api/book Functions
Functions exported from src/api/book.ts
addCellComment
function addCellComment(cell: CellObject, text: string, author?: string): voidParameters
| Name | Type | Description |
|---|---|---|
| cell | CellObject | The cell object to modify |
| text | string | The comment text content |
| author (optional) | string | Optional author name (defaults to "SheetJS") |
appendSheet
function appendSheet(wb: WorkBook, ws: WorkSheet, name?: string, roll?: boolean): stringParameters
| Name | Type | Description |
|---|---|---|
| wb | WorkBook | The workbook to add the sheet to |
| ws | WorkSheet | The worksheet to append |
| name (optional) | string | Optional sheet name; auto-generated if omitted |
| roll (optional) | boolean | If true, auto-increment the name suffix on collision instead of throwing |
Returns
string
The final sheet name that was used
createSheet
function createSheet(opts?: { dense?: boolean }): WorkSheetParameters
| Name | Type | Description |
|---|---|---|
| opts (optional) | { dense?: boolean } | Optional settings; set dense: true for dense storage mode (array-of-arrays backing) |
Returns
WorkSheet
A new empty worksheet object
createWorkbook
function createWorkbook(ws?: WorkSheet, wsname?: string): WorkBookParameters
| Name | Type | Description |
|---|---|---|
| ws (optional) | WorkSheet | Optional worksheet to include as the first sheet |
| wsname (optional) | string | Name for the initial sheet (defaults to "Sheet1") |
Returns
WorkBook
A new workbook object
getSheetIndex
function getSheetIndex(wb: WorkBook, sh: string | number): numberParameters
| Name | Type | Description |
|---|---|---|
| wb | WorkBook | The workbook to search |
| sh | `string | number` |
Returns
number
The zero-based sheet index
setArrayFormula
function setArrayFormula(ws: WorkSheet, range: string | { s: { r: number; c: number }; e: { r: number; c: number } }, formula: string, dynamic?: boolean): WorkSheetParameters
| Name | Type | Description |
|---|---|---|
| ws | WorkSheet | The worksheet to modify |
| range | `string | { s: { r: number; c: number }; e: { r: number; c: number } }` |
| formula | string | The array formula expression (without surrounding braces) |
| dynamic (optional) | boolean | If true, mark as a dynamic array formula (spill) |
Returns
WorkSheet
The modified worksheet
setCellHyperlink
function setCellHyperlink(cell: CellObject, target?: string, tooltip?: string): CellObjectParameters
| Name | Type | Description |
|---|---|---|
| cell | CellObject | The cell object to modify |
| target (optional) | string | The hyperlink URL or path; falsy to remove |
| tooltip (optional) | string | Optional tooltip text shown on hover |
Returns
CellObject
The same cell object, for chaining
setCellInternalLink
function setCellInternalLink(cell: CellObject, range: string, tooltip?: string): CellObjectParameters
| Name | Type | Description |
|---|---|---|
| cell | CellObject | The cell object to modify |
| range | string | The target cell reference or range string (e.g. |
| tooltip (optional) | string | Optional tooltip text shown on hover |
Returns
CellObject
The same cell object, for chaining
setCellNumberFormat
function setCellNumberFormat(cell: CellObject, fmt: string | number): CellObjectParameters
| Name | Type | Description |
|---|---|---|
| cell | CellObject | The cell object to modify |
| fmt | `string | number` |
Returns
CellObject
The same cell object, for chaining
setSheetVisibility
function setSheetVisibility(wb: WorkBook, sh: string | number, vis: 0 | 1 | 2): voidParameters
| Name | Type | Description |
|---|---|---|
| wb | WorkBook | The workbook containing the sheet |
| sh | `string | number` |
| vis | `0 | 1 |
sheetToFormulae
function sheetToFormulae(ws: WorkSheet): string[]Parameters
| Name | Type | Description |
|---|---|---|
| ws | WorkSheet | The worksheet to extract formulas from |
Returns
string[]
An array of "ref=value" strings representing every non-empty cell