Skip to content
Mondrian

Renderer

new Renderer(opts?: RenderOptions): Renderer;
Parameter Type
opts RenderOptions

Renderer

Property Type Default value
allowHeaderSelections boolean undefined
allowRangeSelections boolean undefined
fontAdjust number undefined
headers boolean undefined
headerStyle Style undefined
hiddenStyle Style undefined
highlightColor string undefined
locale string undefined
sheetName string undefined
showAnnotations boolean true
showHidden boolean false
showValuelessFormulas boolean false
viewRef A1Ref undefined
absolutePosition(range: Range): Rect;

Converts a range to its absolute pixel position.

Parameter Type Description
range Range The range to convert

Rect

Rectangle representing the absolute position


getCellAlignment(cell: Cell): HAlign;

Gets the horizontal alignment for a cell.

Parameter Type Description
cell Cell The cell to get alignment for

HAlign

The horizontal alignment value.


getCellAt(col: number, row: number): Cell | null;

Gets the cell at the specified coordinates.

Parameter Type Description
col number Column index
row number Row index

Cell | null

The cell at the given coordinates or null if no cell exists.


getColumnSize(columnIndex: number): number;

Gets the width of the column at a given index (0 based).

Parameter Type Description
columnIndex number A column index.

number

The column width in pixels.


getColumnStyle(colIndex: number): Style | null;

Gets the style for a specific column.

Parameter Type Description
colIndex number The column index (0-based)

Style | null

The column style or null if no style is defined


getCurrentSheet(): WorkSheet | null;

Gets the currently active worksheet.

WorkSheet | null

The current worksheet or null if none is set


getFullSheetRef(): A1Ref;

Returns a reference to a rectangle where the bottom/right corner is the the maximum data size of the current sheet but the top/left corner set to A1 (0, 0).

A1Ref

A reference to the full sheet.


getHeadersSize(): HeaderSize;

Returns the size of the grid’s column & row headers.

HeaderSize


getPivotTableStyle(x: number, y: number): Style;

The visual style a pivot’s declared table style paints on the cell at (x, y), by the cell’s role in the pivot. The cell itself carries no visual style (apiary leaves pivot cells bare, matching Excel); this is where the appearance is resolved. Returns structured-colour JSF styles — getStyles colour-converts them like any other.

Region geometry (Excel-verified — see the apiary excel-test/pivot-role-cell-styles/ and pivot-style-flags-stripes/ findings): wholeTable underlays every cell; column stripes, then row stripes, then the first-column emphasis layer over it on the body rows; the header and grand-total bands sit on top on their rows, as do the subheading and subtotal bands on rows the pivot declares as such (rowRoles). A declared subheading/subtotal column (colRoles) then paints its full-height vertical band on top of all of that. Stripe phase counts from the first body row / first data column; subtotal and subheading rows count as ordinary body rows for the phase.

The subheading/subtotal dxf is picked by nesting level (see tieredRegion): the outermost subtotal/subheading uses first*, the next level in second*, and so on (Excel-verified — see the depth-trigger note on tieredRegion).

Parameter Type
x number
y number

Style


getRowSize(rowIndex: number): number;

Gets the height of the row at a given index (0 based).

Parameter Type Description
rowIndex number A row index.

number

The row height in pixels.


getRowStyle(rowIndex: number): Style | null;

Gets the style for a specific row.

Parameter Type Description
rowIndex number The row index (0-based)

Style | null

The row style or null if no style is defined


getStyles(x: number, y: number): Style;

Gets the combined styles for a cell at the given coordinates.

Parameter Type Description
x number Column index
y number Row index

Style

The cell styles or blank style object if no styles are defined


getTableStyle(x: number, y: number): Style;
Parameter Type
x number
y number

Style


getVisibleColumns(): VisibleGridSize[];

Returns a list of dimensions of the columns that are currently visible in the viewport.

VisibleGridSize[]

An array of visible columns.


getVisibleRows(): VisibleGridSize[];

Returns a list of dimensions of the rows that are currently visible in the viewport.

VisibleGridSize[]

