Skip to content

Renderer

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

Renderer

PropertyType
allowHeaderSelectionsboolean
allowRangeSelectionsboolean
fontAdjustnumber
headersboolean
headerStyleStyle
hiddenStyleStyle
highlightColorstring
localestring
sheetNamestring
showAnnotationsboolean
showHiddenboolean
showValuelessFormulasboolean
viewRefA1Ref
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;

Gets the cell at the specified coordinates.

ParameterTypeDescription
colnumberColumn index
rownumberRow index

Cell

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;

Gets the style for a specific column.

ParameterTypeDescription
colIndexnumberThe column index (0-based)

Style

The column style or null if no style is defined


getCurrentSheet(): WorkSheet;

Gets the currently active worksheet.

WorkSheet

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


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): {
cellPos: Range;
gridPos: Range;
};

Converts pixel coordinates to cell and grid positions.

ParameterTypeDefault valueDescription
posCoordsundefinedThe pixel position [x, y]
scrollPosRectnullOptional 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;
};

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;
}

Object containing focus, anchor, and selection ranges.

anchor: Range;
focus: Range;
selection: Range;

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,
highlights?: Highlight[]): void;

Renders the complete grid to a canvas.

ParameterTypeDefault valueDescription
canvasCanvaslikeundefinedThe canvas to render to
scrollPosRectnullOptional scroll position for viewport
highlights?Highlight[]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


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