PageSetup

PageSetup class

Encapsulates the object that represents the page setup description. The PageSetup object contains all page setup options.

public class PageSetup

Properties

Name Description
BlackAndWhite { get; set; } Represents if elements of the document will be printed in black and white.
BottomMargin { get; set; } Represents the size of the bottom margin, in unit of centimeters.
BottomMarginInch { get; set; } Represents the size of the bottom margin, in unit of inches.
CenterHorizontally { get; set; } Represent if the sheet is printed centered horizontally.
CenterVertically { get; set; } Represent if the sheet is printed centered vertically.
FirstPageNumber { get; set; } Represents the first page number that will be used when this sheet is printed.
FitToPagesTall { get; set; } Represents the number of pages tall the worksheet will be scaled to when it’s printed. The default value is 1.
FitToPagesWide { get; set; } Represents the number of pages wide the worksheet will be scaled to when it’s printed. The default value is 1.
FooterMargin { get; set; } Represents the distance from the bottom of the page to the footer, in unit of centimeters.
FooterMarginInch { get; set; } Represents the distance from the bottom of the page to the footer, in unit of inches.
HeaderMargin { get; set; } Represents the distance from the top of the page to the header, in unit of centimeters.
HeaderMarginInch { get; set; } Represents the distance from the top of the page to the header, in unit of inches.
IsAutoFirstPageNumber { get; set; } Indicates whether the first the page number is automatically assigned.
IsAutomaticPaperSize { get; } Indicates whether the paper size is automatic.
IsHFAlignMargins { get; set; } Indicates whether header and footer margins are aligned with the page margins. If this property is true, the left header and footer will be aligned with the left margin, and the right header and footer will be aligned with the right margin. This option is enabled by default.
IsHFDiffFirst { get; set; } True means that the header/footer of the first page is different with other pages.
IsHFDiffOddEven { get; set; } True means that the header/footer of the odd pages is different with odd pages.
IsHFScaleWithDoc { get; set; } Indicates whether header and footer are scaled with document scaling. Only applies for Excel 2007.
IsPercentScale { get; set; } If this property is False, the FitToPagesWide and FitToPagesTall properties control how the worksheet is scaled.
LeftMargin { get; set; } Represents the size of the left margin, in unit of centimeters.
LeftMarginInch { get; set; } Represents the size of the left margin, in unit of inches.
ODSPageBackground { get; } Gets the background of ODS.
Order { get; set; } Represents the order that Microsoft Excel uses to number pages when printing a large worksheet.
Orientation { get; set; } Represents page print orientation.
PaperHeight { get; } Gets the height of the paper in unit of inches , considered page orientation.
PaperSize { get; set; } Represents the size of the paper.
PaperWidth { get; } Gets the width of the paper in unit of inches, considered page orientation.
PrintArea { get; set; } Represents the range to be printed.
PrintComments { get; set; } Represents the way comments are printed with the sheet.
PrintCopies { get; set; } Get and sets number of copies to print.
PrintDraft { get; set; } Represents if the sheet will be printed without graphics.
PrintErrors { get; set; } Specifies the type of print error displayed.
PrinterSettings { get; set; } Gets and sets the settings of the default printer.
PrintGridlines { get; set; } Represents if cell gridlines are printed on the page.
PrintHeadings { get; set; } Represents if row and column headings are printed with this page.
PrintQuality { get; set; } Represents the print quality.
PrintTitleColumns { get; set; } Represents the columns that contain the cells to be repeated on the left side of each page.
PrintTitleRows { get; set; } Represents the rows that contain the cells to be repeated at the top of each page.
RightMargin { get; set; } Represents the size of the right margin, in unit of centimeters.
RightMarginInch { get; set; } Represents the size of the right margin, in unit of inches.
TopMargin { get; set; } Represents the size of the top margin, in unit of centimeters.
TopMarginInch { get; set; } Represents the size of the top margin, in unit of inches.
Zoom { get; set; } Represents the scaling factor in percent. It should be between 10 and 400.

Methods

Name Description
ClearHeaderFooter() Clears header and footer setting.
Copy(PageSetup, CopyOptions) Copies the setting of the page setup.
CustomPaperSize(double, double) Sets the custom paper size, in unit of inches.
GetCommands(string) Gets all commands of header or footer.
GetEvenFooter(int) Gets a script formatting the even footer of an Excel file.
GetEvenHeader(int) Gets a script formatting the even header of an Excel file.
GetFirstPageFooter(int) Gets a script formatting the first page footer of an Excel file.
GetFirstPageHeader(int) Gets a script formatting the first page header of an Excel file.
GetFooter(int) Gets a script formatting the footer of an Excel file.
GetHeader(int) Gets a script formatting the header of an Excel file.
GetPicture(bool, int) Gets the Picture object of the header / footer.
GetPicture(bool, bool, bool, int) Gets the Picture object of the header / footer.
SetEvenFooter(int, string) Sets a script formatting the even page footer of an Excel file. Only effect in Excel 2007 when IsHFDiffOddEven is true.
SetEvenHeader(int, string) Sets a script formatting the even page header of an Excel file. Only effect in Excel 2007 when IsHFDiffOddEven is true.
SetFirstPageFooter(int, string) Sets a script formatting the first page footer of an Excel file.
SetFirstPageHeader(int, string) Sets a script formatting the first page header of an Excel file. Only effect in Excel 2007 when IsHFDiffFirst is true.
SetFitToPages(int, int) Sets the number of pages the worksheet will be scaled to when it’s printed.
SetFooter(int, string) Sets a script formatting the footer of an Excel file.
SetFooterPicture(int, byte[]) Sets an image in the footer of a worksheet.
SetHeader(int, string) Sets a script formatting the header of an Excel file.
SetHeaderPicture(int, byte[]) Sets an image in the header of a worksheet.
SetPicture(bool, bool, bool, int, byte[]) Sets an image in the header/footer of a worksheet.

Examples

[C#]

Workbook workbook = new Workbook();

WorksheetCollection sheets = workbook.Worksheets;

//Add a worksheet
sheets.Add();
Worksheet sheet = sheets[1];
PageSetup pageSetup = sheet.PageSetup;
pageSetup.PrintArea = "D1:K13";

//do your business

[Visual Basic]
Dim excel as Workbook = new Workbook()

Dim sheets as WorksheetCollection = excel.Worksheets

'Add a worksheet
sheets.Add()
Dim sheet as Worksheet = sheets(1)
Dim pageSetup as PageSetup = sheet.PageSetup
pageSetup.PrintArea = "D1:K13"

See Also