Back to Devexpress

Sheet.Print(PrinterSettings) Method

officefileapi-devexpress-dot-spreadsheet-dot-sheet-dot-print-x28-system-dot-drawing-dot-printing-dot-printersettings-x29.md

latest4.4 KB
Original Source

Sheet.Print(PrinterSettings) Method

Prints the current sheet using the specified printer settings.

Namespace : DevExpress.Spreadsheet

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

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
void Print(
    PrinterSettings printerSettings
)
vb
Sub Print(
    printerSettings As PrinterSettings
)

Parameters

NameTypeDescription
printerSettingsPrinterSettings

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

csharp
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);
vb
Imports DevExpress.Spreadsheet
Imports System.Drawing.Printing
' ...

' Create an object containing printer settings.
Dim printerSettings As 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

WorksheetView

WorksheetPrintOptions

WinForms Spreadsheet Control Examples

Sheet Interface

Sheet Members

DevExpress.Spreadsheet Namespace