Skip to content

@sheetkit/node / Workbook

Class: Workbook

Defined in: index.ts:302

Excel workbook for reading and writing .xlsx files.

Constructors

Constructor

new Workbook(): Workbook

Defined in: index.ts:305

Returns

Workbook

Accessors

sheetNames

Get Signature

get sheetNames(): string[]

Defined in: index.ts:358

Get the names of all sheets in workbook order.

Returns

string[]

Methods

addChart()

addChart(sheet, fromCell, toCell, config): void

Defined in: index.ts:582

Add a chart to a sheet.

Parameters

sheet

string

fromCell

string

toCell

string

config

JsChartConfig

Returns

void


addComment()

addComment(sheet, config): void

Defined in: index.ts:677

Add a comment to a cell.

Parameters

sheet

string

config

JsCommentConfig

Returns

void


addDataValidation()

addDataValidation(sheet, config): void

Defined in: index.ts:647

Add a data validation rule to a sheet.

Parameters

sheet

string

config

JsDataValidationConfig

Returns

void


addFormControl()

addFormControl(sheet, config): void

Defined in: index.ts:617

Add a form control to a sheet.

Parameters

sheet

string

config

JsFormControlConfig

Returns

void


addImage()

addImage(sheet, config): void

Defined in: index.ts:587

Add an image to a sheet.

Parameters

sheet

string

config

JsImageConfig

Returns

void


addPerson()

addPerson(input): string

Defined in: index.ts:717

Add a person to the person list. Returns the person ID.

Parameters

input

JsPersonInput

Returns

string


addPivotTable()

addPivotTable(config): void

Defined in: index.ts:965

Add a pivot table to the workbook.

Parameters

config

JsPivotTableConfig

Returns

void


addShape()

addShape(sheet, config): void

Defined in: index.ts:592

Add a shape to a sheet, anchored between two cells.

Parameters

sheet

string

config

JsShapeConfig

Returns

void


addSlicer()

addSlicer(sheet, config): void

Defined in: index.ts:1010

Add a slicer to a sheet targeting a table column.

Parameters

sheet

string

config

JsSlicerConfig

Returns

void


addSparkline()

addSparkline(sheet, config): void

Defined in: index.ts:980

Add a sparkline to a worksheet.

Parameters

sheet

string

config

JsSparklineConfig

Returns

void


addStyle()

addStyle(style): number

Defined in: index.ts:547

Add a style definition. Returns the style ID for use with setCellStyle.

Parameters

style

JsStyle

Returns

number


addTable()

addTable(sheet, config): void

Defined in: index.ts:995

Register a table in the workbook.

Parameters

sheet

string

config

JsTableConfig

Returns

void


addThreadedComment()

addThreadedComment(sheet, cell, input): string

Defined in: index.ts:692

Add a threaded comment to a cell. Returns the comment ID.

Parameters

sheet

string

cell

string

input

JsThreadedCommentInput

Returns

string


applyStreamWriter()

applyStreamWriter(writer): number

Defined in: index.ts:742

Apply a stream writer's output to the workbook. Returns the sheet index.

Parameters

writer

JsStreamWriter

Returns

number


calculateAll()

calculateAll(): void

Defined in: index.ts:960

Recalculate all formula cells in the workbook.

Returns

void


copySheet()

copySheet(source, target): number

Defined in: index.ts:442

Copy a sheet. Returns the new sheet's 0-based index.

Parameters

source

string

target

string

Returns

number


deleteCellHyperlink(sheet, cell): void

Defined in: index.ts:890

Delete a hyperlink from a cell.

Parameters

sheet

string

cell

string

Returns

void


deleteChart()

deleteChart(sheet, cell): void

Defined in: index.ts:597

Delete a chart anchored at the given cell.

Parameters

sheet

string

cell

string

Returns

void


deleteConditionalFormat()

deleteConditionalFormat(sheet, sqref): void

Defined in: index.ts:672

Delete conditional formatting for a specific cell range.

Parameters

sheet

string

sqref

