Package io.github.dornol.excelkit.excel
Class ExcelPrintSetup
java.lang.Object
io.github.dornol.excelkit.excel.ExcelPrintSetup
Configures page layout settings for printing Excel sheets.
Supports orientation, paper size, margins, headers/footers, repeat rows,
and fit-to-page scaling. Use with ExcelWriter.printSetup(java.util.function.Consumer)
or ExcelSheetWriter.printSetup(java.util.function.Consumer).
Header/Footer special codes
&P— current page number&N— total number of pages&D— current date&T— current time&F— file name
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumPage orientation for printing.static enumStandard paper sizes for printing. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbottomMargin(double inches) Sets the bottom margin.fitToPage(int width, int height) Enables fit-to-page scaling with the specified width and height in pages.Fits the sheet to one page wide with automatic height.footerCenter(String text) Sets the center section of the page footer.footerLeft(String text) Sets the left section of the page footer.footerRight(String text) Sets the right section of the page footer.headerCenter(String text) Sets the center section of the page header.headerLeft(String text) Sets the left section of the page header.headerRight(String text) Sets the right section of the page header.leftMargin(double inches) Sets the left margin.margins(double left, double right, double top, double bottom) Sets all four page margins at once.orientation(ExcelPrintSetup.Orientation orientation) Sets the page orientation.paperSize(ExcelPrintSetup.PaperSize paperSize) Sets the paper size.Repeats header rows (from row 0 through the column header row) on every printed page.repeatRows(int firstRow, int lastRow) Repeats specific rows on every printed page.rightMargin(double inches) Sets the right margin.topMargin(double inches) Sets the top margin.
-
Constructor Details
-
ExcelPrintSetup
public ExcelPrintSetup()Creates a new print setup configuration with defaults.
-
-
Method Details
-
orientation
Sets the page orientation.- Parameters:
orientation- the page orientation- Returns:
- this instance for chaining
-
paperSize
Sets the paper size.- Parameters:
paperSize- the paper size- Returns:
- this instance for chaining
-
margins
Sets all four page margins at once.- Parameters:
left- left margin in inchesright- right margin in inchestop- top margin in inchesbottom- bottom margin in inches- Returns:
- this instance for chaining
-
leftMargin
Sets the left margin.- Parameters:
inches- margin in inches- Returns:
- this instance for chaining
-
rightMargin
Sets the right margin.- Parameters:
inches- margin in inches- Returns:
- this instance for chaining
-
topMargin
Sets the top margin.- Parameters:
inches- margin in inches- Returns:
- this instance for chaining
-
bottomMargin
Sets the bottom margin.- Parameters:
inches- margin in inches- Returns:
- this instance for chaining
-
headerLeft
Sets the left section of the page header.Supports special codes:
&P(page number),&N(total pages),&D(date),&T(time),&F(filename).- Parameters:
text- header text- Returns:
- this instance for chaining
-
headerCenter
Sets the center section of the page header.- Parameters:
text- header text- Returns:
- this instance for chaining
- See Also:
-
headerRight
Sets the right section of the page header.- Parameters:
text- header text- Returns:
- this instance for chaining
- See Also:
-
repeatHeaderRows
Repeats header rows (from row 0 through the column header row) on every printed page.This includes any rows added by
beforeHeaderand group header rows.- Returns:
- this instance for chaining
-
repeatRows
Repeats specific rows on every printed page.- Parameters:
firstRow- first row to repeat (0-based)lastRow- last row to repeat (0-based, inclusive)- Returns:
- this instance for chaining
-
fitToPage
Enables fit-to-page scaling with the specified width and height in pages.Use
height = 0for automatic height scaling.- Parameters:
width- number of pages wideheight- number of pages tall (0 for auto)- Returns:
- this instance for chaining
-
fitToPageWidth
Fits the sheet to one page wide with automatic height.- Returns:
- this instance for chaining
-