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 | 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 |
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 | null;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”Cell | null
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 | null;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 | null
The column style or null if no style is defined
getCurrentSheet()
Section titled “getCurrentSheet()”getCurrentSheet(): WorkSheet | null;Gets the currently active worksheet.
Returns
Section titled “Returns”WorkSheet | null
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”getPivotTableStyle()
Section titled “getPivotTableStyle()”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).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
x | number |
y | number |
Returns
Section titled “Returns”Style
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 | null): { 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 | 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;} | null;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;
}
| null
Object containing focus, anchor, and selection ranges.
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 | null, highlights?: (Highlight | null)[]): 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 | null | Optional scroll position for viewport |
highlights? | (Highlight | null)[] | 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
resolvedPivotStyle()
Section titled “resolvedPivotStyle()”resolvedPivotStyle(ptName: string): | Partial<Record<PresetPivotStyleRegion, ResolvedRegionStyle>> | null;Resolve (and cache) a pivot’s declared style against the workbook theme.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
ptName | string |
Returns
Section titled “Returns”| Partial<Record<PresetPivotStyleRegion, ResolvedRegionStyle>>
| null
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