public class PageSetup
extends java.lang.Object
Example
Workbook workbook = new Workbook();
WorksheetCollection sheets = workbook.getWorksheets();
//Add a worksheet
sheets.add();
Worksheet sheet = sheets.get(1);
PageSetup pageSetup = sheet.getPageSetup();
pageSetup.setPrintArea("D1:K13");
//do your business
| Modifier and Type | Method and Description |
|---|---|
void |
clearHeaderFooter()
Clears header and footer setting.
|
void |
copy(PageSetup source,
CopyOptions copyOptions)
Copies the setting of the page setup.
|
void |
customPaperSize(double width,
double height)
Sets the custom paper size, in unit of inches.
|
boolean |
getBlackAndWhite()
Represents if elements of the document will be printed in black and white.
|
double |
getBottomMargin()
Represents the size of the bottom margin, in unit of centimeters.
|
double |
getBottomMarginInch()
Represents the size of the bottom margin, in unit of inches.
|
boolean |
getCenterHorizontally()
Represent if the sheet is printed centered horizontally.
|
boolean |
getCenterVertically()
Represent if the sheet is printed centered vertically.
|
HeaderFooterCommand[] |
getCommands(java.lang.String headerFooterScript)
Gets all commands of header or footer.
|
java.lang.String |
getEvenFooter(int section)
Gets a script formatting the even footer of an Excel file.
|
java.lang.String |
getEvenHeader(int section)
Gets a script formatting the even header of an Excel file.
|
java.lang.String |
getFirstPageFooter(int section)
Gets a script formatting the first page footer of an Excel file.
|
java.lang.String |
getFirstPageHeader(int section)
Gets a script formatting the first page header of an Excel file.
|
int |
getFirstPageNumber()
Represents the first page number that will be used when this sheet is printed.
|
int |
getFitToPagesTall()
Represents the number of pages tall the worksheet will be scaled to when it's printed.
|
int |
getFitToPagesWide()
Represents the number of pages wide the worksheet will be scaled to when it's printed.
|
java.lang.String |
getFooter(int section)
Gets a script formatting the footer of an Excel file.
|
double |
getFooterMargin()
Represents the distance from the bottom of the page to the footer, in unit of centimeters.
|
double |
getFooterMarginInch()
Represents the distance from the bottom of the page to the footer, in unit of inches.
|
java.lang.String |
getHeader(int section)
Gets a script formatting the header of an Excel file.
|
double |
getHeaderMargin()
Represents the distance from the top of the page to the header, in unit of centimeters.
|
double |
getHeaderMarginInch()
Represents the distance from the top of the page to the header, in unit of inches.
|
double |
getLeftMargin()
Represents the size of the left margin, in unit of centimeters.
|
double |
getLeftMarginInch()
Represents the size of the left margin, in unit of inches.
|
OdsPageBackground |
getODSPageBackground()
Gets the background of ODS.
|
int |
getOrder()
Represents the order that Microsoft Excel uses to number pages when printing a large worksheet.
|
int |
getOrientation()
Represents page print orientation.
|
double |
getPaperHeight()
Gets the height of the paper in unit of inches , considered page orientation.
|
int |
getPaperSize()
Represents the size of the paper.
|
double |
getPaperWidth()
Gets the width of the paper in unit of inches, considered page orientation.
|
Picture |
getPicture(boolean isFirst,
boolean isEven,
boolean isHeader,
int section)
Gets the
Picture object of the header / footer. |
Picture |
getPicture(boolean isHeader,
int section)
Gets the
Picture object of the header / footer. |
java.lang.String |
getPrintArea()
Represents the range to be printed.
|
int |
getPrintComments()
Represents the way comments are printed with the sheet.
|
int |
getPrintCopies()
Gets number of copies to print.
|
boolean |
getPrintDraft()
Represents if the sheet will be printed without graphics.
|
int |
getPrintErrors()
Specifies the type of print error displayed.
|
byte[] |
getPrinterSettings()
Gets the settings of the default printer.
|
boolean |
getPrintGridlines()
Represents if cell gridlines are printed on the page.
|
boolean |
getPrintHeadings()
Represents if row and column headings are printed with this page.
|
int |
getPrintQuality()
Represents the print quality.
|
java.lang.String |
getPrintTitleColumns()
Represents the columns that contain the cells to be repeated on the left side of each page.
|
java.lang.String |
getPrintTitleRows()
Represents the rows that contain the cells to be repeated at the top of each page.
|
double |
getRightMargin()
Represents the size of the right margin, in unit of centimeters.
|
double |
getRightMarginInch()
Represents the size of the right margin, in unit of inches.
|
double |
getTopMargin()
Represents the size of the top margin, in unit of centimeters.
|
double |
getTopMarginInch()
Represents the size of the top margin, in unit of inches.
|
int |
getZoom()
Represents the scaling factor in percent.
|
boolean |
isAutoFirstPageNumber()
Indicates whether the first the page number is automatically assigned.
|
boolean |
isAutomaticPaperSize()
Indicates whether the paper size is automatic.
|
boolean |
isHFAlignMargins()
Indicates whether header and footer margins are aligned with the page margins.
|
boolean |
isHFDiffFirst()
True means that the header/footer of the first page is different with other pages.
|
boolean |
isHFDiffOddEven()
True means that the header/footer of the odd pages is different with odd pages.
|
boolean |
isHFScaleWithDoc()
Indicates whether header and footer are scaled with document scaling.
|
boolean |
isPercentScale()
If this property is False, the FitToPagesWide and FitToPagesTall properties control how the worksheet is scaled.
|
void |
setAutoFirstPageNumber(boolean value)
Indicates whether the first the page number is automatically assigned.
|
void |
setBlackAndWhite(boolean value)
Represents if elements of the document will be printed in black and white.
|
void |
setBottomMargin(double value)
Represents the size of the bottom margin, in unit of centimeters.
|
void |
setBottomMarginInch(double value)
Represents the size of the bottom margin, in unit of inches.
|
void |
setCenterHorizontally(boolean value)
Represent if the sheet is printed centered horizontally.
|
void |
setCenterVertically(boolean value)
Represent if the sheet is printed centered vertically.
|
void |
setEvenFooter(int section,
java.lang.String footerScript)
Sets a script formatting the even page footer of an Excel file.
|
void |
setEvenHeader(int section,
java.lang.String headerScript)
Sets a script formatting the even page header of an Excel file.
|
void |
setFirstPageFooter(int section,
java.lang.String footerScript)
Sets a script formatting the first page footer of an Excel file.
|
void |
setFirstPageHeader(int section,
java.lang.String headerScript)
Sets a script formatting the first page header of an Excel file.
|
void |
setFirstPageNumber(int value)
Represents the first page number that will be used when this sheet is printed.
|
void |
setFitToPages(int wide,
int tall)
Sets the number of pages the worksheet will be scaled to when it's printed.
|
void |
setFitToPagesTall(int value)
Represents the number of pages tall the worksheet will be scaled to when it's printed.
|
void |
setFitToPagesWide(int value)
Represents the number of pages wide the worksheet will be scaled to when it's printed.
|
void |
setFooter(int section,
java.lang.String footerScript)
Sets a script formatting the footer of an Excel file.
|
void |
setFooterMargin(double value)
Represents the distance from the bottom of the page to the footer, in unit of centimeters.
|
void |
setFooterMarginInch(double value)
Represents the distance from the bottom of the page to the footer, in unit of inches.
|
Picture |
setFooterPicture(int section,
byte[] footerPicture)
Sets an image in the footer of a worksheet.
|
void |
setHeader(int section,
java.lang.String headerScript)
Sets a script formatting the header of an Excel file.
|
void |
setHeaderMargin(double value)
Represents the distance from the top of the page to the header, in unit of centimeters.
|
void |
setHeaderMarginInch(double value)
Represents the distance from the top of the page to the header, in unit of inches.
|
Picture |
setHeaderPicture(int section,
byte[] headerPicture)
Sets an image in the header of a worksheet.
|
void |
setHFAlignMargins(boolean value)
Indicates whether header and footer margins are aligned with the page margins.
|
void |
setHFDiffFirst(boolean value)
True means that the header/footer of the first page is different with other pages.
|
void |
setHFDiffOddEven(boolean value)
True means that the header/footer of the odd pages is different with odd pages.
|
void |
setHFScaleWithDoc(boolean value)
Indicates whether header and footer are scaled with document scaling.
|
void |
setLeftMargin(double value)
Represents the size of the left margin, in unit of centimeters.
|
void |
setLeftMarginInch(double value)
Represents the size of the left margin, in unit of inches.
|
void |
setOrder(int value)
Represents the order that Microsoft Excel uses to number pages when printing a large worksheet.
|
void |
setOrientation(int value)
Represents page print orientation.
|
void |
setPaperSize(int value)
Represents the size of the paper.
|
void |
setPercentScale(boolean value)
If this property is False, the FitToPagesWide and FitToPagesTall properties control how the worksheet is scaled.
|
Picture |
setPicture(boolean isFirst,
boolean isEven,
boolean isHeader,
int section,
byte[] imageData)
Sets an image in the header/footer of a worksheet.
|
void |
setPrintArea(java.lang.String value)
Represents the range to be printed.
|
void |
setPrintComments(int value)
Represents the way comments are printed with the sheet.
|
void |
setPrintCopies(int value)
Sets number of copies to print.
|
void |
setPrintDraft(boolean value)
Represents if the sheet will be printed without graphics.
|
void |
setPrintErrors(int value)
Specifies the type of print error displayed.
|
void |
setPrinterSettings(byte[] value)
Sets the settings of the default printer.
|
void |
setPrintGridlines(boolean value)
Represents if cell gridlines are printed on the page.
|
void |
setPrintHeadings(boolean value)
Represents if row and column headings are printed with this page.
|
void |
setPrintQuality(int value)
Represents the print quality.
|
void |
setPrintTitleColumns(java.lang.String value)
Represents the columns that contain the cells to be repeated on the left side of each page.
|
void |
setPrintTitleRows(java.lang.String value)
Represents the rows that contain the cells to be repeated at the top of each page.
|
void |
setRightMargin(double value)
Represents the size of the right margin, in unit of centimeters.
|
void |
setRightMarginInch(double value)
Represents the size of the right margin, in unit of inches.
|
void |
setTopMargin(double value)
Represents the size of the top margin, in unit of centimeters.
|
void |
setTopMarginInch(double value)
Represents the size of the top margin, in unit of inches.
|
void |
setZoom(int value)
Represents the scaling factor in percent.
|
public OdsPageBackground getODSPageBackground()
public void copy(PageSetup source, CopyOptions copyOptions)
source - The source.copyOptions - The copy options.public java.lang.String getPrintArea()
public void setPrintArea(java.lang.String value)
public java.lang.String getPrintTitleColumns()
Example
pageSetup.setPrintTitleColumns("$A:$A");
public void setPrintTitleColumns(java.lang.String value)
public java.lang.String getPrintTitleRows()
Example
pageSetup.setPrintTitleRows("$1:$1");
public void setPrintTitleRows(java.lang.String value)
public boolean getBlackAndWhite()
public void setBlackAndWhite(boolean value)
public boolean getCenterHorizontally()
public void setCenterHorizontally(boolean value)
public boolean getCenterVertically()
public void setCenterVertically(boolean value)
public boolean getPrintDraft()
public void setPrintDraft(boolean value)
public double getFooterMargin()
public void setFooterMargin(double value)
public double getFooterMarginInch()
public void setFooterMarginInch(double value)
public double getHeaderMargin()
public void setHeaderMargin(double value)
public double getHeaderMarginInch()
public void setHeaderMarginInch(double value)
public byte[] getPrinterSettings()
public void setPrinterSettings(byte[] value)
public double getLeftMargin()
public void setLeftMargin(double value)
public double getLeftMarginInch()
public void setLeftMarginInch(double value)
public double getRightMargin()
public void setRightMargin(double value)
public double getRightMarginInch()
public void setRightMarginInch(double value)
public double getTopMargin()
public void setTopMargin(double value)
public double getTopMarginInch()
public void setTopMarginInch(double value)
public double getBottomMargin()
public void setBottomMargin(double value)
public double getBottomMarginInch()
public void setBottomMarginInch(double value)
public int getFirstPageNumber()
public void setFirstPageNumber(int value)
public void setFitToPages(int wide,
int tall)
wide - Pages wide.tall - Pages tall.public int getFitToPagesTall()
Remarks
You have to set FitToPagesWide as zero if you want to fit all rows on one page.public void setFitToPagesTall(int value)
Remarks
You have to set FitToPagesWide as zero if you want to fit all rows on one page.public int getFitToPagesWide()
Remarks
You have to set FitToPagesTall as zero if you want to fit all columns on one page.public void setFitToPagesWide(int value)
Remarks
You have to set FitToPagesTall as zero if you want to fit all columns on one page.public boolean isPercentScale()
public void setPercentScale(boolean value)
public int getOrder()
See PrintOrderType.
public void setOrder(int value)
See PrintOrderType.
public boolean isAutomaticPaperSize()
public int getPaperSize()
See PaperSizeType.
public void setPaperSize(int value)
See PaperSizeType.
public double getPaperWidth()
public double getPaperHeight()
public void customPaperSize(double width,
double height)
width - The width of the paper.height - The height of the paper.public int getOrientation()
See PageOrientationType.
public void setOrientation(int value)
See PageOrientationType.
public int getPrintComments()
See PrintCommentsType.
public void setPrintComments(int value)
See PrintCommentsType.
public int getPrintErrors()
See PrintErrorsType.
public void setPrintErrors(int value)
See PrintErrorsType.
public boolean getPrintHeadings()
public void setPrintHeadings(boolean value)
public boolean getPrintGridlines()
public void setPrintGridlines(boolean value)
public int getZoom()
public void setZoom(int value)
public boolean isAutoFirstPageNumber()
public void setAutoFirstPageNumber(boolean value)
public int getPrintQuality()
public void setPrintQuality(int value)
public int getPrintCopies()
public void setPrintCopies(int value)
public void clearHeaderFooter()
public java.lang.String getHeader(int section)
section - 0: Left Section, 1: Center Section, 2: Right Section.public HeaderFooterCommand[] getCommands(java.lang.String headerFooterScript)
headerFooterScript - The header/footer scriptpublic java.lang.String getFooter(int section)
section - 0: Left Section, 1: Center Section, 2: Right Section.public void setHeader(int section,
java.lang.String headerScript)
Remarks
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 |
| &"<FontName>" | Font name, for example: &"Arial" |
| &"<FontName>, <FontStyle>" | Font name and font style, for example: &"Arial,Bold" |
| &<FontSize> | 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<RRGGBB> | Font color, for example(RED): &KFF0000 |
| &G | Image script |
section - 0: Left Section, 1: Center Section, 2: Right Section.headerScript - Header format script.public void setFooter(int section,
java.lang.String footerScript)
Remarks
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 |
| &"<FontName>" | Font name, for example: &"Arial" |
| &"<FontName>, <FontStyle>" | Font name and font style, for example: &"Arial,Bold" |
| &<FontSize> | 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<RRGGBB> | Font color, for example(RED): &KFF0000 |
| &G | Image script |
section - 0: Left Section, 1: Center Section, 2: Right Section.footerScript - Footer format script.public void setEvenHeader(int section,
java.lang.String headerScript)
section - 0: Left Section, 1: Center Section, 2: Right Section.headerScript - Header format script.public java.lang.String getEvenHeader(int section)
section - 0: Left Section, 1: Center Section, 2: Right Section.public void setEvenFooter(int section,
java.lang.String footerScript)
section - 0: Left Section, 1: Center Section, 2: Right Section.footerScript - Footer format script.public java.lang.String getEvenFooter(int section)
section - 0: Left Section, 1: Center Section, 2: Right Section.public void setFirstPageHeader(int section,
java.lang.String headerScript)
section - 0: Left Section, 1: Center Section, 2: Right Section.headerScript - Header format script.public java.lang.String getFirstPageHeader(int section)
section - 0: Left Section, 1: Center Section, 2: Right Section.public void setFirstPageFooter(int section,
java.lang.String footerScript)
section - 0: Left Section, 1: Center Section, 2: Right Section.footerScript - Footer format script.public java.lang.String getFirstPageFooter(int section)
section - 0: Left Section, 1: Center Section, 2: Right Section.public boolean isHFDiffOddEven()
public void setHFDiffOddEven(boolean value)
public boolean isHFDiffFirst()
public void setHFDiffFirst(boolean value)
public boolean isHFScaleWithDoc()
public void setHFScaleWithDoc(boolean value)
public boolean isHFAlignMargins()
public void setHFAlignMargins(boolean value)
public Picture setHeaderPicture(int section, byte[] headerPicture)
section - 0: Left Section, 1: Center Section, 2: Right Section.headerPicture - Image data.Picture object.public Picture setFooterPicture(int section, byte[] footerPicture)
section - 0: Left Section, 1: Center Section, 2: Right Section.footerPicture - Image data.Picture object.public Picture setPicture(boolean isFirst, boolean isEven, boolean isHeader, int section, byte[] imageData)
isFirst - Indicates whether setting the picture of first page header/footer.isEven - Indicates whether setting the picture of even page header/footer.isHeader - Indicates whether setting the picture of header/footer.section - 0: Left Section, 1: Center Section, 2: Right Section.imageData - Image data.Picture object.public Picture getPicture(boolean isHeader, int section)
Picture object of the header / footer.isHeader - Indicates whether it is in the header or footer.section - 0: Left Section, 1: Center Section, 2: Right Section.Picture object.
Returns null if there is no picture.public Picture getPicture(boolean isFirst, boolean isEven, boolean isHeader, int section)
Picture object of the header / footer.isFirst - Indicates whether getting the picture of first page header/footer.isEven - Indicates whether getting the picture of even page header/footer.isHeader - Indicates whether getting the picture of header/footer.section - 0: Left Section, 1: Center Section, 2: Right Section.Picture object.See Also:
Aspose.Cells Documentation - the home page for the Aspose.Cells Product Documentation.
Aspose.Cells Support Forum - our preferred method of support.
We guarantee a prompt response to any inquiry!
© Aspose Pty Ltd 2003-2025. All Rights Reserved.