string

Returns

void


deleteCustomProperty()

deleteCustomProperty(name): boolean

Defined in: index.ts:786

Delete a custom property. Returns true if it existed.

Parameters

name

string

Returns

boolean


deleteDefinedName()

deleteDefinedName(name, scope?): void

Defined in: index.ts:1055

Delete a defined name by name and optional scope.

Parameters

name

string

scope?

string | null

Returns

void


deleteFormControl()

deleteFormControl(sheet, index): void

Defined in: index.ts:627

Delete a form control by index.

Parameters

sheet

string

index

number

Returns

void


deletePicture()

deletePicture(sheet, cell): void

Defined in: index.ts:602

Delete a picture anchored at the given cell.

Parameters

sheet

string

cell

string

Returns

void


deletePivotTable()

deletePivotTable(name): void

Defined in: index.ts:975

Delete a pivot table by name.

Parameters

name

string

Returns

void


deleteSheet()

deleteSheet(name): void

Defined in: index.ts:432

Delete a sheet by name.

Parameters

name

string

Returns

void


deleteSlicer()

deleteSlicer(sheet, name): void

Defined in: index.ts:1020

Delete a slicer by name from a sheet.

Parameters

sheet

string

name

string

Returns

void


deleteTable()

deleteTable(sheet, name): void

Defined in: index.ts:1005

Delete a table from a sheet by name.

Parameters

sheet

string

name

string

Returns

void


deleteThreadedComment()

deleteThreadedComment(sheet, commentId): void

Defined in: index.ts:707

Delete a threaded comment by ID.

Parameters

sheet

string

commentId

string

Returns

void


duplicateRow()

duplicateRow(sheet, row): void

Defined in: index.ts:472

Duplicate a row (1-based).

Parameters

sheet

string

row

number

Returns

void


evaluateFormula()

evaluateFormula(sheet, formula): string | number | boolean | DateValue | null

Defined in: index.ts:955

Evaluate a formula string against the current workbook data.

Parameters

sheet

string

formula

string

Returns

string | number | boolean | DateValue | null


fillFormula()

fillFormula(sheet, range, formula): void

Defined in: index.ts:950

Fill a range with a formula, adjusting row references.

Parameters

sheet

string

range

string

formula

string

Returns

void


fromJSON()

fromJSON(sheet, data, options?): void

Defined in: index.ts:1172

Write an array of JSON objects to a sheet.

Parameters

sheet

string

data

Record<string, CellValueInput>[]

options?

FromJsonOptions

Returns

void


getActiveSheet()

getActiveSheet(): string

Defined in: index.ts:452

Get the name of the active sheet.

Returns

string


getAppProps()

getAppProps(): JsAppProperties

Defined in: index.ts:771

Get application properties.

Returns

JsAppProperties


getCellFormattedValue()

getCellFormattedValue(sheet, cell): string

Defined in: index.ts:398

Get the formatted display text for a cell, applying its number format.

Parameters

sheet

string

cell

string

Returns

string


getCellHyperlink(sheet, cell): JsHyperlinkInfo | null

Defined in: index.ts:885

Get hyperlink information for a cell, or null if no hyperlink exists.

Parameters

sheet

string

cell

string

Returns

JsHyperlinkInfo | null


getCellRichText()

getCellRichText(sheet, cell): JsRichTextRun[] | null

Defined in: index.ts:1030

Get rich text runs for a cell, or null if not rich text.

Parameters

sheet

string

cell

string

Returns

JsRichTextRun[] | null


getCellStyle()

getCellStyle(sheet, cell): number | null

Defined in: index.ts:552

Get the style ID applied to a cell, or null if default.

Parameters

sheet

string

cell

string

Returns

number | null


getCellValue()

getCellValue(sheet, cell): string | number | boolean | DateValue | null

Defined in: index.ts:393

Get the value of a cell. Returns string, number, boolean, DateValue, or null.

Parameters

sheet

string

cell

string

Returns

string | number | boolean | DateValue | null


