Skip to main content
A newer version of this page is available. .

How to: Specify Print Settings

  • 2 minutes to read

This example demonstrates how set print options to create the required printout.

To set general page options, specify the WorksheetView properties. The Active view for the worksheet is accessible via the Worksheet.ActiveView property. Worksheet View enables you to set orientation, margins and paper size settings, among others. View settings are used when a worksheet is being printed.

Worksheet printing options is a set of more print-specific options accessible via the Worksheet.PrintOptions property.

To scale the content to fit in a specific number of pages, set the WorksheetPrintOptions.FitToPage property to true and specify the desired number of pages by width (WorksheetPrintOptions.FitToWidth property) or by height (the WorksheetPrintOptions.FitToHeight property). You can scale the content arbitrarily by specifying the scale percentage using the WorksheetPrintOptions.Scale property. In this case, the WorksheetPrintOptions.FitToPage property is false

Other options include printing gridlines (the WorksheetPrintOptions.PrintGridlines property), printing in color or black-and-white (the WorksheetPrintOptions.BlackAndWhite property), and more.

Note

Not all worksheet printing options are supported when printing a document using a PrintableComponentLink.

View settings and worksheet printing options are stored in a worksheet file, so you can use Microsoft Excel or other spreadsheet applications to load a document from a file and print it without the need to specify additional print options.

worksheet.ActiveView.Orientation = PageOrientation.Landscape;
//  Display row and column headings.
worksheet.ActiveView.ShowHeadings = true;
worksheet.ActiveView.PaperKind = System.Drawing.Printing.PaperKind.A4;
// Access an object providing print options.
WorksheetPrintOptions printOptions = worksheet.PrintOptions;
//  Print in black and white.
printOptions.BlackAndWhite = true;
//  Do not print gridlines.
printOptions.PrintGridlines = false;
//  Scale the print area to fit to a  page.
printOptions.FitToPage = true;
//  Print a dash instead of a cell error message.
printOptions.ErrorsPrintMode = ErrorsPrintMode.Dash;