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

How to: Specify Print Settings

  • 2 minutes to read

This topic demonstrates how to fine-tune print settings for a worksheet to create a desired page layout.

A WorksheetView object’s properties allow you to specify general page options. Use the Worksheet.ActiveView property to access a worksheet’s active view.

Property Description
WorksheetView.Margins Defines page margins.
WorksheetView.Orientation Specifies page orientation.
WorksheetView.PaperKind Specifies paper size.

More print-specific options are available from the WorksheetPrintOptions object. To access this object, use the Worksheet.PrintOptions property.

Property Description
WorksheetPrintOptions.FitToPage Determines whether worksheet content should be scaled to fit on a specific number of pages.
WorksheetPrintOptions.FitToWidth Specifies the number of pages that a worksheet should fit on horizontally.
WorksheetPrintOptions.FitToHeight Specifies the number of pages that a worksheet should fit on vertically.
WorksheetPrintOptions.Scale Specifies the percentage by which to scale 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 every printed page.
WorksheetPrintOptions.PageOrder Specifies the order in which worksheet pages are numbered and printed.
WorksheetPrintOptions.PageNumbering Contains page numbering options for a worksheet.
WorksheetPrintOptions.CenterHorizontally Specifies whether worksheet data should be centered horizontally on a printed page.
WorksheetPrintOptions.CenterVertically Specifies whether worksheet data should be centered vertically on a printed page.
WorksheetPrintOptions.ErrorsPrintMode Specifies how cell errors are printed.

Note

The WorksheetPrintOptions.Draft, WorksheetPrintOptions.BlackAndWhite, WorksheetPrintOptions.NumberOfCopies and WorksheetPrintOptions.CommentsPrintMode options are not supported when printing a document from the SpreadsheetControl. They are, however, saved to a file, allowing you to use Microsoft® Excel® or another spreadsheet application to load and print a document.

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 that contains print options.
WorksheetPrintOptions printOptions = worksheet.PrintOptions;
// Do not print gridlines.
printOptions.PrintGridlines = false;
// Scale the print area to fit to two pages wide.
printOptions.FitToPage = true;
printOptions.FitToWidth = 2;
// Print a dash instead of a cell error message.
printOptions.ErrorsPrintMode = ErrorsPrintMode.Dash;