getColOutlineLevel()

getColOutlineLevel(sheet, col): number

Defined in: index.ts:532

Get the outline level of a column. Returns 0 if not set.

Parameters

sheet

string

col

string

Returns

number


getCols()

getCols(sheet): JsColData[]

Defined in: index.ts:940

Get all columns with their data from a sheet.

Parameters

sheet

string

Returns

JsColData[]


getColStyle()

getColStyle(sheet, col): number

Defined in: index.ts:577

Get the style ID for a column. Returns 0 if not set.

Parameters

sheet

string

col

string

Returns

number


getColVisible()

getColVisible(sheet, col): boolean

Defined in: index.ts:522

Get whether a column is visible.

Parameters

sheet

string

col

string

Returns

boolean


getColWidth()

getColWidth(sheet, col): number | null

Defined in: index.ts:512

Get the width of a column, or null if not explicitly set.

Parameters

sheet

string

col

string

Returns

number | null


getComments()

getComments(sheet): JsCommentConfig[]

Defined in: index.ts:682

Get all comments on a sheet.

Parameters

sheet

string

Returns

JsCommentConfig[]


getConditionalFormats()

getConditionalFormats(sheet): JsConditionalFormatEntry[]

Defined in: index.ts:667

Get all conditional formatting rules for a sheet.

Parameters

sheet

string

Returns

JsConditionalFormatEntry[]


getCustomProperty()

getCustomProperty(name): string | number | boolean | null

Defined in: index.ts:781

Get a custom property value, or null if not found.

Parameters

name

string

Returns

string | number | boolean | null


getDataValidations()

getDataValidations(sheet): JsDataValidationConfig[]

Defined in: index.ts:652

Get all data validations on a sheet.

Parameters

sheet

string

Returns

JsDataValidationConfig[]


getDefinedName()

getDefinedName(name, scope?): JsDefinedNameInfo | null

Defined in: index.ts:1045

Get a defined name by name and optional scope.

Parameters

name

string

scope?

string | null

Returns

JsDefinedNameInfo | null


getDefinedNames()

getDefinedNames(): JsDefinedNameInfo[]

Defined in: index.ts:1050

Get all defined names in the workbook.

Returns

JsDefinedNameInfo[]


getDocProps()

getDocProps(): JsDocProperties

Defined in: index.ts:761

Get core document properties.

Returns

JsDocProperties


getFormat()

getFormat(): string

Defined in: index.ts:1214

Get the workbook format ("xlsx", "xlsm", "xltx", "xltm", "xlam").

Returns

string


getFormControls()

getFormControls(sheet): JsFormControlInfo[]

Defined in: index.ts:622

Get all form controls on a sheet.

Parameters

sheet

string

Returns

JsFormControlInfo[]


getHeaderFooter()

getHeaderFooter(sheet): JsHeaderFooter

Defined in: index.ts:850

Get the header and footer text for a sheet.

Parameters

sheet

string

Returns

JsHeaderFooter


getMergeCells()

getMergeCells(sheet): string[]

Defined in: index.ts:642

Get all merged cell ranges on a sheet.

Parameters

sheet

string

Returns

string[]


getPageBreaks()

getPageBreaks(sheet): number[]

Defined in: index.ts:875

Get all row page break positions (1-based row numbers).

Parameters

sheet

string

Returns

number[]


getPageMargins()

getPageMargins(sheet): JsPageMargins

Defined in: index.ts:826

Get page margins for a sheet. Returns defaults if not explicitly set.

Parameters

sheet

string

Returns

JsPageMargins


getPageSetup()

getPageSetup(sheet): JsPageSetup

Defined in: index.ts:836

Get the page setup for a sheet.

Parameters

sheet

string

Returns

JsPageSetup


getPanes()

getPanes(sheet): string | null

Defined in: index.ts:816

Get the current freeze pane cell reference for a sheet, or null if none.

Parameters

sheet

string

Returns

string | null


getPersons()

getPersons(): JsPersonData[]

Defined in: index.ts:722

