PageSetup

PageSetup class

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

Properties

NameTypeDescription
ODSPageBackgroundOdsPageBackgroundGets the background of ODS.
PrintAreaStringRepresents the range to be printed.
PrintTitleColumnsStringRepresents the columns that contain the cells to be repeated on the left side of each page.
PrintTitleRowsStringRepresents the rows that contain the cells to be repeated at the top of each page.
BlackAndWhitebooleanRepresents if elements of the document will be printed in black and white.
CenterHorizontallybooleanRepresent if the sheet is printed centered horizontally.
CenterVerticallybooleanRepresent if the sheet is printed centered vertically.
PrintDraftbooleanRepresents if the sheet will be printed without graphics.
FooterMarginfloatRepresents the distance from the bottom of the page to the footer, in unit of centimeters.
FooterMarginInchfloatRepresents the distance from the bottom of the page to the footer, in unit of inches.
HeaderMarginfloatRepresents the distance from the top of the page to the header, in unit of centimeters.
HeaderMarginInchfloatRepresents the distance from the top of the page to the header, in unit of inches.
PrinterSettingsbyte[]Gets and sets the settings of the default printer.
LeftMarginfloatRepresents the size of the left margin, in unit of centimeters.
LeftMarginInchfloatRepresents the size of the left margin, in unit of inches.
RightMarginfloatRepresents the size of the right margin, in unit of centimeters.
RightMarginInchfloatRepresents the size of the right margin, in unit of inches.
TopMarginfloatRepresents the size of the top margin, in unit of centimeters.
TopMarginInchfloatRepresents the size of the top margin, in unit of inches.
BottomMarginfloatRepresents the size of the bottom margin, in unit of centimeters.
BottomMarginInchfloatRepresents the size of the bottom margin, in unit of inches.
FirstPageNumberintRepresents the first page number that will be used when this sheet is printed.
FitToPagesTallintRepresents the number of pages tall the worksheet will be scaled to when it’s printed. The default value is 1. You have
FitToPagesWideintRepresents the number of pages wide the worksheet will be scaled to when it’s printed. The default value is 1. You have
IsPercentScalebooleanIf this property is False, the FitToPagesWide and FitToPagesTall properties control how the worksheet is scaled.
OrderintRepresents the order that Microsoft Excel uses to number pages when printing a large worksheet. The value of the propert
IsAutomaticPaperSizebooleanIndicates whether the paper size is automatic.
PaperSizeintRepresents the size of the paper. The value of the property is PaperSizeType integer constant.
PaperWidthfloatGets the width of the paper in unit of inches, considered page orientation.
PaperHeightfloatGets the height of the paper in unit of inches , considered page orientation.
OrientationintRepresents page print orientation. The value of the property is PageOrientationType integer constant.
PrintCommentsintRepresents the way comments are printed with the sheet. The value of the property is PrintCommentsType integer constant.
PrintErrorsintSpecifies the type of print error displayed. The value of the property is PrintErrorsType integer constant.
PrintHeadingsbooleanRepresents if row and column headings are printed with this page.
PrintGridlinesbooleanRepresents if cell gridlines are printed on the page.
ZoomintRepresents the scaling factor in percent. It should be between 10 and 400.
IsAutoFirstPageNumberbooleanIndicates whether the first the page number is automatically assigned.
PrintQualityintRepresents the print quality.
PrintCopiesintGet and sets number of copies to print.
IsHFDiffOddEvenbooleanTrue means that the header/footer of the odd pages is different with odd pages.
IsHFDiffFirstbooleanTrue means that the header/footer of the first page is different with other pages.
IsHFScaleWithDocbooleanIndicates whether header and footer are scaled with document scaling. Only applies for Excel 2007.
IsHFAlignMarginsbooleanIndicates whether header and footer margins are aligned with the page margins. If this property is true, the left header

Methods

NameDescription
setHeaderPictureSets an image in the header of a worksheet.
setFooterPictureSets an image in the footer of a worksheet.
setPictureSets an image in the header/footer of a worksheet.
getPictureGets the Picture object of the header / footer.
copyCopies the setting of the page setup.
setFitToPagesSets the number of pages the worksheet will be scaled to when it’s printed.
customPaperSizeSets the custom paper size, in unit of inches.
clearHeaderFooterClears header and footer setting.
getHeaderGets a script formatting the header of an Excel file.
getCommandsGets all commands of header or footer.
getFooterGets a script formatting the footer of an Excel file.
setHeaderSets 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.

ParameterTypeDescription
sectionint0: Left Section, 1: Center Section, 2: Right Section.
headerPicturebyte[]Image data.

