Renderer
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Renderer(opts?: RenderOptions): Renderer;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
opts | RenderOptions |
Returns
Section titled “Returns”Renderer
Properties
Section titled “Properties”| Property | Type |
|---|---|
allowHeaderSelections | boolean |
allowRangeSelections | boolean |
fontAdjust | number |
headers | boolean |
headerStyle | Style |
hiddenStyle | Style |
highlightColor | string |
locale | string |
sheetName | string |
showAnnotations | boolean |
showHidden | boolean |
showValuelessFormulas | boolean |
viewRef | A1Ref |
Methods
Section titled “Methods”absolutePosition()
Section titled “absolutePosition()”absolutePosition(range: Range): Rect;Converts a range to its absolute pixel position.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
range | Range | The range to convert |
Returns
Section titled “Returns”Rectangle representing the absolute position
getCellAlignment()
Section titled “getCellAlignment()”getCellAlignment(cell: Cell): HAlign;Gets the horizontal alignment for a cell.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
cell | Cell | The cell to get alignment for |
Returns
Section titled “Returns”The horizontal alignment value.
getCellAt()
Section titled “getCellAt()”getCellAt(col: number, row: number): Cell;Gets the cell at the specified coordinates.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
col | number | Column index |
row | number | Row index |
Returns
Section titled “Returns”The cell at the given coordinates or null if no cell exists.
getColumnSize()
Section titled “getColumnSize()”getColumnSize(columnIndex: number): number;Gets the width of the column at a given index (0 based).
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
columnIndex | number | A column index. |
Returns
Section titled “Returns”number
The column width in pixels.
getColumnStyle()
Section titled “getColumnStyle()”getColumnStyle(colIndex: number): Style;Gets the style for a specific column.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
colIndex | number | The column index (0-based) |
Returns
Section titled “Returns”Style
The column style or null if no style is defined
getCurrentSheet()
Section titled “getCurrentSheet()”getCurrentSheet(): WorkSheet;Gets the currently active worksheet.
Returns
Section titled “Returns”The current worksheet or null if none is set
getFullSheetRef()
Section titled “getFullSheetRef()”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).
Returns
Section titled “Returns”A reference to the full sheet.
getHeadersSize()
Section titled “getHeadersSize()”getHeadersSize(): HeaderSize;Returns the size of the grid’s column & row headers.
Returns
Section titled “Returns”getRowSize()
Section titled “getRowSize()”getRowSize(rowIndex: number): number;Gets the height of the row at a given index (0 based).
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
rowIndex | number | A row index. |
Returns
Section titled “Returns”number
The row height in pixels.
getStyles()
Section titled “getStyles()”getStyles(x: number, y: number): Style;Gets the combined styles for a cell at the given coordinates.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
x | number | Column index |
y | number | Row index |
Returns
Section titled “Returns”The cell styles or blank style object if no styles are defined
getTableStyle()
Section titled “getTableStyle()”getTableStyle(x: number, y: number): Style;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
x | number |
y | number |
Returns
Section titled “Returns”Style
getVisibleColumns()
Section titled “getVisibleColumns()”getVisibleColumns(): VisibleGridSize[];Returns a list of dimensions of the columns that are currently visible in the viewport.
Returns
Section titled “Returns”An array of visible columns.
getVisibleRows()
Section titled “getVisibleRows()”getVisibleRows(): VisibleGridSize[];Returns a list of dimensions of the rows that are currently visible in the viewport.
Returns
Section titled “Returns”An array of visible columns.
invert()
Section titled “invert()”invert(pos: Coords, scrollPos?: Rect): { cellPos: Range; gridPos: Range;};Converts pixel coordinates to cell and grid positions.
Parameters
Section titled “Parameters”| Parameter | Type | Default value | Description |
|---|---|---|---|
pos | Coords | undefined | The pixel position [x, y] |
scrollPos | Rect | null | Optional scroll position offset |
Returns
Section titled “Returns”{ cellPos: Range; gridPos: Range;}Object containing cellPos (considering merges) and gridPos (raw position)
cellPos
Section titled “cellPos”cellPos: Range;gridPos
Section titled “gridPos”gridPos: Range;rectToRanges()
Section titled “rectToRanges()”rectToRanges( anchorPx: Coords, focusPx: Coords, scrollPos?: Rect): { anchor: Range; focus: Range; selection: Range;};Converts pixel rectangle coordinates to cell ranges for selection.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
anchorPx | Coords | Starting pixel position of selection |
focusPx | Coords | Ending pixel position of selection |
scrollPos? | Rect | Optional scroll position offset |
Returns
Section titled “Returns”{ anchor: Range; focus: Range; selection: Range;}Object containing focus, anchor, and selection ranges.
anchor
Section titled “anchor”anchor: Range;focus: Range;selection
Section titled “selection”selection: Range;refToRect()
Section titled “refToRect()”refToRect(ref: A1Ref, includeHeaders?: boolean): Rect;Converts an A1 reference to a rectangle with optional header inclusion.
Parameters
Section titled “Parameters”| Parameter | Type | Default value | Description |
|---|---|---|---|
ref | A1Ref | undefined | The A1 reference to convert |
includeHeaders | boolean | true | Whether to include header dimensions in the result |
Returns
Section titled “Returns”The rectangle corresponding to the reference
render()
Section titled “render()”render( canvas: Canvaslike, scrollPos?: Rect, highlights?: Highlight[]): void;Renders the complete grid to a canvas.
Parameters
Section titled “Parameters”| Parameter | Type | Default value | Description |
|---|---|---|---|
canvas | Canvaslike | undefined | The canvas to render to |
scrollPos | Rect | null | Optional scroll position for viewport |
highlights? | Highlight[] | undefined | Optional array of highlights to render over the grid |
Returns
Section titled “Returns”void
renderHeaders()
Section titled “renderHeaders()”renderHeaders(): void;Renders the row and column headers with labels and styling.
Returns
Section titled “Returns”void
renderHighlight()
Section titled “renderHighlight()”renderHighlight(highlight: Highlight): void;Renders a highlight overlay for a selected range.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
highlight | Highlight | The highlight configuration to render |
Returns
Section titled “Returns”void
resize()
Section titled “resize()”resize(canvas: Canvaslike, rect: Rect): void;Resizes a canvas to fit the specified rectangle or view dimensions.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
canvas | Canvaslike | The canvas to resize |
rect | Rect | Optional rectangle to size the canvas to; if not provided, uses view dimensions |
Returns
Section titled “Returns”void
setColumnSize()
Section titled “setColumnSize()”setColumnSize(columnIndex: number, width: number): void;Sets a new width for the column at a given index (0 based).
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
columnIndex | number | A column index. |
width | number | The width in pixels |
Returns
Section titled “Returns”void
setOptions()
Section titled “setOptions()”setOptions(opts: RenderOptions): void;Updates the renderer configuration with new options
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
opts | RenderOptions | Rendering options to apply |
Returns
Section titled “Returns”void
setRowSize()
Section titled “setRowSize()”setRowSize(rowIndex: number, height: number): void;Sets a new height for the row at a given index (0 based).
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
rowIndex | number | A row index. |
height | number | The height in pixels. |
Returns
Section titled “Returns”void
setSheet()
Section titled “setSheet()”setSheet(sheetName: string): void;Sets the active sheet to render and updates the internal scale.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
sheetName | string | The name of the sheet to render |
Returns
Section titled “Returns”void
setWorkbook()
Section titled “setWorkbook()”setWorkbook(workbook: Workbook): void;Sets the workbook to render and updates the internal scale.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
workbook | Workbook | The workbook to render |
Returns
Section titled “Returns”void
shouldRenderGridLines()
Section titled “shouldRenderGridLines()”shouldRenderGridLines(): boolean;Determines whether grid lines should be rendered based on sheet view settings.
Returns
Section titled “Returns”boolean
True if grid lines should be rendered, false otherwise.
toRect()
Section titled “toRect()”toRect(range: Range): Rect;Converts a range to a rectangle in pixel coordinates with headers and scroll-tilt applied.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
range | Range | The range to convert |
Returns
Section titled “Returns”Rectangle representing the range position
updateScale()
Section titled “updateScale()”updateScale(): void;Updates the internal scale and view reference based on the current workbook and sheet.
Returns
Section titled “Returns”void