Back to Devexpress

Worksheet.SetPrintRange(CellRange) Method

officefileapi-devexpress-dot-spreadsheet-dot-worksheet-dot-setprintrange-x28-devexpress-dot-spreadsheet-dot-cellrange-x29.md

latest3.5 KB
Original Source

Worksheet.SetPrintRange(CellRange) Method

Defines the print range.

Namespace : DevExpress.Spreadsheet

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

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
void SetPrintRange(
    CellRange range
)
vb
Sub SetPrintRange(
    range As CellRange
)

Parameters

NameTypeDescription
rangeCellRange

A CellRange object that is the worksheet range to print.

|

Remarks

The SetPrintRange method sets the worksheet print range. To extend the print range, use the Worksheet.AddPrintRange method.

Example

csharp
// Define a print area on a worksheet.
CellRange printArea = worksheet["B1:F39"];
worksheet.SetPrintRange(printArea);

// Enlarge the print area by adding adjacent cells.
// An additional print area is created if you add non-adjacent cells to the print area.
worksheet.AddPrintRange(worksheet["B40:F50"]);

// Uncomment the following line to clear the print area and print the entire worksheet.
// worksheet.ClearPrintRange();
vb
' Define a print area on a worksheet.
Dim printArea As CellRange = worksheet("B1:F39")
worksheet.SetPrintRange(printArea)

' Enlarge the print area by adding adjacent cells.
' An additional print area is created if you add non-adjacent cells to the print area.
worksheet.AddPrintRange(worksheet("B40:F50"))

' Uncomment the following line to clear the print area and print the entire worksheet.
' worksheet.ClearPrintRange();

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the SetPrintRange(CellRange) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

spreadsheet-document-api-create-loan-amortization-schedule-within-blazor-server-app/CS/BlazorAppSpreadsheet/Code/DocumentGenerator.cs#L200

csharp
// for the worksheet.
Sheet.SetPrintRange(Sheet.GetDataRange());
Sheet.PrintOptions.FitToPage = true;

See Also

AddPrintRange(CellRange)

Worksheet Interface

Worksheet Members

DevExpress.Spreadsheet Namespace