Skip to content
Mondrian

Renderer

new Renderer(opts?: RenderOptions): Renderer;
ParameterType
optsRenderOptions

Renderer

PropertyTypeDefault value
allowHeaderSelectionsbooleanundefined
allowRangeSelectionsbooleanundefined
fontAdjustnumberundefined
headersbooleanundefined
headerStyleStyleundefined
hiddenStyleStyleundefined
highlightColorstringundefined
localestringundefined
sheetNamestringundefined
showAnnotationsbooleantrue
showHiddenbooleanfalse
showValuelessFormulasbooleanfalse
viewRefA1Refundefined
absolutePosition(range: Range): Rect;

Converts a range to its absolute pixel position.

ParameterTypeDescription
rangeRangeThe range to convert

Rect

Rectangle representing the absolute position


getCellAlignment(cell: Cell): HAlign;

Gets the horizontal alignment for a cell.

ParameterTypeDescription
cellCellThe cell to get alignment for

HAlign

The horizontal alignment value.


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

Gets the cell at the specified coordinates.

ParameterTypeDescription
colnumberColumn index
rownumberRow 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).

ParameterTypeDescription
columnIndexnumberA column index.

number

The column width in pixels.


getColumnStyle(colIndex: number): Style | null;

Gets the style for a specific column.

ParameterTypeDescription
colIndexnumberThe 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).

ParameterType
xnumber
ynumber

Style


getRowSize(rowIndex: number): number;

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

ParameterTypeDescription
rowIndexnumberA row index.

number

The row height in pixels.


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

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

ParameterTypeDescription
xnumberColumn index
ynumberRow index

Style

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


getTableStyle(x: number, y: number): Style;
ParameterType
xnumber
ynumber

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.

ParameterTypeDefault valueDescription
posCoordsundefinedThe pixel position [x, y]
scrollPosRect | nullnullOptional 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.

ParameterTypeDescription
anchorPxCoordsStarting pixel position of selection
focusPxCoordsEnding pixel position of selection
scrollPos?RectOptional 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.

ParameterTypeDefault valueDescription
refA1RefundefinedThe A1 reference to convert
includeHeadersbooleantrueWhether 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.

ParameterTypeDefault valueDescription
canvasCanvaslikeundefinedThe canvas to render to
scrollPosRect | nullnullOptional scroll position for viewport
highlights?(Highlight | null)[]undefinedOptional array of highlights to render over the grid

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.

ParameterTypeDescription
highlightHighlightThe highlight configuration to render

void


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

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

ParameterTypeDescription
canvasCanvaslikeThe canvas to resize
rectRectOptional 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.

ParameterType
ptNamestring

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


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

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

ParameterTypeDescription
columnIndexnumberA column index.
widthnumberThe width in pixels

void


setOptions(opts: RenderOptions): void;

Updates the renderer configuration with new options

ParameterTypeDescription
optsRenderOptionsRendering options to apply

void


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

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

ParameterTypeDescription
rowIndexnumberA row index.
heightnumberThe height in pixels.

void


setSheet(sheetName: string): void;

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

ParameterTypeDescription
sheetNamestringThe name of the sheet to render

void


setWorkbook(workbook: Workbook): void;

Sets the workbook to render and updates the internal scale.

ParameterTypeDescription
workbookWorkbookThe 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.

ParameterTypeDescription
rangeRangeThe 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