Skip to main content
Row

Sheet.Print(PrinterSettings) Method

Prints the current sheet using the specified printer settings.

Namespace: DevExpress.Spreadsheet

Assembly: DevExpress.Spreadsheet.v24.2.Core.dll

NuGet Package: DevExpress.Spreadsheet.Core

Declaration

void Print(
    PrinterSettings printerSettings
)

Parameters

Name Type Description
printerSettings PrinterSettings

A PrinterSettings object that contains printer settings.

Remarks

Use this Print method overload to print a particular sheet in a document using the custom printer settings specified by the PrinterSettings class instance. For example, the PrinterSettings.Copies property allows you to set the number of copies to print, the PrinterSettings.PrinterName property determines the printer to use, and the PrinterSettings.PrintRange property defines a print range. If PrinterSettings.PrintRange is SomePages, use the PrinterSettings.FromPage and PrinterSettings.ToPage properties to specify what pages should be printed.

To define general page options, use properties of the WorksheetView object accessible from the Worksheet.ActiveView property. WorksheetView enables you to specify page orientation, margins, and paper size settings.

The WorksheetPrintOptions object’s properties allow you to specify more print-specific options, which include scaling, printing gridlines, titles, row and column headings, setting page order, and more.

For more information on how to specify print settings and print a document, refer to the Printing example section.

Warning

The Print(PrinterSettings) method overload works only on Windows OS. The PlatformNotSupportedException is thrown on other operating systems. Use the Print method overloads with DXPrinterSettings printerSettings parameter to print on other operating systems.

Example: Print Worksheet with Specified Print Settings

using DevExpress.Spreadsheet;
using System.Drawing.Printing;
// ...

// Create an object containing printer settings.
PrinterSettings printerSettings = new PrinterSettings();

// Specify that the first two pages should be printed.
printerSettings.PrintRange = PrintRange.SomePages;
printerSettings.FromPage = 1;
printerSettings.ToPage = 2;

// Set the number of copies to print.
printerSettings.Copies = 2;

// Print the active worksheet in the workbook 
// using the specified printer settings.
workbook.Worksheets.ActiveWorksheet.Print(printerSettings);
See Also