Get all persons in the person list.

Returns

JsPersonData[]


getPictureCells()

getPictureCells(sheet): string[]

Defined in: index.ts:612

Get all cells that have pictures anchored to them on the given sheet.

Parameters

sheet

string

Returns

string[]


getPictures()

getPictures(sheet, cell): JsPictureInfo[]

Defined in: index.ts:607

Get all pictures anchored at the given cell.

Parameters

sheet

string

cell

string

Returns

JsPictureInfo[]


getPivotTables()

getPivotTables(): JsPivotTableInfo[]

Defined in: index.ts:970

Get all pivot tables in the workbook.

Returns

JsPivotTableInfo[]


getPrintOptions()

getPrintOptions(sheet): JsPrintOptions

Defined in: index.ts:860

Get print options for a sheet.

Parameters

sheet

string

Returns

JsPrintOptions


getRowHeight()

getRowHeight(sheet, row): number | null

Defined in: index.ts:482

Get the height of a row, or null if not explicitly set.

Parameters

sheet

string

row

number

Returns

number | null


getRowOutlineLevel()

getRowOutlineLevel(sheet, row): number

Defined in: index.ts:502

Get the outline level of a row. Returns 0 if not set.

Parameters

sheet

string

row

number

Returns

number


getRows()

getRows(sheet): JsRowData[]

Defined in: index.ts:895

Get all rows with their data from a sheet using buffer-based transfer.

Parameters

sheet

string

Returns

JsRowData[]


getRowsBuffer()

getRowsBuffer(sheet): Buffer

Defined in: index.ts:901

Serialize a sheet's cell data into a compact binary buffer (v1 format).

Parameters

sheet

string

Returns

Buffer


getRowsBufferV2()

getRowsBufferV2(sheet): Buffer

Defined in: index.ts:910

Serialize a sheet's cell data into a v2 binary buffer with inline strings. The v2 format eliminates the global string table, enabling incremental row-by-row decoding without eagerly materializing all strings.

Parameters

sheet

string

Returns

Buffer


getRowsIterator()

getRowsIterator(sheet): Generator<JsRowData>

Defined in: index.ts:929

Get a generator that yields one row at a time from the sheet, avoiding materializing the entire result array in memory at once.

Parameters

sheet

string

Returns

Generator<JsRowData>


getRowsRaw()

getRowsRaw(sheet): RawRowsResult

Defined in: index.ts:920

Get all rows as typed arrays with minimal JS object creation. Returns column numbers (not names), cell types, and values in parallel typed arrays. Use this when processing large sheets where object creation overhead matters.

Parameters

sheet

string

Returns

RawRowsResult


getRowStyle()

getRowStyle(sheet, row): number

Defined in: index.ts:567

Get the style ID for a row. Returns 0 if not set.

Parameters

sheet

string

row

number

Returns

number


getRowVisible()

getRowVisible(sheet, row): boolean

Defined in: index.ts:492

Get whether a row is visible.

Parameters

sheet

string

row

number

Returns

boolean


getSheetIndex()

getSheetIndex(name): number | null

Defined in: index.ts:447

Get the 0-based index of a sheet, or null if not found.

Parameters

name

string

Returns

number | null


getSheetViewOptions()

getSheetViewOptions(sheet): JsSheetViewOptions

Defined in: index.ts:1224

Get sheet view options.

Parameters

sheet

string

Returns

JsSheetViewOptions


getSheetVisibility()

getSheetVisibility(sheet): string

Defined in: index.ts:1234

Get sheet visibility. Returns "visible", "hidden", or "veryHidden".

Parameters

sheet

string

Returns

string


getSlicers()

getSlicers(sheet): JsSlicerInfo[]

Defined in: index.ts:1015

Get all slicers on a sheet.

Parameters

sheet

string

Returns

JsSlicerInfo[]


getSparklines()

getSparklines(sheet): JsSparklineConfig[]

Defined in: index.ts:985

Get all sparklines for a worksheet.

Parameters

sheet

string

Returns

