Skip to content
Mog is in active development. The GitHub repo, SDK packages, and community channels are not yet available. Follow for launch updates

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>;
ParameterTypeRequired
settingsPartial<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>;
ParameterTypeRequired
areastringrequired

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>;
ParameterTypeRequired
type'horizontal' | 'vertical'required
positionnumberrequired

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>;
ParameterTypeRequired
type'horizontal' | 'vertical'required
positionnumberrequired

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>;
ParameterTypeRequired
startRownumberrequired
endRownumberrequired

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>;
ParameterTypeRequired
startColnumberrequired
endColnumberrequired

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>;
ParameterTypeRequired
unit'inches' | 'points' | 'centimeters'required
optionsPartial<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 };
ParameterTypeRequired
type'horizontal' | 'vertical'required
positionnumberrequired

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

getHeaderFooterImages

Promise<HeaderFooterImageInfo[]>
getHeaderFooterImages(): Promise<HeaderFooterImageInfo[]>;

Get all header/footer images for this sheet. @returns Array of image info objects, one per occupied position

setHeaderFooterImage

Promise<void>
setHeaderFooterImage(info: HeaderFooterImageInfo): Promise<void>;
ParameterTypeRequired
infoHeaderFooterImageInforequired

Set or replace a header/footer image at the specified position. The engine automatically manages the `&G` format code in the corresponding header/footer string. @param info - Image info including position, src (data-URL or path), and dimensions

removeHeaderFooterImage

Promise<void>
removeHeaderFooterImage(position: HfImagePosition): Promise<void>;
ParameterTypeRequired
positionHfImagePositionrequired

Remove the header/footer image at the specified position. The engine automatically removes the `&G` format code from the corresponding header/footer string. @param position - Which of the 6 header/footer positions to clear