Back to Devexpress

How to: Define a Print Area

officefileapi-119938-spreadsheet-document-api-examples-printing-how-to-define-a-print-area.md

latest1.8 KB
Original Source

How to: Define a Print Area

  • Sep 19, 2023

The table below lists a Worksheet object’s methods that allow you to set or clear a print area on a worksheet. A print area designates one or more cell ranges as the only region to print. A worksheet can have multiple print areas. Each print area is printed on a separate page.

MethodDescription
Worksheet.SetPrintRangeDefines a print area.
Worksheet.AddPrintRangeAdds cells to an existing print area.
Worksheet.ClearPrintRangeClears a print area to print the entire worksheet.
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();