JsSparklineConfig[]


getTables()

getTables(sheet): JsTableInfo[]

Defined in: index.ts:1000

Get all tables on a sheet.

Parameters

sheet

string

Returns

JsTableInfo[]


getThemeColor()

getThemeColor(index, tint?): string | null

Defined in: index.ts:1035

Resolve a theme color by index (0-11) with optional tint.

Parameters

index

number

tint?

number | null

Returns

string | null


getThreadedComments()

getThreadedComments(sheet): JsThreadedCommentData[]

Defined in: index.ts:697

Get all threaded comments on a sheet.

Parameters

sheet

string

Returns

JsThreadedCommentData[]


getThreadedCommentsByCell()

getThreadedCommentsByCell(sheet, cell): JsThreadedCommentData[]

Defined in: index.ts:702

Get threaded comments for a specific cell on a sheet.

Parameters

sheet

string

cell

string

Returns

JsThreadedCommentData[]


getVbaModules()

getVbaModules(): JsVbaProject | null

Defined in: index.ts:1249

Extract VBA module source code from the workbook's VBA project. Returns null if no VBA project.

Returns

JsVbaProject | null


getVbaProject()

getVbaProject(): Buffer<ArrayBufferLike> | null

Defined in: index.ts:1244

Get the raw VBA project binary (xl/vbaProject.bin), or null if not present.

Returns

Buffer<ArrayBufferLike> | null


insertCols()

insertCols(sheet, col, count): void

Defined in: index.ts:537

Insert empty columns starting at the given column letter.

Parameters

sheet

string

col

string

count

number

Returns

void


insertPageBreak()

insertPageBreak(sheet, row): void

Defined in: index.ts:865

Insert a horizontal page break before the given 1-based row.

Parameters

sheet

string

row

number

Returns

void


insertRows()

insertRows(sheet, startRow, count): void

Defined in: index.ts:462

Insert empty rows starting at the given 1-based row number.

Parameters

sheet

string

startRow

number

count

number

Returns

void


isSheetProtected()

isSheetProtected(sheet): boolean

Defined in: index.ts:1070

Check if a sheet is protected.

Parameters

sheet

string

Returns

boolean


isWorkbookProtected()

isWorkbookProtected(): boolean

Defined in: index.ts:801

Check if the workbook is protected.

Returns

boolean


mergeCells()

mergeCells(sheet, topLeft, bottomRight): void

Defined in: index.ts:632

Merge a range of cells on a sheet.

Parameters

sheet

string

topLeft

string

bottomRight

string

Returns

void


newSheet()

newSheet(name): number

Defined in: index.ts:427

Create a new empty sheet. Returns the 0-based sheet index.

Parameters

name

string

Returns

number


newStreamWriter()

newStreamWriter(sheetName): JsStreamWriter

Defined in: index.ts:737

Create a new stream writer for a new sheet.

Parameters

sheetName

string

Returns

JsStreamWriter


openSheetReader()

openSheetReader(sheet, opts?): Promise<SheetStreamReader>

Defined in: index.ts:750

Open a forward-only streaming reader for the named sheet. Reads rows in batches without loading the entire sheet into memory.

Parameters

sheet

string

opts?
batchSize?

number

Returns

Promise<SheetStreamReader>


protectSheet()

protectSheet(sheet, config?): void

Defined in: index.ts:1060

Protect a sheet with optional password and permission settings.

Parameters

sheet

string

config?

JsSheetProtectionConfig | null

Returns

void


protectWorkbook()

protectWorkbook(config): void

Defined in: index.ts:791

Protect the workbook structure/windows with optional password.

Parameters

config

JsWorkbookProtectionConfig

Returns

void


removeAutoFilter()

removeAutoFilter(sheet): void

Defined in: index.ts:732

Remove the auto-filter from a sheet.

Parameters

sheet

string

Returns

void


removeCol()

removeCol(sheet, col): void

Defined in: index.ts:542

Remove a column by letter.

Parameters

sheet

string

col

string

Returns

