Page Setup Dialog in Spreadsheet Control
- 4 minutes to read
The Page Setup dialog allows end-users to specify the page orientation, paper size, margins, printout options, and it allows them to add headers and footers to a worksheet.
End-users can invoke the Page Setup dialog by clicking the dialog box launcher located in the bottom-right corner of the Page Setup group on the Page Layout tab of the ribbon UI. For an example on how to create a ribbon UI and add the Page Setup page group to the SpreadsheetControl, refer to the Getting Started topic.
The Page Setup dialog includes the following tabs.
Options under the Page tab enable end-users to set page orientation (SheetView.Orientation), scaling options (WorksheetPrintOptions.Scale, WorksheetPrintOptions.FitToWidth and WorksheetPrintOptions.FitToHeight), paper size (SheetView.PaperKind), printing DPI and the starting page number (WorksheetPageNumbering.Start).
This tab allows end-users to set page margins, which determine the space between the document content and page edges. To specify margins in code, use the SheetView.Margins property.
End-users can center worksheet data on a printed page by selecting the Horizontally (WorksheetPrintOptions.CenterHorizontally) and Vertically (WorksheetPrintOptions.CenterVertically) check boxes.
Using this tab, end-users can add headers and footers to a worksheet printout. They can select one of the predefined options in the Header or Footer drop-down list, or specify custom headers and footers using the Header and Footer dialog, which can be invoked by clicking the Custom Header/Footer… button. To get access to the worksheet header and footer in code, use the Worksheet.HeaderFooterOptions property.
This tab also allows end-users to specify a number of settings affecting both headers and footers.
Different odd and even pages (WorksheetHeaderFooterOptions.DifferentOddEven)
An end-user can select this check box to indicate that odd-numbered pages should have headers and footers different from those on even-numbered pages.
Different first page (WorksheetHeaderFooterOptions.DifferentFirst)
An end-user can select this check box to specify whether the first page of a worksheet should contain unique headers and footers.
Scale with document (WorksheetHeaderFooterOptions.ScaleWithDoc)
An end-user can select this check box to scale headers and footers proportionately when print scaling options are used to fit information on the specified number of pages.
Align with page margins (WorksheetHeaderFooterOptions.AlignWithMargins)
An end-user can select this check box to center the header and footer in relation to the left and right margins of a worksheet.
The Sheet tab allows end-users to specify the following high-powered printout options.
Print area (Worksheet.SetPrintRange)
In the Print area box, an end-user can type a cell range to be printed.
Print titles (WorksheetPrintOptions.PrintTitles)
This group of settings allows an end-user to specify rows and columns to be repeated on every printed page.
An end-user can select this check box to display worksheet gridlines on a printed page.
Black and white (WorksheetPrintOptions.BlackAndWhite)
An end-user can select this check box to print a worksheet in black and white.
Draft quality (WorksheetPrintOptions.Draft)
An end-user can select this check box to print a worksheet without graphics.
Row and column headings (WorksheetPrintOptions.PrintHeadings)
An end-user can select this check box to include row and column headings into a worksheet printout.
In the Comments box, end-users can select one of the built-in options to specify how to print comments attached to worksheet cells. They can either omit comments on printing, print them as they are displayed on the worksheet, or append them to a separate page at the end of a worksheet printout.
Cell errors as (WorksheetPrintOptions.ErrorsPrintMode)
In this box, end-users can select how to print formula errors contained in worksheet cells. They can print errors as they are displayed on the worksheet, replace them with blank values, display errors as two dashes (–), or print the error code #N/A in the corresponding cells.
Page order (WorksheetPrintOptions.PageOrder)
An end-user can click Down, then over or Over, then down to specify whether worksheet pages should be numbered and printed from the top down and then left to right (PageOrder.DownThenOver) or from left to right and then from the top down (PageOrder.OverThenDown).
An end-user can click the Print button located at the bottom of each tab to send the worksheet to a printer, or invoke the Print Preview window to view a worksheet before printing by clicking the Print Preview button.
The Black and white, Draft quality and Comments options are not taken into account when printing a document from the SpreadsheetControl. However, they are saved to a file, so you can use Microsoft® Excel® or another spreadsheet application to load and print a document.
For examples on how to specify print settings for a worksheet in code, refer to the Printing section.