Workbook
Individual workbook within a model. Contains Sheets which contain Cells. Contains its own dependency graph, for now at least, so no dependencies between workbooks.
Extends
Section titled “Extends”emitter
Implements
Section titled “Implements”Properties
Section titled “Properties”charts
Section titled “charts”charts: ChartCSF[];cloud_connection
Section titled “cloud_connection”cloud_connection: CloudConnection | null;comments
Section titled “comments”readonly comments: CommentsManager;Workbook-level comment operations. See CommentsManager.
defect
Section titled “defect”defect: string | null;externals
Section titled “externals”externals: External[];id: string;isExternal
Section titled “isExternal”isExternal: boolean;Whether this workbook was loaded as an external reference from another workbook.
metadata
Section titled “metadata”metadata: GridMetadata;mode: WorkbookMode;Implementation of
Section titled “Implementation of”name: string;readonly notes: NotesManager;Workbook-level note operations. See NotesManager.
people
Section titled “people”people: Person[] = [];Authors of cell comments, or people mentioned in a cell comment.
ready: boolean = false;replacedBy
Section titled “replacedBy”replacedBy: string | null = null;reserved for outside use (client loader)
styles
Section titled “styles”readonly styles: StyleManager;tables
Section titled “tables”readonly tables: TableManager;Table collection operations. See TableManager.
readonly theme: ThemeManager;Get and set workbook theme properties.
type: | "unknown" | "airtable" | "notion" | "smartsheet" | "csv" | "excel" | "form-submissions" | "google-sheets" | "native";The origin of the workbook (Excel, Google Sheets, CSV, etc).
update_time
Section titled “update_time”update_time: string | undefined;version
Section titled “version”version: number | undefined;readonly views: ViewManager;Workbook-level view operations.
Accessors
Section titled “Accessors”Get Signature
Section titled “Get Signature”get env(): Map<"isPrint" | "isMobile" | "username", MaybeBoxedFormulaArgument>;Returns
Section titled “Returns”Map<"isPrint" | "isMobile" | "username", MaybeBoxedFormulaArgument>
Implementation of
Section titled “Implementation of”errorLevel
Section titled “errorLevel”Get Signature
Section titled “Get Signature”get errorLevel(): number;Returns
Section titled “Returns”number
errors
Section titled “errors”Get Signature
Section titled “Get Signature”get errors(): ModelError[];Returns
Section titled “Returns”Methods
Section titled “Methods”_applyWrite()
Section titled “_applyWrite()”_applyWrite( refStr, value, oldSheetCount, oldSheetIndex): void;Write value value to the given reference, or to the same address in
the sheet with index oldSheetIndex if sheet count matches oldSheetCount
Parameters
Section titled “Parameters”refStr
Section titled “refStr”string
oldSheetCount
Section titled “oldSheetCount”number
oldSheetIndex
Section titled “oldSheetIndex”number | null
Returns
Section titled “Returns”void
_getExistingCachedFormulaCell()
Section titled “_getExistingCachedFormulaCell()”_getExistingCachedFormulaCell(formula, prefix?): object;Parameters
Section titled “Parameters”formula
Section titled “formula”string
prefix?
Section titled “prefix?”string = CACHED_FORMULA_CELL_ID_PREFIX
Returns
Section titled “Returns”object
cell: DefinedName | null;id: string;_markCellsReferencingRemovedSheetForRecalculation()
Section titled “_markCellsReferencingRemovedSheetForRecalculation()”_markCellsReferencingRemovedSheetForRecalculation(sheetBeingRemoved): void;Parameters
Section titled “Parameters”sheetBeingRemoved
Section titled “sheetBeingRemoved”Returns
Section titled “Returns”void
_rewriteFormulasReferencingRenamedSheet()
Section titled “_rewriteFormulasReferencingRenamedSheet()”_rewriteFormulasReferencingRenamedSheet( sheet, currentName, newName): void;Precondition: formula parser has finished importing (formulaParserReady has resolved).
Parameters
Section titled “Parameters”currentName
Section titled “currentName”string
newName
Section titled “newName”string
Returns
Section titled “Returns”void
_writesIter()
Section titled “_writesIter()”_writesIter(): IterableIterator<[string, CellValue, KnownVertexId]>;Precondition: Workbook must be initialized
Returns
Section titled “Returns”IterableIterator<[string, CellValue, KnownVertexId]>
addSheet()
Section titled “addSheet()”addSheet(sheetName?, index?): WorkSheet;Add a new empty sheet to the workbook
Parameters
Section titled “Parameters”sheetName?
Section titled “sheetName?”string | null
if no sheet name is provided a unique sheet name will be generated
index?
Section titled “index?”number
if no index is provided the sheet will be appended to the list of sheets
Returns
Section titled “Returns”clearCachedFormulasExcept()
Section titled “clearCachedFormulasExcept()”clearCachedFormulasExcept(formulas): void;Parameters
Section titled “Parameters”formulas
Section titled “formulas”string[]
Returns
Section titled “Returns”void
clearCells()
Section titled “clearCells()”clearCells(ref): boolean;Precondition: Workbook must be initialized
Parameters
Section titled “Parameters”string | Reference
A reference to the cell, or range of cells, to clear. Defined names are not supported.
Returns
Section titled “Returns”boolean
true if any changes were made (so a recalculation is in order).
columnWidth()
Section titled “columnWidth()”columnWidth(columnIndex, sheetName): number;Width of the given column in the given sheet, in pixels. When no span
covers the column, falls back to the sheet’s default column width if set
(sheet.defaults.colWidth), otherwise to the Excel default
(EXCEL_DEFAULT_COLUMN_WIDTH_PX, 65).
Parameters
Section titled “Parameters”columnIndex
Section titled “columnIndex”number
1-based column index
sheetName
Section titled “sheetName”string
name of the sheet in which to look up a column width
Returns
Section titled “Returns”number
Throws
Section titled “Throws”if the sheet does not exist
Workbook.rowHeight (the same precedence chain on the row axis).
copySheet()
Section titled “copySheet()”copySheet(sheetName, newName?): WorkSheet;Copy a sheet and insert the copy immediately after the source.
Parameters
Section titled “Parameters”sheetName
Section titled “sheetName”string
the name of the sheet to copy (matched case-insensitively)
newName?
Section titled “newName?”string
name for the copy; if omitted, generates one following Excel’s convention (e.g. “Sheet1 (2)“)
Returns
Section titled “Returns”the new sheet
Throws
Section titled “Throws”if the source sheet does not exist, the new name is invalid or already taken, or there are writes that have not been reset
deleteColumns()
Section titled “deleteColumns()”deleteColumns( sheetName, columnIndex, count): RewriteFormula;Delete count columns at a specific index in the given sheet.
Parameters
Section titled “Parameters”sheetName
Section titled “sheetName”string
columnIndex
Section titled “columnIndex”number
0-based column index
number
how many columns should be deleted
Returns
Section titled “Returns”deleteRows()
Section titled “deleteRows()”deleteRows( sheetName, rowIndex, count): RewriteFormula;Delete count rows at a specific index in the given sheet.
Parameters
Section titled “Parameters”sheetName
Section titled “sheetName”string
rowIndex
Section titled “rowIndex”number
0-based row index
number
how many rows should be deleted
Returns
Section titled “Returns”editCell()
Section titled “editCell()”editCell(cellRef, cellData): | Cell | DefinedName;Write the given cell data attributes (.v, .f, etc.) to an existing or
new cell.
If cell value is an error value, normalize it to the corresponding
singleton error value in errorTable.
If cellData has a formula, it is parsed and (if parsing succeeds) the AST
is stored in the cell object.
If cellData has an .f attribute (whether null or not), the whole
workbook’s dependency graph is rebuilt.
Preconditions:
- Formula parser has finished importing (
formulaParserReadyhas resolved). - Workbook must be initialized.
Parameters
Section titled “Parameters”cellRef
Section titled “cellRef”string | Reference
the cell to edit, as a Reference or a string representing
one. If this indicates a range, the top-left cell of that range is
edited. May also be a name reference (defined name).
cellData
Section titled “cellData”object with attributes to write to the cell
Returns
Section titled “Returns”| Cell
| DefinedName
the existing or new Cell instance.
Throws
Section titled “Throws”if precondition is not satisfied (the formula parser has
not finished importing), or if a string is passed and it fails to parse
as a Reference.
emit()
Section titled “emit()”emit(event, ...arguments_): Emitter;Emit an event, invoking all handlers registered for it.
Parameters
Section titled “Parameters”string
The name of the event to emit.
arguments_
Section titled “arguments_”…any[]
Arguments to pass to the event handlers.
Returns
Section titled “Returns”Emitter
The Emitter instance for method chaining.
Inherited from
Section titled “Inherited from”EventEmitter.emitgetCell()
Section titled “getCell()”getCell(cellId, sheetName?): Cell | null;Parameters
Section titled “Parameters”cellId
Section titled “cellId”string
sheetName?
Section titled “sheetName?”string | null
Returns
Section titled “Returns”Cell | null
getGlobal()
Section titled “getGlobal()”getGlobal(name): | FormulaError | DefinedName;Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”getSheet()
Section titled “getSheet()”getSheet(sheetName?): WorkSheet | null;Parameters
Section titled “Parameters”sheetName?
Section titled “sheetName?”string | null
Returns
Section titled “Returns”WorkSheet | null
the named sheet if sheetName is truthy (null if not found), else the first sheet.
getSheetByIndex()
Section titled “getSheetByIndex()”getSheetByIndex(index?): WorkSheet | null;Get a sheet of the given index or else, if index is not provided, the first sheet of this workbook.
Parameters
Section titled “Parameters”index?
Section titled “index?”number | null
the index of a sheet
Returns
Section titled “Returns”WorkSheet | null
the sheet found at the given index, or else the first sheet if none was given. If no sheets are present this method returns null.
getSheetIndex()
Section titled “getSheetIndex()”getSheetIndex(sheetName?): number | null;Get the order index of a sheet with the given name.
Parameters
Section titled “Parameters”sheetName?
Section titled “sheetName?”string
the name of the sheet whose index should be returned. It will be matched case-insensitively.
Returns
Section titled “Returns”number | null
The index of the sheet with the given name, or null if no sheet with that name exists, or 0 if no/empty name was given.
getSheets()
Section titled “getSheets()”getSheets(): WorkSheet[];Returns
Section titled “Returns”getSheetSize()
Section titled “getSheetSize()”getSheetSize(sheetName?): [number, number];Get the size of a sheet with the given name.
Parameters
Section titled “Parameters”sheetName?
Section titled “sheetName?”string | null
the name of the sheet whose size should be returned. It will be matched case-insensitively. If not provided, or empty, the size of the first sheet (0, 0) is returned.
Returns
Section titled “Returns”[number, number]
The size of the sheet with the given name, or null if no sheet with that name exists, or (0, 0) if no/empty name was given.
hasListeners()
Section titled “hasListeners()”Call Signature
Section titled “Call Signature”hasListeners(event): boolean;Check if there are any handlers registered for a specific event.
Parameters
Section titled “Parameters”string
The name of the event.
Returns
Section titled “Returns”boolean
true if there are one or more handlers, false otherwise.
Inherited from
Section titled “Inherited from”EventEmitter.hasListenersCall Signature
Section titled “Call Signature”hasListeners(): boolean;Check if there are any handlers registered for any event.
Returns
Section titled “Returns”boolean
true if there are one or more handlers for any event, false otherwise.
Inherited from
Section titled “Inherited from”EventEmitter.hasListenersinsertColumns()
Section titled “insertColumns()”insertColumns( sheetName, columnIndex, count, toTheRight): RewriteFormula;Insert count columns at a specific index in the given sheet.
Parameters
Section titled “Parameters”sheetName
Section titled “sheetName”string
columnIndex
Section titled “columnIndex”number
0-based column index
number
how many columns to insert
toTheRight
Section titled “toTheRight”boolean
determines whether the inserted columns are inserted to the
left or right of the column at columnIndex.
Returns
Section titled “Returns”insertRows()
Section titled “insertRows()”insertRows( sheetName, rowIndex, count, below): RewriteFormula;Insert count rows at a specific index in the given sheet.
Parameters
Section titled “Parameters”sheetName
Section titled “sheetName”string
rowIndex
Section titled “rowIndex”number
0-based row index
number
how many rows to insert
boolean
determines whether the inserted rows are inserted below or
above of the row at rowIndex.
Returns
Section titled “Returns”isGlobal()
Section titled “isGlobal()”isGlobal(name): boolean;Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”boolean
iterDataTableCells()
Section titled “iterDataTableCells()”iterDataTableCells(): IterableIterator<Cell>;Returns
Section titled “Returns”IterableIterator<Cell>
iterFormulaCells()
Section titled “iterFormulaCells()”iterFormulaCells(): IterableIterator< | Cell| DefinedName>;Returns
Section titled “Returns”IterableIterator<
| Cell
| DefinedName>
listenerCount()
Section titled “listenerCount()”Call Signature
Section titled “Call Signature”listenerCount(event): number;Get the count of listeners for a specific event.
Parameters
Section titled “Parameters”string
The name of the event.
Returns
Section titled “Returns”number
The number of listeners for the event.
Inherited from
Section titled “Inherited from”EventEmitter.listenerCountCall Signature
Section titled “Call Signature”listenerCount(): number;Get the count of all event handlers in total.
Returns
Section titled “Returns”number
The total number of event handlers.
Inherited from
Section titled “Inherited from”EventEmitter.listenerCountlisteners()
Section titled “listeners()”listeners(event): (...arguments_) => void[];Retrieve the event handlers registered for a specific event.
Parameters
Section titled “Parameters”string
The name of the event.
Returns
Section titled “Returns”(…arguments_) => void[]
An array of functions registered as handlers for the event.
Inherited from
Section titled “Inherited from”EventEmitter.listenersmergeCells()
Section titled “mergeCells()”mergeCells( sheetName, rangeStr, options?): void;Merge a range of cells on the given sheet.
Parameters
Section titled “Parameters”sheetName
Section titled “sheetName”string
name of the sheet
rangeStr
Section titled “rangeStr”string
range in A1 notation, e.g. “A1:B2”
options?
Section titled “options?”recalcNow?
Section titled “recalcNow?”boolean = true
if true (default), recalculate after merging; set to false to batch multiple merges before a single recalc
Returns
Section titled “Returns”void
Throws
Section titled “Throws”if the sheet does not exist, the range is a single cell, or overlaps an existing merge
moveCells()
Section titled “moveCells()”moveCells( from, to, recalcNow?): RewriteFormula;Move the cells in the from range to the to range, preserving cell
values, formulas, styles, comments, and notes. References inside the
moved formulas are adjusted to track their new positions, and tables
fully contained within from move with the cells.
Returns a RewriteFormula function that adjusts references to the moved cells in formulas elsewhere in the workbook (or in any other workbook). The caller is responsible for applying it via Workbook.rewriteFormulas for any workbook whose formulas may reference the moved cells; this method does not invoke it automatically.
Precondition: formula parser has finished importing (formulaParserReady has resolved).
Parameters
Section titled “Parameters”string | A1Reference
Must be the same dimensions as to
string | A1Reference
Must be the same dimensions as from
recalcNow?
Section titled “recalcNow?”boolean = true
If false, skip the recalculate() call at the end. Useful when the caller will write more data before recalculating.
Returns
Section titled “Returns”A RewriteFormula function for adjusting references to the moved cells.
moveColumns()
Section titled “moveColumns()”moveColumns( sheetName, from, to, count): RewriteFormula;Parameters
Section titled “Parameters”sheetName
Section titled “sheetName”string
number
0-based index of first column to move
number
0-based index of end-position of first column to move
number
the number of columns to move
Returns
Section titled “Returns”moveRows()
Section titled “moveRows()”moveRows( sheetName, from, to, count): RewriteFormula;Parameters
Section titled “Parameters”sheetName
Section titled “sheetName”string
number
0-based index of first row to move
number
0-based index of end-position of first row to move
number
the number of rows to move
Returns
Section titled “Returns”Call Signature
Section titled “Call Signature”off(event, listener): Emitter;Remove a specific event handler for a specified event.
Parameters
Section titled “Parameters”string
The name of the event.
listener
Section titled “listener”(…arguments_) => void
The specific handler function to remove.
Returns
Section titled “Returns”Emitter
The Emitter instance for method chaining.
Inherited from
Section titled “Inherited from”EventEmitter.offCall Signature
Section titled “Call Signature”off(event): Emitter;Remove all event handlers for a specified event.
Parameters
Section titled “Parameters”string
The name of the event for which to remove all handlers.
Returns
Section titled “Returns”Emitter
The Emitter instance for method chaining.
Inherited from
Section titled “Inherited from”EventEmitter.offCall Signature
Section titled “Call Signature”off(): Emitter;Remove all event handlers for all events.
Returns
Section titled “Returns”Emitter
The Emitter instance for method chaining.
Inherited from
Section titled “Inherited from”EventEmitter.offon(event, listener): Emitter;Register an event handler that listens to a specified event.
Parameters
Section titled “Parameters”string
The name of the event to listen to.
listener
Section titled “listener”(…arguments_) => void
The function to execute when the event is emitted.
Returns
Section titled “Returns”Emitter
The Emitter instance for method chaining.
Inherited from
Section titled “Inherited from”EventEmitter.ononce()
Section titled “once()”once(event, listener): Emitter;Register a one-time event handler for a specified event.
Parameters
Section titled “Parameters”string
The name of the event to listen to.
listener
Section titled “listener”(…arguments_) => void
The function to execute once when the event is emitted.
Returns
Section titled “Returns”Emitter
The Emitter instance for method chaining.
Inherited from
Section titled “Inherited from”EventEmitter.onceremoveDefinedName()
Section titled “removeDefinedName()”removeDefinedName(name, sheetName?): boolean;Remove a defined name (global or sheet-scoped) from the workbook. This will schedule cells depending on that name for recalculation, but will not perform that recalculation.
Parameters
Section titled “Parameters”string
the name of the defined name to remove. It will be matched case-insensitively.
sheetName?
Section titled “sheetName?”string | null
the name of a sheet the defined name is scoped to, null if it is a global defined name. It will be matched case-insensitively.
Returns
Section titled “Returns”boolean
true if the name was removed, false if it did not exist (or the sheet did not exist)
removeSheet()
Section titled “removeSheet()”removeSheet(sheetName): boolean;Remove a sheet from the workbook.
Parameters
Section titled “Parameters”sheetName
Section titled “sheetName”string
the name of the sheet to delete. It will be matched case-insensitively.
Returns
Section titled “Returns”boolean
true if the sheet was removed, false if it did not exist
Throws
Section titled “Throws”if there are writes that have not been reset
renameSheet()
Section titled “renameSheet()”renameSheet(currentName, newName): void;Rename the given sheet to a new name, updating all formulas referencing it
Precondition: formula parser has finished importing (formulaParserReady has resolved).
Parameters
Section titled “Parameters”currentName
Section titled “currentName”string
newName
Section titled “newName”string
must be different from currentName
Returns
Section titled “Returns”void
Throws
Section titled “Throws”if no sheet exists named currentName
reorderSheet()
Section titled “reorderSheet()”reorderSheet(sheetName, newIndex): void;Move a sheet to a new position in the workbook.
Parameters
Section titled “Parameters”sheetName
Section titled “sheetName”string
the name of the sheet to move (matched case-insensitively)
newIndex
Section titled “newIndex”number
the target zero-based position
Returns
Section titled “Returns”void
Throws
Section titled “Throws”if no sheet exists with that name, index is out of bounds, or there are writes that have not been reset
requireSheet()
Section titled “requireSheet()”requireSheet(sheetName): WorkSheet;Like getSheet, but throws if the sheet does not exist.
Parameters
Section titled “Parameters”sheetName
Section titled “sheetName”string
Returns
Section titled “Returns”reset()
Section titled “reset()”reset(): void;Returns
Section titled “Returns”void
rewriteFormulas()
Section titled “rewriteFormulas()”rewriteFormulas(rewriteFormula, recalcNow?): number;Rewrite every formula cell’s formula string by passing it through the
given transform; cells whose rewriteFormula(formula) return value
differs from the original are updated and their dependency-graph edges
rebuilt.
Parameters
Section titled “Parameters”rewriteFormula
Section titled “rewriteFormula”(formula) => string
Transform applied to each formula. Returning the
input unchanged (by === identity or string equality) is treated as
“no change” and skips the cell.
recalcNow?
Section titled “recalcNow?”boolean = true
If false, skip the trailing recalculate(). The caller is responsible for triggering recalculation after any additional mutations.
Returns
Section titled “Returns”number
number of formulas changed
rowHeight()
Section titled “rowHeight()”rowHeight(rowIndex, sheetName): number;Height of the given row in the given sheet, in pixels. When no span covers
the row, falls back to the sheet’s default row height if set
(sheet.defaults.rowHeight), otherwise to the Excel default
(EXCEL_DEFAULT_ROW_HEIGHT_PX, 16).
Parameters
Section titled “Parameters”rowIndex
Section titled “rowIndex”number
1-based row index
sheetName
Section titled “sheetName”string
name of the sheet in which to look up a row height
Returns
Section titled “Returns”number
Throws
Section titled “Throws”if the sheet does not exist
Workbook.columnWidth (the same precedence chain on the column axis).
setColumnWidth()
Section titled “setColumnWidth()”setColumnWidth( sheetName, column, width): void;Parameters
Section titled “Parameters”sheetName
Section titled “sheetName”string
column
Section titled “column”number
0-based column index
number
non-negative
Returns
Section titled “Returns”void
Throws
Section titled “Throws”if there is no sheet with sheetName in this workbook, or if col and/or width are invalid
setDefinedName()
Section titled “setDefinedName()”setDefinedName<AbortOnError>( name, formula, sheet?, abortOnError?, validateNow?): | DefinedName | AbortOnError extends true ? null : never;Add a defined name in this workbook with the given formula.
If any error is detected in the formula (syntax error, or use of something
we do not support), abort and return null if abortOnError is true, else
go ahead and make the defined name but record the error with this.addError.
This method does not create a vertex in the dependency graph. If the graph
is already built (i.e. outside initial workbook construction), the caller
must call updateDependencies([dn.vertexId]) on the returned DefinedName
to register its vertex and outgoing edges.
Type Parameters
Section titled “Type Parameters”AbortOnError
Section titled “AbortOnError”AbortOnError extends boolean = false
Parameters
Section titled “Parameters”string
formula
Section titled “formula”string
sheet?
Section titled “sheet?”WorkSheet | null
sheet to scope the name to, or null for workbook scope
abortOnError?
Section titled “abortOnError?”AbortOnError
true to return null and make no change if formula has any errors
validateNow?
Section titled “validateNow?”boolean = true
set to false to skip formula validation here (caller is responsible for it then)
Returns
Section titled “Returns”| DefinedName
| AbortOnError extends true ? null : never
setRowHeight()
Section titled “setRowHeight()”setRowHeight( sheetName, rowNum, height): void;Sets the height of a row.
One function, SUBTOTAL, may yield different results depending on whether some cells in the range belong to hidden rows or not. Therefore, if the row becomes hidden, or was hidden before this change, a recalculation of formulas referencing cells in the affected row will be required. This call will register state about that, so that the next recalculation will update formula cells as needed. It is up to the caller to make sure a recalculation is eventually triggered.
Precondition: Workbook is initialized.
Parameters
Section titled “Parameters”sheetName
Section titled “sheetName”string
rowNum
Section titled “rowNum”number
0-based row index
height
Section titled “height”number
non-negative
Returns
Section titled “Returns”void
Throws
Section titled “Throws”if there is no sheet with sheetName in this workbook, or if rowNum and/or height are invalid
toCSF()
Section titled “toCSF()”toCSF(): CSFOutput;Returns
Section titled “Returns”CSFOutput
toJsf()
Section titled “toJsf()”toJsf(): JSF;Returns
Section titled “Returns”JSF
toJSF()
Section titled “toJSF()”toJSF(): JSF;Serialize this workbook to JSF (JSON Spreadsheet Format).
This is the inverse of Workbook.fromJSF, producing a JSF object that can be used to reconstruct the workbook state.
Returns
Section titled “Returns”JSF
A JSF object representing this workbook
toXlsx()
Section titled “toXlsx()”toXlsx<T>(outputType?, options?): Promise<XLSXOutputMap[T]>;Type Parameters
Section titled “Type Parameters”T extends keyof XLSXOutputMap = "nodebuffer"
Parameters
Section titled “Parameters”outputType?
Section titled “outputType?”T
options?
Section titled “options?”Returns
Section titled “Returns”Promise<XLSXOutputMap[T]>
toXLSX()
Section titled “toXLSX()”toXLSX<T>(outputType?, options?): Promise<XLSXOutputMap[T]>;Convert this workbook to XLSX format and return the result as a Buffer.
This method converts the workbook to JSF format first, then generates an XLSX file from that representation.
Type Parameters
Section titled “Type Parameters”T extends keyof XLSXOutputMap = "nodebuffer"
Parameters
Section titled “Parameters”outputType?
Section titled “outputType?”T
The output format: 'nodebuffer' (default) or 'arraybuffer'
options?
Section titled “options?”Optional settings (e.g. compression level)
Returns
Section titled “Returns”Promise<XLSXOutputMap[T]>
A Buffer containing the XLSX file data
toXlsxFile()
Section titled “toXlsxFile()”toXlsxFile(path, options?): Promise<void>;Parameters
Section titled “Parameters”string
options?
Section titled “options?”Returns
Section titled “Returns”Promise<void>
toXLSXFile()
Section titled “toXLSXFile()”toXLSXFile(path, options?): Promise<void>;Convert this workbook to XLSX format and write it to a file.
This method converts the workbook to JSF format first, then generates an XLSX file from that representation and writes it to the specified path.
Parameters
Section titled “Parameters”string
The file path to write the XLSX file to
options?
Section titled “options?”Optional settings (e.g. compression level)
Returns
Section titled “Returns”Promise<void>
unmergeCells()
Section titled “unmergeCells()”unmergeCells(sheetName, rangeStr): void;Unmerge cells on the given sheet. Any existing merge that overlaps the given range is fully removed. If no merges overlap, this is a no-op.
Parameters
Section titled “Parameters”sheetName
Section titled “sheetName”string
name of the sheet
rangeStr
Section titled “rangeStr”string
range in A1 notation, e.g. “A1:B2”
Returns
Section titled “Returns”void
Throws
Section titled “Throws”if the sheet does not exist
write()
Section titled “write()”write( ref, val, neutralizeFormulaOnSingleCellWrite?): boolean;Write the given value to the given cell (A1 address or global name)
Precondition: Workbook must be initialized
Parameters
Section titled “Parameters”string | Reference
the address or global name to write to
the value to write
neutralizeFormulaOnSingleCellWrite?
Section titled “neutralizeFormulaOnSingleCellWrite?”boolean = false
set to true if writes to single formula cells should neutralize them
Returns
Section titled “Returns”boolean
true if a write occurred
writeCellData()
Section titled “writeCellData()”writeCellData(cellRef, cellData): | Cell | DefinedName;Parameters
Section titled “Parameters”cellRef
Section titled “cellRef”string | Reference
cellData
Section titled “cellData”Returns
Section titled “Returns”| Cell
| DefinedName
writes()
Section titled “writes()”writes(): [string, CellValue][];Precondition: Workbook must be initialized
Returns
Section titled “Returns”[string, CellValue][]
fromCsf()
Section titled “fromCsf()”static fromCsf( csf, model, options?): Workbook;Create a Workbook from CSF format directly, bypassing JSF conversion. This provides significantly better performance than converting CSF→JSF→Workbook.
Parameters
Section titled “Parameters”Workbook data in CSF format
The Model instance to attach this workbook to
options?
Section titled “options?”WorkbookOptions = {}
Workbook initialization options
Returns
Section titled “Returns”Workbook
A new Workbook instance populated from CSF
fromJsf()
Section titled “fromJsf()”static fromJsf( jsf, model, options?): Workbook;Parameters
Section titled “Parameters”JSF
options?
Section titled “options?”WorkbookOptions = {}
Returns
Section titled “Returns”Workbook
fromJSF()
Section titled “fromJSF()”static fromJSF( jsf, model, options?): Workbook;Create a Workbook from JSF format.
Parameters
Section titled “Parameters”JSF
Workbook data in JSF format
The Model instance to attach this workbook to
options?
Section titled “options?”WorkbookOptions = {}
Workbook initialization options
Returns
Section titled “Returns”Workbook
A new Workbook instance populated from JSF
fromXlsx()
Section titled “fromXlsx()”static fromXlsx( data, model, filename,options?): Promise<Workbook>;Parameters
Section titled “Parameters”| ArrayBuffer
| Buffer<ArrayBufferLike>
| Uint8Array<ArrayBufferLike>
filename
Section titled “filename”string
options?
Section titled “options?”Returns
Section titled “Returns”Promise<Workbook>
fromXLSX()
Section titled “fromXLSX()”static fromXLSX( data, model, filename,options?): Promise<Workbook>;Create a Workbook from XLSX binary data.
This is a convenience method that wraps @borgar/xlsx-convert to load XLSX data
directly into a Workbook without requiring users to manually import the conversion library.
Note: This creates only the main workbook. External references in the XLSX file are not automatically added to the model. Use Model.addWorkbookFromXLSX to also add externals.
Parameters
Section titled “Parameters”| ArrayBuffer
| Buffer<ArrayBufferLike>
| Uint8Array<ArrayBufferLike>
Binary XLSX data (works in browsers and Node.js)
The Model instance to attach this workbook to
filename
Section titled “filename”string
Filename to associate with the workbook
options?
Section titled “options?”Workbook initialization options
Returns
Section titled “Returns”Promise<Workbook>
A Promise resolving to a new Workbook instance
fromXlsxFile()
Section titled “fromXlsxFile()”static fromXlsxFile( path, model,options?): Promise<Workbook>;Parameters
Section titled “Parameters”string
options?
Section titled “options?”Returns
Section titled “Returns”Promise<Workbook>
fromXLSXFile()
Section titled “fromXLSXFile()”static fromXLSXFile( path, model,options?): Promise<Workbook>;Create a Workbook from an XLSX file path.
This is a convenience method that wraps @borgar/xlsx-convert to load XLSX files
directly into a Workbook without requiring users to manually import the conversion library.
Note: This creates only the main workbook. External references in the XLSX file are not automatically added to the model. Use Model.addWorkbookFromXLSXFile to also add externals.
Parameters
Section titled “Parameters”string
Path to the XLSX file (Node.js only - uses fs)
The Model instance to attach this workbook to
options?
Section titled “options?”Workbook initialization options
Returns
Section titled “Returns”Promise<Workbook>
A Promise resolving to a new Workbook instance