Returns: Returns Picture object.

setFooterPicture(section, footerPicture)

Sets an image in the footer of a worksheet.

ParameterTypeDescription
sectionint0: Left Section, 1: Center Section, 2: Right Section.
footerPicturebyte[]Image data.

Returns: Returns Picture object.

setPicture(isFirst, isEven, isHeader, section, imageData)

Sets an image in the header/footer of a worksheet.

ParameterTypeDescription
isFirstbooleanIndicates whether setting the picture of first page header/footer.
isEvenbooleanIndicates whether setting the picture of even page header/footer.
isHeaderbooleanIndicates whether setting the picture of header/footer.
sectionint0: Left Section, 1: Center Section, 2: Right Section.
imageDatabyte[]Image data.

Returns: Returns Picture object.

getPicture(isHeader, section) (1 of 2)

Gets the Picture object of the header / footer.

ParameterTypeDescription
isHeaderbooleanIndicates whether it is in the header or footer.
sectionint0: 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.

ParameterTypeDescription
isFirstbooleanIndicates whether getting the picture of first page header/footer.
isEvenbooleanIndicates whether getting the picture of even page header/footer.
isHeaderbooleanIndicates whether getting the picture of header/footer.
sectionint0: Left Section, 1: Center Section, 2: Right Section.

Returns: Returns Picture object.

copy(source, copyOptions)

Copies the setting of the page setup.

ParameterTypeDescription
sourcePageSetupThe source.
copyOptionsCopyOptionsThe copy options.

setFitToPages(wide, tall)

Sets the number of pages the worksheet will be scaled to when it’s printed.

ParameterTypeDescription
wideintPages wide.
tallintPages tall.

customPaperSize(width, height)

Sets the custom paper size, in unit of inches.

ParameterTypeDescription
widthfloatThe width of the paper.
heightfloatThe height of the paper.

clearHeaderFooter()

Clears header and footer setting.

getHeader(section)

Gets a script formatting the header of an Excel file.

ParameterTypeDescription
sectionint0: Left Section, 1: Center Section, 2: Right Section.

getCommands(headerFooterScript)

Gets all commands of header or footer.

ParameterTypeDescription
headerFooterScriptStringThe header/footer script

Returns: Returns all commands of header or footer.

getFooter(section)

Gets a script formatting the footer of an Excel file.

ParameterTypeDescription
sectionint0: 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 &"" Font name, for example: &“Arial” &", " Font name and font style, for example: &“Arial,Bold” & Font size. If this command is followed by a plain number to be printed in the header, it will be separated from the font height with a space character. &K Font color, for example(RED): &KFF0000 &G Image script For example: “&Arial,Bold&8Header Note”

ParameterTypeDescription
sectionint0: Left Section, 1: Center Section, 2: Right Section.
headerScriptStringHeader 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 &"" Font name, for example: &“Arial” &", " Font name and font style, for example: &“Arial,Bold” & Font size. If this command is followed by a plain number to be printed in the header, it will be separated from the font height with a space character. &K Font color, for example(RED): &KFF0000 &G Image script For example: “&Arial,Bold&8Footer Note”

ParameterTypeDescription
sectionint0: Left Section, 1: Center Section, 2: Right Section.
footerScriptStringFooter 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.

ParameterTypeDescription
sectionint0: Left Section, 1: Center Section, 2: Right Section.
headerScriptStringHeader format script.

getEvenHeader(section)

Gets a script formatting the even header of an Excel file.

ParameterTypeDescription
sectionint0: 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.

ParameterTypeDescription
sectionint0: Left Section, 1: Center Section, 2: Right Section.
footerScriptStringFooter format script.

getEvenFooter(section)

Gets a script formatting the even footer of an Excel file.

ParameterTypeDescription
sectionint0: 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.

ParameterTypeDescription
sectionint0: Left Section, 1: Center Section, 2: Right Section.
headerScriptStringHeader format script.

getFirstPageHeader(section)

Gets a script formatting the first page header of an Excel file.

ParameterTypeDescription
sectionint0: Left Section, 1: Center Section, 2: Right Section.

setFirstPageFooter(section, footerScript)

Sets a script formatting the first page footer of an Excel file.

ParameterTypeDescription
sectionint0: Left Section, 1: Center Section, 2: Right Section.
footerScriptStringFooter format script.

getFirstPageFooter(section)

Gets a script formatting the first page footer of an Excel file.

ParameterTypeDescription
sectionint0: Left Section, 1: Center Section, 2: Right Section.