void


removeComment()

removeComment(sheet, cell): void

Defined in: index.ts:687

Remove a comment from a cell.

Parameters

sheet

string

cell

string

Returns

void


removeDataValidation()

removeDataValidation(sheet, sqref): void

Defined in: index.ts:657

Remove a data validation by sqref.

Parameters

sheet

string

sqref

string

Returns

void


removePageBreak()

removePageBreak(sheet, row): void

Defined in: index.ts:870

Remove a horizontal page break at the given 1-based row.

Parameters

sheet

string

row

number

Returns

void


removeRow()

removeRow(sheet, row): void

Defined in: index.ts:467

Remove a row (1-based).

Parameters

sheet

string

row

number

Returns

void


removeSparkline()

removeSparkline(sheet, location): void

Defined in: index.ts:990

Remove a sparkline by its location cell reference.

Parameters

sheet

string

location

string

Returns

void


renderToSvg()

renderToSvg(options): string

Defined in: index.ts:1239

Render a worksheet to an SVG string.

Parameters

options

JsRenderOptions

Returns

string


resolveThreadedComment()

resolveThreadedComment(sheet, commentId, done): void

Defined in: index.ts:712

Set the resolved (done) state of a threaded comment.

Parameters

sheet

string

commentId

string

done

boolean

Returns

void


save()

save(path): Promise<void>

Defined in: index.ts:368

Save the workbook to a .xlsx file asynchronously. Serializes to an in-memory buffer before writing; use saveSync for lower peak memory on large workbooks.

Parameters

path

string

Returns

Promise<void>


saveSync()

saveSync(path): void

Defined in: index.ts:363

Save the workbook to a .xlsx file.

Parameters

path

string

Returns

void


saveWithPassword()

saveWithPassword(path, password): Promise<void>

Defined in: index.ts:388

Save the workbook as an encrypted .xlsx file asynchronously. Both sync and async encrypted saves buffer in memory before encrypting, so peak memory is similar.

Parameters

path

string

password

string

Returns

Promise<void>


saveWithPasswordSync()

saveWithPasswordSync(path, password): void

Defined in: index.ts:383

Save the workbook as an encrypted .xlsx file.

Parameters

path

string

password

string

Returns

void


setActiveSheet()

setActiveSheet(name): void

Defined in: index.ts:457

Set the active sheet by name.

Parameters

name

string

Returns

void


setAppProps()

setAppProps(props): void

Defined in: index.ts:766

Set application properties (company, app version, etc.).

Parameters

props

JsAppProperties

Returns

void


setAutoFilter()

setAutoFilter(sheet, range): void

Defined in: index.ts:727

Set an auto-filter on a sheet.

Parameters

sheet

string

range

string

Returns

void


setCellFormula()

setCellFormula(sheet, cell, formula): void

Defined in: index.ts:945

Set a formula on a cell.

Parameters

sheet

string

cell

string

formula

string

Returns

void


setCellHyperlink(sheet, cell, opts): void

Defined in: index.ts:880

Set a hyperlink on a cell.

Parameters

sheet

string

cell

string

opts

JsHyperlinkOptions

Returns

void


setCellRichText()

setCellRichText(sheet, cell, runs): void

Defined in: index.ts:1025

Set a cell to a rich text value with multiple formatted runs.

Parameters

sheet

string

cell

string

runs

JsRichTextRun[]

Returns

void


setCellStyle()

setCellStyle(sheet, cell, styleId): void

Defined in: index.ts:557

Apply a style ID to a cell.

Parameters

sheet

string

cell

string

styleId

number

Returns

void


setCellValue()

setCellValue(sheet, cell, value): void

Defined in: index.ts:403

Set the value of a cell. Pass string, number, boolean, DateValue, or null to clear.

Parameters

sheet

string

cell

string

value

CellValueInput

Returns

void


setCellValues()

setCellValues(sheet, cells): void

Defined in: index.ts:408

Set multiple cell values at once.

Parameters

sheet

string

cells

JsCellEntry[]

