Skip to main content

How to: Specify Print Settings

  • 2 minutes to read

Use the Worksheet.ActiveView property to specify the following page options:

Property Description
WorksheetView.Margins Defines page margins.
WorksheetView.Orientation Specifies page orientation.
WorksheetView.PaperKind Specifies paper size.
WorksheetView.SetCustomPaperSize Specifies custom paper size for a worksheet.

Use the Worksheet.PrintOptions property to configure print options. Print options include the following:

Property Description
WorksheetPrintOptions.FitToPage Indicates whether to scale a worksheet to fit its data within a specified number of pages.
WorksheetPrintOptions.FitToWidth Specifies the number of pages a worksheet should fit within horizontally.
WorksheetPrintOptions.FitToHeight Specifies the number of pages a worksheet should fit within vertically.
WorksheetPrintOptions.Scale Specifies the percentage by which to scale the worksheet content.
WorksheetPrintOptions.PrintGridlines Specifies whether to print worksheet gridlines.
WorksheetPrintOptions.PrintHeadings Specifies whether to print row and column headings.
WorksheetPrintOptions.PrintTitles Allows you to repeat specific rows and columns on the printed pages.
WorksheetPrintOptions.BlackAndWhite Allows you to print a worksheet in black and white.
WorksheetPrintOptions.PageOrder Specifies the order of printed pages.
WorksheetPrintOptions.PageNumbering Allows you to specify the first page number.
WorksheetPrintOptions.CenterHorizontally Specifies whether to center data horizontally on the printed page.
WorksheetPrintOptions.CenterVertically Specifies whether to center data vertically on the printed page.
WorksheetPrintOptions.ErrorsPrintMode Specifies how to print cell errors.

Important

The WorksheetPrintOptions.Draft, WorksheetPrintOptions.NumberOfCopies and WorksheetPrintOptions.CommentsPrintMode options are not supported when you print a workbook from the Spreadsheet component. The Spreadsheet saves these property values to a document, so that you can print the document in Microsoft® Excel® or another spreadsheet application.

View Example

// Set page orientation to landscape.
worksheet.ActiveView.Orientation = PageOrientation.Landscape;
// Select paper size.
worksheet.ActiveView.PaperKind = DevExpress.Drawing.Printing.DXPaperKind.A4;
// Access an object that contains print options.
WorksheetPrintOptions printOptions = worksheet.PrintOptions;
// Do not print gridlines.
printOptions.PrintGridlines = false;
// Scale the worksheet to fit within the width of one page.
printOptions.FitToPage = true;
printOptions.FitToWidth = 1;
// Print in black and white.
printOptions.BlackAndWhite = true;
// Print a dash instead of a cell error message.
printOptions.ErrorsPrintMode = ErrorsPrintMode.Dash;