PageSetup
PageSetup class
Encapsulates the object that represents the page setup description. The PageSetup object contains all page setup options.
Properties
| Name | Type | Description |
|---|---|---|
| ODSPageBackground | OdsPageBackground | Gets the background of ODS. |
| PrintArea | String | Represents the range to be printed. |
| PrintTitleColumns | String | Represents the columns that contain the cells to be repeated on the left side of each page. |
| PrintTitleRows | String | Represents the rows that contain the cells to be repeated at the top of each page. |
| BlackAndWhite | boolean | Represents if elements of the document will be printed in black and white. |
| CenterHorizontally | boolean | Represent if the sheet is printed centered horizontally. |
| CenterVertically | boolean | Represent if the sheet is printed centered vertically. |
| PrintDraft | boolean | Represents if the sheet will be printed without graphics. |
| FooterMargin | float | Represents the distance from the bottom of the page to the footer, in unit of centimeters. |
| FooterMarginInch | float | Represents the distance from the bottom of the page to the footer, in unit of inches. |
| HeaderMargin | float | Represents the distance from the top of the page to the header, in unit of centimeters. |
| HeaderMarginInch | float | Represents the distance from the top of the page to the header, in unit of inches. |
| PrinterSettings | byte[] | Gets and sets the settings of the default printer. |
| LeftMargin | float | Represents the size of the left margin, in unit of centimeters. |
| LeftMarginInch | float | Represents the size of the left margin, in unit of inches. |
| RightMargin | float | Represents the size of the right margin, in unit of centimeters. |
| RightMarginInch | float | Represents the size of the right margin, in unit of inches. |
| TopMargin | float | Represents the size of the top margin, in unit of centimeters. |
| TopMarginInch | float | Represents the size of the top margin, in unit of inches. |
| BottomMargin | float | Represents the size of the bottom margin, in unit of centimeters. |
| BottomMarginInch | float | Represents the size of the bottom margin, in unit of inches. |
| FirstPageNumber | int | Represents the first page number that will be used when this sheet is printed. |
| FitToPagesTall | int | Represents the number of pages tall the worksheet will be scaled to when it’s printed. The default value is 1. You have |
| FitToPagesWide | int | Represents the number of pages wide the worksheet will be scaled to when it’s printed. The default value is 1. You have |
| IsPercentScale | boolean | If this property is False, the FitToPagesWide and FitToPagesTall properties control how the worksheet is scaled. |
| Order | int | Represents the order that Microsoft Excel uses to number pages when printing a large worksheet. The value of the propert |
| IsAutomaticPaperSize | boolean | Indicates whether the paper size is automatic. |
| PaperSize | int | Represents the size of the paper. The value of the property is PaperSizeType integer constant. |
| PaperWidth | float | Gets the width of the paper in unit of inches, considered page orientation. |
| PaperHeight | float | Gets the height of the paper in unit of inches , considered page orientation. |
| Orientation | int | Represents page print orientation. The value of the property is PageOrientationType integer constant. |
| PrintComments | int | Represents the way comments are printed with the sheet. The value of the property is PrintCommentsType integer constant. |
| PrintErrors | int | Specifies the type of print error displayed. The value of the property is PrintErrorsType integer constant. |
| PrintHeadings | boolean | Represents if row and column headings are printed with this page. |
| PrintGridlines | boolean | Represents if cell gridlines are printed on the page. |
| Zoom | int | Represents the scaling factor in percent. It should be between 10 and 400. |
| IsAutoFirstPageNumber | boolean | Indicates whether the first the page number is automatically assigned. |
| PrintQuality | int | Represents the print quality. |
| PrintCopies | int | Get and sets number of copies to print. |
| IsHFDiffOddEven | boolean | True means that the header/footer of the odd pages is different with odd pages. |
| IsHFDiffFirst | boolean | True means that the header/footer of the first page is different with other pages. |
| IsHFScaleWithDoc | boolean | Indicates whether header and footer are scaled with document scaling. Only applies for Excel 2007. |
| IsHFAlignMargins | boolean | Indicates whether header and footer margins are aligned with the page margins. If this property is true, the left header |
Methods
| Name | Description |
|---|---|
| setHeaderPicture | Sets an image in the header of a worksheet. |
| setFooterPicture | Sets an image in the footer of a worksheet. |
| setPicture | Sets an image in the header/footer of a worksheet. |
| getPicture | Gets the Picture object of the header / footer. |
| copy | Copies the setting of the page setup. |
| setFitToPages | Sets the number of pages the worksheet will be scaled to when it’s printed. |
| customPaperSize | Sets the custom paper size, in unit of inches. |
| clearHeaderFooter | Clears header and footer setting. |
| getHeader | Gets a script formatting the header of an Excel file. |
| getCommands | Gets all commands of header or footer. |
| getFooter | Gets a script formatting the footer of an Excel file. |
| setHeader | Sets a script formatting the header of an Excel file. |
Script commands: Command Description &P Current page number &N Pa | | setFooter | Sets a script formatting the footer of an Excel file.
Script commands: Command Description &P Current page number &N Pa | | setEvenHeader | Sets a script formatting the even page header of an Excel file. Only effect in Excel 2007 when IsHFDiffOddEven is true. | | getEvenHeader | Gets a script formatting the even header of an Excel file. | | setEvenFooter | Sets a script formatting the even page footer of an Excel file. Only effect in Excel 2007 when IsHFDiffOddEven is true. | | getEvenFooter | Gets a script formatting the even footer of an Excel file. | | setFirstPageHeader | Sets a script formatting the first page header of an Excel file. Only effect in Excel 2007 when IsHFDiffFirst is true. | | getFirstPageHeader | Gets a script formatting the first page header of an Excel file. | | setFirstPageFooter | Sets a script formatting the first page footer of an Excel file. | | getFirstPageFooter | Gets a script formatting the first page footer of an Excel file. |
PageSetup.ODSPageBackground property
Gets the background of ODS.
Type: OdsPageBackground
PageSetup.PrintArea property
Represents the range to be printed.
Type: String
PageSetup.PrintTitleColumns property
Represents the columns that contain the cells to be repeated on the left side of each page.
Type: String
PageSetup.PrintTitleRows property
Represents the rows that contain the cells to be repeated at the top of each page.
Type: String
PageSetup.BlackAndWhite property
Represents if elements of the document will be printed in black and white.
Type: boolean
PageSetup.CenterHorizontally property
Represent if the sheet is printed centered horizontally.
Type: boolean
PageSetup.CenterVertically property
Represent if the sheet is printed centered vertically.
Type: boolean
PageSetup.PrintDraft property
Represents if the sheet will be printed without graphics.
Type: boolean
PageSetup.FooterMargin property
Represents the distance from the bottom of the page to the footer, in unit of centimeters.
Type: float
PageSetup.FooterMarginInch property
Represents the distance from the bottom of the page to the footer, in unit of inches.
Type: float
PageSetup.HeaderMargin property
Represents the distance from the top of the page to the header, in unit of centimeters.
Type: float
PageSetup.HeaderMarginInch property
Represents the distance from the top of the page to the header, in unit of inches.
Type: float
PageSetup.PrinterSettings property
Gets and sets the settings of the default printer.
Type: byte[]
PageSetup.LeftMargin property
Represents the size of the left margin, in unit of centimeters.
Type: float
PageSetup.LeftMarginInch property
Represents the size of the left margin, in unit of inches.
Type: float
PageSetup.RightMargin property
Represents the size of the right margin, in unit of centimeters.
Type: float
PageSetup.RightMarginInch property
Represents the size of the right margin, in unit of inches.
Type: float
PageSetup.TopMargin property
Represents the size of the top margin, in unit of centimeters.
Type: float
PageSetup.TopMarginInch property
Represents the size of the top margin, in unit of inches.
Type: float
PageSetup.BottomMargin property
Represents the size of the bottom margin, in unit of centimeters.
Type: float
PageSetup.BottomMarginInch property
Represents the size of the bottom margin, in unit of inches.
Type: float
PageSetup.FirstPageNumber property
Represents the first page number that will be used when this sheet is printed.
Type: int
PageSetup.FitToPagesTall property
Represents the number of pages tall the worksheet will be scaled to when it’s printed. The default value is 1. You have to set FitToPagesWide as zero if you want to fit all rows on one page.
Type: int
PageSetup.FitToPagesWide property
Represents the number of pages wide the worksheet will be scaled to when it’s printed. The default value is 1. You have to set FitToPagesTall as zero if you want to fit all columns on one page.
Type: int
PageSetup.IsPercentScale property
If this property is False, the FitToPagesWide and FitToPagesTall properties control how the worksheet is scaled.
Type: boolean
PageSetup.Order property
Represents the order that Microsoft Excel uses to number pages when printing a large worksheet. The value of the property is PrintOrderType integer constant.
Type: int
PageSetup.IsAutomaticPaperSize property
Indicates whether the paper size is automatic.
Type: boolean
PageSetup.PaperSize property
Represents the size of the paper. The value of the property is PaperSizeType integer constant.
Type: int
PageSetup.PaperWidth property
Gets the width of the paper in unit of inches, considered page orientation.
Type: float
PageSetup.PaperHeight property
Gets the height of the paper in unit of inches , considered page orientation.
Type: float
PageSetup.Orientation property
Represents page print orientation. The value of the property is PageOrientationType integer constant.
Type: int
PageSetup.PrintComments property
Represents the way comments are printed with the sheet. The value of the property is PrintCommentsType integer constant.
Type: int
PageSetup.PrintErrors property
Specifies the type of print error displayed. The value of the property is PrintErrorsType integer constant.
Type: int
PageSetup.PrintHeadings property
Represents if row and column headings are printed with this page.
Type: boolean
PageSetup.PrintGridlines property
Represents if cell gridlines are printed on the page.
Type: boolean
PageSetup.Zoom property
Represents the scaling factor in percent. It should be between 10 and 400.
Type: int
PageSetup.IsAutoFirstPageNumber property
Indicates whether the first the page number is automatically assigned.
Type: boolean
PageSetup.PrintQuality property
Represents the print quality.
Type: int
PageSetup.PrintCopies property
Get and sets number of copies to print.
Type: int
PageSetup.IsHFDiffOddEven property
True means that the header/footer of the odd pages is different with odd pages.
Type: boolean
PageSetup.IsHFDiffFirst property
True means that the header/footer of the first page is different with other pages.
Type: boolean
PageSetup.IsHFScaleWithDoc property
Indicates whether header and footer are scaled with document scaling. Only applies for Excel 2007.
Type: boolean
PageSetup.IsHFAlignMargins property
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.
Type: boolean
setHeaderPicture(section, headerPicture)
Sets an image in the header of a worksheet.
| Parameter | Type | Description |
|---|---|---|
| section | int | 0: Left Section, 1: Center Section, 2: Right Section. |
| headerPicture | byte[] | Image data. |
Returns: Returns Picture object.
setFooterPicture(section, footerPicture)
Sets an image in the footer of a worksheet.
| Parameter | Type | Description |
|---|---|---|
| section | int | 0: Left Section, 1: Center Section, 2: Right Section. |
| footerPicture | byte[] | Image data. |
Returns: Returns Picture object.
setPicture(isFirst, isEven, isHeader, section, imageData)
Sets an image in the header/footer of a worksheet.
| Parameter | Type | Description |
|---|---|---|
| isFirst | boolean | Indicates whether setting the picture of first page header/footer. |
| isEven | boolean | Indicates whether setting the picture of even page header/footer. |
| isHeader | boolean | Indicates whether setting the picture of header/footer. |
| section | int | 0: Left Section, 1: Center Section, 2: Right Section. |
| imageData | byte[] | Image data. |
Returns: Returns Picture object.
getPicture(isHeader, section) (1 of 2)
Gets the Picture object of the header / footer.
| Parameter | Type | Description |
|---|---|---|
| isHeader | boolean | Indicates whether it is in the header or footer. |
| section | int | 0: Left Section, 1: Center Section, 2: Right Section. |
Returns: Returns Picture object. Returns null if there is no picture.
getPicture(isFirst, isEven, isHeader, section) (2 of 2)
Gets the Picture object of the header / footer.
| Parameter | Type | Description |
|---|---|---|
| isFirst | boolean | Indicates whether getting the picture of first page header/footer. |
| isEven | boolean | Indicates whether getting the picture of even page header/footer. |
| isHeader | boolean | Indicates whether getting the picture of header/footer. |
| section | int | 0: Left Section, 1: Center Section, 2: Right Section. |
Returns: Returns Picture object.
copy(source, copyOptions)
Copies the setting of the page setup.
| Parameter | Type | Description |
|---|---|---|
| source | PageSetup | The source. |
| copyOptions | CopyOptions | The copy options. |
setFitToPages(wide, tall)
Sets the number of pages the worksheet will be scaled to when it’s printed.
| Parameter | Type | Description |
|---|---|---|
| wide | int | Pages wide. |
| tall | int | Pages tall. |
customPaperSize(width, height)
Sets the custom paper size, in unit of inches.
| Parameter | Type | Description |
|---|---|---|
| width | float | The width of the paper. |
| height | float | The height of the paper. |
clearHeaderFooter()
Clears header and footer setting.
getHeader(section)
Gets a script formatting the header of an Excel file.
| Parameter | Type | Description |
|---|---|---|
| section | int | 0: Left Section, 1: Center Section, 2: Right Section. |
getCommands(headerFooterScript)
Gets all commands of header or footer.
| Parameter | Type | Description |
|---|---|---|
| headerFooterScript | String | The header/footer script |
Returns: Returns all commands of header or footer.
getFooter(section)
Gets a script formatting the footer of an Excel file.
| Parameter | Type | Description |
|---|---|---|
| section | int | 0: Left Section, 1: Center Section, 2: Right Section. |
setHeader(section, headerScript)
Sets a script formatting the header of an Excel file.
Script commands: Command Description &P Current page number &N Page count &D Current date &T Current time &A Sheet name &F File name without path &"
| Parameter | Type | Description |
|---|---|---|
| section | int | 0: Left Section, 1: Center Section, 2: Right Section. |
| headerScript | String | Header format script. |
setFooter(section, footerScript)
Sets a script formatting the footer of an Excel file.
Script commands: Command Description &P Current page number &N Page count &D Current date &T Current time &A Sheet name &F File name without path &"
| Parameter | Type | Description |
|---|---|---|
| section | int | 0: Left Section, 1: Center Section, 2: Right Section. |
| footerScript | String | Footer format script. |
setEvenHeader(section, headerScript)
Sets a script formatting the even page header of an Excel file. Only effect in Excel 2007 when IsHFDiffOddEven is true.
| Parameter | Type | Description |
|---|---|---|
| section | int | 0: Left Section, 1: Center Section, 2: Right Section. |
| headerScript | String | Header format script. |
getEvenHeader(section)
Gets a script formatting the even header of an Excel file.
| Parameter | Type | Description |
|---|---|---|
| section | int | 0: Left Section, 1: Center Section, 2: Right Section. |
setEvenFooter(section, footerScript)
Sets a script formatting the even page footer of an Excel file. Only effect in Excel 2007 when IsHFDiffOddEven is true.
| Parameter | Type | Description |
|---|---|---|
| section | int | 0: Left Section, 1: Center Section, 2: Right Section. |
| footerScript | String | Footer format script. |
getEvenFooter(section)
Gets a script formatting the even footer of an Excel file.
| Parameter | Type | Description |
|---|---|---|
| section | int | 0: Left Section, 1: Center Section, 2: Right Section. |
setFirstPageHeader(section, headerScript)
Sets a script formatting the first page header of an Excel file. Only effect in Excel 2007 when IsHFDiffFirst is true.
| Parameter | Type | Description |
|---|---|---|
| section | int | 0: Left Section, 1: Center Section, 2: Right Section. |
| headerScript | String | Header format script. |
getFirstPageHeader(section)
Gets a script formatting the first page header of an Excel file.
| Parameter | Type | Description |
|---|---|---|
| section | int | 0: Left Section, 1: Center Section, 2: Right Section. |
setFirstPageFooter(section, footerScript)
Sets a script formatting the first page footer of an Excel file.
| Parameter | Type | Description |
|---|---|---|
| section | int | 0: Left Section, 1: Center Section, 2: Right Section. |
| footerScript | String | Footer format script. |
getFirstPageFooter(section)
Gets a script formatting the first page footer of an Excel file.
| Parameter | Type | Description |
|---|---|---|
| section | int | 0: Left Section, 1: Center Section, 2: Right Section. |