Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Class

ExcelSheetPageSetup

OfficeIMO.Excel

Namespace
OfficeIMO.Excel
Assembly
OfficeIMO.Excel
Source revision
e163ccb36643 with working tree changes
Modifiers
sealed

Page setup of a worksheet: paper, orientation, scaling, margins, print area and titles, print options, and headers and footers. Values are read from and written to the worksheet directly.

Inheritance

  • object
  • ExcelSheetPageSetup

Usage

Explore 4 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

Methods

ApplyLayout 2 overloads
public ExcelSheetPageSetup ApplyLayout(ExcelPrintLayoutOptions options) #

Applies a print layout preset, such as Report or Wide, with optional overrides.

Parameters

options OfficeIMO.Excel.ExcelPrintLayoutOptions required
public ExcelSheetPageSetup ApplyLayout(ExcelPrintLayoutPreset preset, string? printArea = null) #

Applies a print layout preset and an optional print area.

Parameters

preset OfficeIMO.Excel.ExcelPrintLayoutPreset required
printArea string? = null optional
SetMargins 2 overloads
public ExcelSheetPageSetup SetMargins(OfficeLength left, OfficeLength right, OfficeLength top, OfficeLength bottom, OfficeLength? header = null, OfficeLength? footer = null) #

Sets physical page margins. Omitted header and footer margins are 0.3 inches.

Parameters

left OfficeIMO.OfficeLength required
right OfficeIMO.OfficeLength required
top OfficeIMO.OfficeLength required
bottom OfficeIMO.OfficeLength required
header OfficeIMO.OfficeLength? = null optional
footer OfficeIMO.OfficeLength? = null optional
public ExcelSheetPageSetup SetMargins(ExcelMarginPreset preset) #

Sets the margins of one of Excel's margin presets.

Parameters

preset OfficeIMO.Excel.ExcelMarginPreset required
public ExcelSheetPageSetup SetPrintTitles(int? firstRow, int? lastRow, int? firstColumn = null, int? lastColumn = null) #

Sets the rows and columns repeated on every printed page; nulls on both axes clear them.

Parameters

firstRow int? required
lastRow int? required
firstColumn int? = null optional
lastColumn int? = null optional

Properties

public OfficePageOrientation? Orientation { get; set; } #

Page orientation; null when the worksheet does not store one (Excel prints portrait).

public ExcelPaperSize? PaperSize { get; set; } #

Known paper size; null when none is stored or the stored code has no ExcelPaperSize value.

public uint? PaperSizeCode { get; } #

Stored OpenXML paper-size code, including codes without an ExcelPaperSize value.

public uint? FitToWidth { get; set; } #

Pages to fit horizontally when fit-to-page is on; null when it is off. Setting a value turns fit-to-page on. An omitted dimension defaults to one; zero leaves the axis unlimited.

public uint? FitToHeight { get; set; } #

Pages to fit vertically when fit-to-page is on; null when it is off. Setting a value turns fit-to-page on. An omitted dimension defaults to one; zero leaves the axis unlimited.

public uint? Scale { get; set; } #

Manual print scale percentage (10-400); null when none is stored.

public ExcelPageOrder? PageOrder { get; set; } #

Order in which multi-page sheets print; null when none is stored.

public ExcelSheetPageMargins? Margins { get; } #

Page margins; null when the worksheet does not store them.

public string? PrintArea { get; set; } #

Print area as stored, with one or more comma-separated areas; null when none is set. Setting null removes it.

public IReadOnlyList<string> PrintAreas { get; } #

The separate print areas in their stored order; empty when none is set.

public ExcelPrintTitles PrintTitles { get; } #

Rows and columns repeated on every printed page.

public bool PrintGridLines { get; set; } #

Whether cell gridlines print.

public bool PrintHeadings { get; set; } #

Whether row and column headings print.

public bool HorizontalCentered { get; set; } #

Whether the printed sheet is centered horizontally on the page.

public bool VerticalCentered { get; set; } #

Whether the printed sheet is centered vertically on the page.

public ExcelHeaderFooter Header { get; } #

Header on every page, or on odd pages when ExcelSheetPageSetup.DifferentOddEven is on.

public ExcelHeaderFooter FirstPageHeader { get; } #

Header on the first page; writing text turns ExcelSheetPageSetup.DifferentFirstPage on.

public ExcelHeaderFooter FirstPageFooter { get; } #

Footer on the first page; writing text turns ExcelSheetPageSetup.DifferentFirstPage on.

public ExcelHeaderFooter EvenPageHeader { get; } #

Header on even pages; writing text turns ExcelSheetPageSetup.DifferentOddEven on.

public ExcelHeaderFooter EvenPageFooter { get; } #

Footer on even pages; writing text turns ExcelSheetPageSetup.DifferentOddEven on.

public bool DifferentFirstPage { get; set; } #

Whether the first page uses its own header and footer. Turning it on copies the running header and footer into a missing first-page variant; existing first-page text is kept when it is turned off.

public bool DifferentOddEven { get; set; } #

Whether even pages use their own header and footer. Turning it on copies the running header and footer into a missing even-page variant; existing even-page text is kept when it is turned off.

public bool AlignHeaderFooterWithMargins { get; set; } #

Whether headers and footers align with the page margins.

public bool ScaleHeaderFooterWithDocument { get; set; } #

Whether headers and footers scale with the document.