An array of visible columns.


invert(pos: Coords, scrollPos?: Rect | null): {
cellPos: Range;
gridPos: Range;
};

Converts pixel coordinates to cell and grid positions.

Parameter Type Default value Description
pos Coords undefined The pixel position [x, y]
scrollPos Rect | null null Optional scroll position offset
{
cellPos: Range;
gridPos: Range;
}

Object containing cellPos (considering merges) and gridPos (raw position)

cellPos: Range;
gridPos: Range;

rectToRanges(
anchorPx: Coords,
focusPx: Coords,
scrollPos?: Rect):
| {
anchor: Range;
focus: Range;
selection: Range;
}
| null;

Converts pixel rectangle coordinates to cell ranges for selection.

Parameter Type Description
anchorPx Coords Starting pixel position of selection
focusPx Coords Ending pixel position of selection
scrollPos? Rect Optional scroll position offset

| { anchor: Range; focus: Range; selection: Range; } | null

Object containing focus, anchor, and selection ranges.


refToRect(ref: A1Ref, includeHeaders?: boolean): Rect;

Converts an A1 reference to a rectangle with optional header inclusion.

Parameter Type Default value Description
ref A1Ref undefined The A1 reference to convert
includeHeaders boolean true Whether to include header dimensions in the result

Rect

The rectangle corresponding to the reference


render(
canvas: Canvaslike,
scrollPos?: Rect | null,
highlights?: (Highlight | null)[]): void;

Renders the complete grid to a canvas.

Parameter Type Default value Description
canvas Canvaslike undefined The canvas to render to
scrollPos Rect | null null Optional scroll position for viewport
highlights? (Highlight | null)[] undefined Optional array of highlights to render over the grid

void


renderDrawings(drawings?: Drawing[]): void;
Parameter Type
drawings? Drawing[]

void


renderGraphic(graphic: Graphic, rect: Rect): void;
Parameter Type
graphic Graphic
rect Rect

void


renderHeaders(): void;

Renders the row and column headers with labels and styling.

void


renderHighlight(highlight: Highlight): void;

Renders a highlight overlay for a selected range.

Parameter Type Description
highlight Highlight The highlight configuration to render

void


resize(canvas: Canvaslike, rect: Rect): void;

Resizes a canvas to fit the specified rectangle or view dimensions.

Parameter Type Description
canvas Canvaslike The canvas to resize
rect Rect Optional rectangle to size the canvas to; if not provided, uses view dimensions

void


resolvedPivotStyle(ptName: string):
| Partial<Record<PresetPivotStyleRegion, ResolvedRegionStyle>>
| null;

Resolve (and cache) a pivot’s declared style against the workbook theme.

Parameter Type
ptName string

| Partial<Record<PresetPivotStyleRegion, ResolvedRegionStyle>> | null


setColumnSize(columnIndex: number, width: number): void;

Sets a new width for the column at a given index (0 based).

Parameter Type Description
columnIndex number A column index.
width number The width in pixels

void


setOptions(opts: RenderOptions): void;

Updates the renderer configuration with new options

Parameter Type Description
opts RenderOptions Rendering options to apply

void


setRowSize(rowIndex: number, height: number): void;

Sets a new height for the row at a given index (0 based).

Parameter Type Description
rowIndex number A row index.
height number The height in pixels.

void


setSheet(sheetName: string): void;

Sets the active sheet to render and updates the internal scale.

Parameter Type Description
sheetName string The name of the sheet to render

void


setWorkbook(workbook: Workbook): void;

Sets the workbook to render and updates the internal scale.

Parameter Type Description
workbook Workbook The workbook to render

void


shouldRenderGridLines(): boolean;

Determines whether grid lines should be rendered based on sheet view settings.

boolean

True if grid lines should be rendered, false otherwise.


toRect(range: Range): Rect;

Converts a range to a rectangle in pixel coordinates with headers and scroll-tilt applied.

Parameter Type Description
range Range The range to convert

Rect

Rectangle representing the range position


updateScale(): void;

Updates the internal scale and view reference based on the current workbook and sheet.

void