Returns

void


setColOutlineLevel()

setColOutlineLevel(sheet, col, level): void

Defined in: index.ts:527

Set the outline level of a column (0-7).

Parameters

sheet

string

col

string

level

number

Returns

void


setColStyle()

setColStyle(sheet, col, styleId): void

Defined in: index.ts:572

Apply a style ID to an entire column.

Parameters

sheet

string

col

string

styleId

number

Returns

void


setColVisible()

setColVisible(sheet, col, visible): void

Defined in: index.ts:517

Set whether a column is visible.

Parameters

sheet

string

col

string

visible

boolean

Returns

void


setColWidth()

setColWidth(sheet, col, width): void

Defined in: index.ts:507

Set the width of a column (e.g., "A", "B", "AA").

Parameters

sheet

string

col

string

width

number

Returns

void


setConditionalFormat()

setConditionalFormat(sheet, sqref, rules): void

Defined in: index.ts:662

Set conditional formatting rules on a cell range.

Parameters

sheet

string

sqref

string

rules

JsConditionalFormatRule[]

Returns

void


setCustomProperty()

setCustomProperty(name, value): void

Defined in: index.ts:776

Set a custom property. Value can be string, number, or boolean.

Parameters

name

string

value

string | number | boolean

Returns

void


setDefinedName()

setDefinedName(config): void

Defined in: index.ts:1040

Add or update a defined name.

Parameters

config

JsDefinedNameConfig

Returns

void


setDocProps()

setDocProps(props): void

Defined in: index.ts:756

Set core document properties (title, creator, etc.).

Parameters

props

JsDocProperties

Returns

void


setHeaderFooter()

setHeaderFooter(sheet, header?, footer?): void

Defined in: index.ts:841

Set header and footer text for printing.

Parameters

sheet

string

string | null

string | null

Returns

void


setPageMargins()

setPageMargins(sheet, margins): void

Defined in: index.ts:821

Set page margins on a sheet (values in inches).

Parameters

sheet

string

margins

JsPageMargins

Returns

void


setPageSetup()

setPageSetup(sheet, setup): void

Defined in: index.ts:831

Set page setup options (paper size, orientation, scale, fit-to-page).

Parameters

sheet

string

setup

JsPageSetup

Returns

void


setPanes()

setPanes(sheet, cell): void

Defined in: index.ts:806

Set freeze panes on a sheet.

Parameters

sheet

string

cell

string

Returns

void


setPrintOptions()

setPrintOptions(sheet, opts): void

Defined in: index.ts:855

Set print options on a sheet.

Parameters

sheet

string

opts

JsPrintOptions

Returns

void


setRowHeight()

setRowHeight(sheet, row, height): void

Defined in: index.ts:477

Set the height of a row (1-based).

Parameters

sheet

string

row

number

height

number

Returns

void


setRowOutlineLevel()

setRowOutlineLevel(sheet, row, level): void

Defined in: index.ts:497

Set the outline level of a row (0-7).

Parameters

sheet

string

row

number

level

number

Returns

void


setRowStyle()

setRowStyle(sheet, row, styleId): void

Defined in: index.ts:562

Apply a style ID to an entire row.

Parameters

sheet

string

row

number

styleId

number

Returns

void


setRowValues()

setRowValues(sheet, row, startCol, values): void

Defined in: index.ts:413

Set values in a single row starting from the given column.

Parameters

sheet

string

row

number

startCol

string

values

CellValueInput[]

Returns

void


setRowVisible()

setRowVisible(sheet, row, visible): void

Defined in: index.ts:487

Set whether a row is visible.

Parameters

sheet

string

row

number

visible

boolean

Returns

void


setSheetData()

setSheetData(sheet, data, startCell?): void

Defined in: index.ts:418

Set a block of cell values from a 2D array.

Parameters

sheet

string

data

CellValueInput[][]

startCell?

string | null

Returns

void


setSheetDataBuffer()

setSheetDataBuffer(sheet, buf, startCell?): void

