Worksheet Page Setup – Configure Print Layout with Aspose.Cells Cloud
Contents
[
Hide
]
PageSetup
Excel print page settings
Overview
The PageSetup object defines the print‑layout options for an Excel worksheet, such as margins, orientation, scaling, headers, footers, and other print‑related settings. Configuring these properties lets developers produce printable workbooks that match the desired appearance and pagination.
Below is a short C# example that demonstrates how to set common page‑setup properties using the Aspose.Cells Cloud SDK:
using Aspose.Cells.Cloud.SDK.Api;
using Aspose.Cells.Cloud.SDK.Model;
// Initialize the API client (replace with your credentials)
var apiInstance = new CellsApi("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET");
// Define the PageSetup settings
var pageSetup = new PageSetup()
{
Orientation = "Landscape",
PaperSize = "A4",
CenterHorizontally = true,
CenterVertically = true,
Zoom = 100
};
// Apply the settings to the first worksheet of the workbook
apiInstance.PutWorksheetPageSetup("Sample.xlsx", "Sheet1", pageSetup);
This snippet sets the worksheet to landscape orientation, uses A4 paper, centers the content, and applies a 100 % zoom factor.
Properties
| Property Name | Property Type | Nullable | ReadOnly | DefaultValue | Description |
|---|---|---|---|---|---|
| BlackAndWhite | bool | false | false | false | Prints the worksheet in black‑and‑white mode. |
| BottomMargin | float | true | false | 2.54 cm | Size of the bottom margin in centimeters. |
| CenterHorizontally | bool | false | false | false | Centers the sheet horizontally when printed. |
| CenterVertically | bool | false | false | false | Centers the sheet vertically when printed. |
| FirstPageNumber | int | true | false | 1 | The first page number used when the sheet is printed. |
| FitToPagesTall | int | false | false | 1 | Number of pages tall to which the worksheet will be scaled. |
| FitToPagesWide | int | false | false | 1 | Number of pages wide to which the worksheet will be scaled. |
| FooterMargin | float | true | false | 2.54 cm | Distance from the bottom of the page to the footer, in centimeters. |
| HeaderMargin | float | true | false | 2.54 cm | Distance from the top of the page to the header, in centimeters. |
| IsAutoFirstPageNumber | bool | false | false | false | Assigns the first page number automatically. |
| IsHFAlignMargins | bool | false | false | true | When true, header/footer margins align with the page margins. |
| IsHFDiffFirst | bool | false | false | false | Indicates that the header/footer on the first page differs from other pages. |
| IsHFDiffOddEven | bool | false | false | false | Indicates that the header/footer on odd pages differs from even pages. |
| IsHFScaleWithDoc | bool | false | false | false | Scales header and footer together with the document (Excel 2007+). |
| IsPercentScale | bool | false | false | true | When false, FitToPagesWide and FitToPagesTall control scaling. |
| LeftMargin | float | true | false | 2.54 cm | Size of the left margin in centimeters. |
| Order | string | true | false | “DownThenOver” | The order Excel uses to number pages when printing a large worksheet. |
| Orientation | string | false | false | “Portrait” | Page orientation: Landscape or Portrait. |
| PaperSize | string | true | false | “A4” | Paper size used for printing. |
| PrintArea | string | true | false | (none) | Range of cells to be printed (e.g., "A1:D20"). |
| PrintComments | string | true | false | “NoComments” | How comments are printed with the sheet. |
| PrintCopies | int | true | false | 1 | Number of copies to print. |
| PrintDraft | bool | false | false | false | Prints the worksheet in draft mode (no graphics). |
| PrintErrors | string | true | false | “Display” | Type of print error displayed. |
| PrintGridlines | bool | false | false | false | Prints cell gridlines. |
| PrintHeadings | bool | false | false | false | Prints row and column headings. |
| PrintQuality | int | true | false | 600 | Print quality setting (dots per inch). |
| PrintTitleColumns | string | true | false | (none) | Columns to repeat on the left side of each printed page. |
| PrintTitleRows | string | true | false | (none) | Rows to repeat at the top of each printed page. |
| RightMargin | float | true | false | 2.54 cm | Size of the right margin in centimeters. |
| TopMargin | float | true | false | 2.54 cm | Size of the top margin in centimeters. |
| Zoom | int | false | false | 100 | Scaling factor in percent (10 – 400%). |
| Header | object | true | false | (none) | Page header configuration. |
| Footer | object | true | false | (none) | Page footer configuration. |
Related Objects
- Header – Configures the worksheet header.
- Footer – Configures the worksheet footer.
- PrintOptions – Additional print‑related settings such as page breaks and print area.