ws.print
WorksheetPrint
Sub-API for worksheet print and page break operations.
19 methods
getSettings
→ Promise<PrintSettings>getSettings(): Promise<PrintSettings>;Get the current print settings for the sheet. @returns Current print settings
setSettings
→ Promise<void>setSettings(settings: Partial<PrintSettings>): Promise<void>;| Parameter | Type | Required |
|---|---|---|
| settings | Partial<PrintSettings> | required |
Update print settings. Only the provided keys are changed. @param settings - Partial print settings to apply
getArea
→ Promise<string | null>getArea(): Promise<string | null>;Get the current print area as an A1-notation range string. @returns The print area range string, or null if no print area is set
setArea
→ Promise<void>setArea(area: string): Promise<void>;| Parameter | Type | Required |
|---|---|---|
| area | string | required |
Set the print area to the specified A1-notation range. @param area - A1-notation range string (e.g., "A1:H20")
clearArea
→ Promise<void>clearArea(): Promise<void>;Clear the print area so the entire sheet prints.
addPageBreak
→ Promise<void>addPageBreak(type: 'horizontal' | 'vertical', position: number): Promise<void>;| Parameter | Type | Required |
|---|---|---|
| type | 'horizontal' | 'vertical' | required |
| position | number | required |
Add a manual page break at the specified position. @param type - 'horizontal' (row break) or 'vertical' (column break) @param position - 0-based row or column index for the break
removePageBreak
→ Promise<void>removePageBreak(type: 'horizontal' | 'vertical', position: number): Promise<void>;| Parameter | Type | Required |
|---|---|---|
| type | 'horizontal' | 'vertical' | required |
| position | number | required |
Remove a manual page break at the specified position. @param type - 'horizontal' or 'vertical' @param position - 0-based row or column index of the break to remove
getPageBreaks
→ Promise<{ rowBreaks: Array<{ id: number; min: number; max: number; manual: boolean; pt: boolean }>; colBreaks: Array<{ id: number; min: number; max: number; manual: boolean; pt: boolean }>; }>getPageBreaks(): Promise<{
rowBreaks: Array<{ id: number; min: number; max: number; manual: boolean; pt: boolean }>;
colBreaks: Array<{ id: number; min: number; max: number; manual: boolean; pt: boolean }>;
}>;Get all manual page breaks in the sheet. @returns Object containing arrays of horizontal and vertical break positions
clearPageBreaks
→ Promise<void>clearPageBreaks(): Promise<void>;Remove all manual page breaks from the sheet.
setPrintTitleRows
→ Promise<void>setPrintTitleRows(startRow: number, endRow: number): Promise<void>;| Parameter | Type | Required |
|---|---|---|
| startRow | number | required |
| endRow | number | required |
Set the rows to repeat at the top of each printed page (print titles). @param startRow - 0-based start row index @param endRow - 0-based end row index (inclusive)
setPrintTitleColumns
→ Promise<void>setPrintTitleColumns(startCol: number, endCol: number): Promise<void>;| Parameter | Type | Required |
|---|---|---|
| startCol | number | required |
| endCol | number | required |
Set the columns to repeat at the left of each printed page (print titles). @param startCol - 0-based start column index @param endCol - 0-based end column index (inclusive)
getPrintTitleRows
→ Promise<[number, number] | null>getPrintTitleRows(): Promise<[number, number] | null>;Get the rows configured to repeat at the top of each printed page. @returns A [startRow, endRow] tuple (0-based, inclusive), or null if no repeat rows are set
getPrintTitleColumns
→ Promise<[number, number] | null>getPrintTitleColumns(): Promise<[number, number] | null>;Get the columns configured to repeat at the left of each printed page. @returns A [startCol, endCol] tuple (0-based, inclusive), or null if no repeat columns are set
clearPrintTitles
→ Promise<void>clearPrintTitles(): Promise<void>;Clear all print titles (both repeat rows and repeat columns). Other print settings (margins, orientation, etc.) are preserved.
setPrintMargins
→ Promise<void>setPrintMargins(
unit: 'inches' | 'points' | 'centimeters',
options: Partial<PageMargins>,
): Promise<void>;| Parameter | Type | Required |
|---|---|---|
| unit | 'inches' | 'points' | 'centimeters' | required |
| options | Partial<PageMargins> | required |
Set page margins with unit conversion. Values are converted to inches (OOXML native unit) before storing. Only provided margin fields are updated; others are preserved. @param unit - Unit of the provided values: 'inches', 'points', or 'centimeters' @param options - Partial margin values to set
getCellAfterBreak
→ { row: number; col: number }getCellAfterBreak(
type: 'horizontal' | 'vertical',
position: number,
): { row: number; col: number };| Parameter | Type | Required |
|---|---|---|
| type | 'horizontal' | 'vertical' | required |
| position | number | required |
Get the cell position immediately after a page break. @param type - Break type: 'horizontal' (row break) or 'vertical' (column break) @param position - 0-based row or column index of the break @returns Cell coordinates of the first cell after the break