Defined in: index.ts:935

Apply cell data from a binary buffer to a sheet.

Parameters

sheet

string

buf

Buffer

startCell?

string | null

Returns

void


setSheetName()

setSheetName(oldName, newName): void

Defined in: index.ts:437

Rename a sheet.

Parameters

oldName

string

newName

string

Returns

void


setSheetViewOptions()

setSheetViewOptions(sheet, opts): void

Defined in: index.ts:1219

Set sheet view options (gridlines, zoom, view mode, etc.).

Parameters

sheet

string

opts

JsSheetViewOptions

Returns

void


setSheetVisibility()

setSheetVisibility(sheet, visibility): void

Defined in: index.ts:1229

Set sheet visibility ("visible", "hidden", or "veryHidden").

Parameters

sheet

string

visibility

string

Returns

void


toCSV()

toCSV(sheet, options?): string

Defined in: index.ts:1110

Convert sheet data to a CSV string.

Parameters

sheet

string

options?

ToCsvOptions

Returns

string


toHTML()

toHTML(sheet, options?): string

Defined in: index.ts:1150

Convert sheet data to an HTML table string.

Parameters

sheet

string

options?

ToHtmlOptions

Returns

string


toJSON()

toJSON(sheet, options?): Record<string, CellValue>[]

Defined in: index.ts:1075

Convert sheet data to an array of JSON objects.

Parameters

sheet

string

options?

ToJsonOptions

Returns

Record<string, CellValue>[]


unmergeCell()

unmergeCell(sheet, reference): void

Defined in: index.ts:637

Remove a merged cell range from a sheet.

Parameters

sheet

string

reference

string

Returns

void


unprotectSheet()

unprotectSheet(sheet): void

Defined in: index.ts:1065

Remove sheet protection.

Parameters

sheet

string

Returns

void


unprotectWorkbook()

unprotectWorkbook(): void

Defined in: index.ts:796

Remove workbook protection.

Returns

void


unsetPanes()

unsetPanes(sheet): void

Defined in: index.ts:811

Remove any freeze or split panes from a sheet.

Parameters

sheet

string

Returns

void


writeBuffer()

writeBuffer(): Promise<Buffer<ArrayBufferLike>>

Defined in: index.ts:378

Serialize the workbook to an in-memory Buffer asynchronously.

Returns

Promise<Buffer<ArrayBufferLike>>


writeBufferSync()

writeBufferSync(): Buffer

Defined in: index.ts:373

Serialize the workbook to an in-memory Buffer.

Returns

Buffer


open()

static open(path, options?): Promise<Workbook>

Defined in: index.ts:324

Open an existing .xlsx file from disk asynchronously.

Parameters

path

string

options?

OpenOptions | JsOpenOptions | null

Returns

Promise<Workbook>


openBuffer()

static openBuffer(data, options?): Promise<Workbook>

Defined in: index.ts:340

Open a workbook from an in-memory Buffer asynchronously.

Parameters

data

Buffer

options?

OpenOptions | JsOpenOptions | null

Returns

Promise<Workbook>


openBufferSync()

static openBufferSync(data, options?): Workbook

Defined in: index.ts:332

Open a workbook from an in-memory Buffer.

Parameters

data

Buffer

options?

OpenOptions | JsOpenOptions | null

Returns

Workbook


openSync()

static openSync(path, options?): Workbook

Defined in: index.ts:316

Open an existing .xlsx file from disk.

Parameters

path

string

options?

OpenOptions | JsOpenOptions | null

Returns

Workbook


openWithPassword()

static openWithPassword(path, password): Promise<Workbook>

Defined in: index.ts:353

Open an encrypted .xlsx file using a password asynchronously.

Parameters

path

string

password

string

Returns

Promise<Workbook>


openWithPasswordSync()

static openWithPasswordSync(path, password): Workbook

Defined in: index.ts:348

Open an encrypted .xlsx file using a password.

Parameters

path

string

password

string

Returns

Workbook

Released under the MIT / Apache-2.0 License.