Skip to content

@sheetkit/node / Workbook

Class: Workbook

Defined in: index.ts:282

Excel workbook for reading and writing .xlsx files.

Constructors

Constructor

new Workbook(): Workbook

Defined in: index.ts:285

Returns

Workbook

Accessors

sheetNames

Get Signature

get sheetNames(): string[]

Defined in: index.ts:338

Get the names of all sheets in workbook order.

Returns

string[]

Methods

addChart()

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

Defined in: index.ts:562

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:657

Add a comment to a cell.

Parameters

sheet

string

config

JsCommentConfig

Returns

void


addDataValidation()

addDataValidation(sheet, config): void

Defined in: index.ts:627

Add a data validation rule to a sheet.

Parameters

sheet

string

config

JsDataValidationConfig

Returns

void


addFormControl()

addFormControl(sheet, config): void

Defined in: index.ts:597

Add a form control to a sheet.

Parameters

sheet

string

config

JsFormControlConfig

Returns

void


addImage()

addImage(sheet, config): void

Defined in: index.ts:567

Add an image to a sheet.

Parameters

sheet

string

config

JsImageConfig

Returns

void


addPerson()

addPerson(input): string

Defined in: index.ts:697

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

Parameters

input

JsPersonInput

Returns

string


addPivotTable()

addPivotTable(config): void

Defined in: index.ts:945

Add a pivot table to the workbook.

Parameters

config

JsPivotTableConfig

Returns

void


addShape()

addShape(sheet, config): void

Defined in: index.ts:572

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:990

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:960

Add a sparkline to a worksheet.

Parameters

sheet

string

config

JsSparklineConfig

Returns

void


addStyle()

addStyle(style): number

Defined in: index.ts:527

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:975

Register a table in the workbook.

Parameters

sheet

string

config

JsTableConfig

Returns

void


addThreadedComment()

addThreadedComment(sheet, cell, input): string

Defined in: index.ts:672

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:722

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:940

Recalculate all formula cells in the workbook.

Returns

void


copySheet()

copySheet(source, target): number

Defined in: index.ts:422

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:870

Delete a hyperlink from a cell.

Parameters

sheet

string

cell

string

Returns

void


deleteChart()

deleteChart(sheet, cell): void

Defined in: index.ts:577

Delete a chart anchored at the given cell.

Parameters

sheet

string

cell

string

Returns

void


deleteConditionalFormat()

deleteConditionalFormat(sheet, sqref): void

Defined in: index.ts:652

Delete conditional formatting for a specific cell range.

Parameters

sheet

string

sqref

string

Returns

void


deleteCustomProperty()

deleteCustomProperty(name): boolean

Defined in: index.ts:766

Delete a custom property. Returns true if it existed.

Parameters

name

string

Returns

boolean


deleteDefinedName()

deleteDefinedName(name, scope?): void

Defined in: index.ts:1035

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:607

Delete a form control by index.

Parameters

sheet

string

index

number

Returns

void


deletePicture()

deletePicture(sheet, cell): void

Defined in: index.ts:582

Delete a picture anchored at the given cell.

Parameters

sheet

string

cell

string

Returns

void


deletePivotTable()

deletePivotTable(name): void

Defined in: index.ts:955

Delete a pivot table by name.

Parameters

name

string

Returns

void


deleteSheet()

deleteSheet(name): void

Defined in: index.ts:412

Delete a sheet by name.

Parameters

name

string

Returns

void


deleteSlicer()

deleteSlicer(sheet, name): void

Defined in: index.ts:1000

Delete a slicer by name from a sheet.

Parameters

sheet

string

name

string

Returns

void


deleteTable()

deleteTable(sheet, name): void

Defined in: index.ts:985

Delete a table from a sheet by name.

Parameters

sheet

string

name

string

Returns

void


deleteThreadedComment()

deleteThreadedComment(sheet, commentId): void

Defined in: index.ts:687

Delete a threaded comment by ID.

Parameters

sheet

string

commentId

string

Returns

void


duplicateRow()

duplicateRow(sheet, row): void

Defined in: index.ts:452

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:935

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:930

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:1152

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:432

Get the name of the active sheet.

Returns

string


getAppProps()

getAppProps(): JsAppProperties

Defined in: index.ts:751

Get application properties.

Returns

JsAppProperties


getCellFormattedValue()

getCellFormattedValue(sheet, cell): string

Defined in: index.ts:378

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:865

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:1010

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:532

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:373

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:512

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:920

Get all columns with their data from a sheet.

Parameters

sheet

string

Returns

JsColData[]


getColStyle()

getColStyle(sheet, col): number

Defined in: index.ts:557

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:502

Get whether a column is visible.

Parameters

sheet

string

col

string

Returns

boolean


getColWidth()

getColWidth(sheet, col): number | null

Defined in: index.ts:492

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:662

Get all comments on a sheet.

Parameters

sheet

string

Returns

JsCommentConfig[]


getConditionalFormats()

getConditionalFormats(sheet): JsConditionalFormatEntry[]

Defined in: index.ts:647

Get all conditional formatting rules for a sheet.

Parameters

sheet

string

Returns

JsConditionalFormatEntry[]


getCustomProperty()

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

Defined in: index.ts:761

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:632

Get all data validations on a sheet.

Parameters

sheet

string

Returns

JsDataValidationConfig[]


getDefinedName()

getDefinedName(name, scope?): JsDefinedNameInfo | null

Defined in: index.ts:1025

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:1030

Get all defined names in the workbook.

Returns

JsDefinedNameInfo[]


getDocProps()

getDocProps(): JsDocProperties

Defined in: index.ts:741

Get core document properties.

Returns

JsDocProperties


getFormat()

getFormat(): string

Defined in: index.ts:1194

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

Returns

string


getFormControls()

getFormControls(sheet): JsFormControlInfo[]

Defined in: index.ts:602

Get all form controls on a sheet.

Parameters

sheet

string

Returns

JsFormControlInfo[]


getHeaderFooter()

getHeaderFooter(sheet): JsHeaderFooter

Defined in: index.ts:830

Get the header and footer text for a sheet.

Parameters

sheet

string

Returns

JsHeaderFooter


getMergeCells()

getMergeCells(sheet): string[]

Defined in: index.ts:622

Get all merged cell ranges on a sheet.

Parameters

sheet

string

Returns

string[]


getPageBreaks()

getPageBreaks(sheet): number[]

Defined in: index.ts:855

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

Parameters

sheet

string

Returns

number[]


getPageMargins()

getPageMargins(sheet): JsPageMargins

Defined in: index.ts:806

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:816

Get the page setup for a sheet.

Parameters

sheet

string

Returns

JsPageSetup


getPanes()

getPanes(sheet): string | null

Defined in: index.ts:796

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:702

Get all persons in the person list.

Returns

JsPersonData[]


getPictureCells()

getPictureCells(sheet): string[]

Defined in: index.ts:592

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:587

Get all pictures anchored at the given cell.

Parameters

sheet

string

cell

string

Returns

JsPictureInfo[]


getPivotTables()

getPivotTables(): JsPivotTableInfo[]

Defined in: index.ts:950

Get all pivot tables in the workbook.

Returns

JsPivotTableInfo[]


getPrintOptions()

getPrintOptions(sheet): JsPrintOptions

Defined in: index.ts:840

Get print options for a sheet.

Parameters

sheet

string

Returns

JsPrintOptions


getRowHeight()

getRowHeight(sheet, row): number | null

Defined in: index.ts:462

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:482

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:875

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:881

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:890

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:909

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:900

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:547

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:472

Get whether a row is visible.

Parameters

sheet

string

row

number

Returns

boolean


getSheetIndex()

getSheetIndex(name): number | null

Defined in: index.ts:427

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:1204

Get sheet view options.

Parameters

sheet

string

Returns

JsSheetViewOptions


getSheetVisibility()

getSheetVisibility(sheet): string

Defined in: index.ts:1214

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

Parameters

sheet

string

Returns

string


getSlicers()

getSlicers(sheet): JsSlicerInfo[]

Defined in: index.ts:995

Get all slicers on a sheet.

Parameters

sheet

string

Returns

JsSlicerInfo[]


getSparklines()

getSparklines(sheet): JsSparklineConfig[]

Defined in: index.ts:965

Get all sparklines for a worksheet.

Parameters

sheet

string

Returns

JsSparklineConfig[]


getTables()

getTables(sheet): JsTableInfo[]

Defined in: index.ts:980

Get all tables on a sheet.

Parameters

sheet

string

Returns

JsTableInfo[]


getThemeColor()

getThemeColor(index, tint?): string | null

Defined in: index.ts:1015

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:677

Get all threaded comments on a sheet.

Parameters

sheet

string

Returns

JsThreadedCommentData[]


getThreadedCommentsByCell()

getThreadedCommentsByCell(sheet, cell): JsThreadedCommentData[]

Defined in: index.ts:682

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:1229

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:1224

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:517

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:845

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:442

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:1050

Check if a sheet is protected.

Parameters

sheet

string

Returns

boolean


isWorkbookProtected()

isWorkbookProtected(): boolean

Defined in: index.ts:781

Check if the workbook is protected.

Returns

boolean


mergeCells()

mergeCells(sheet, topLeft, bottomRight): void

Defined in: index.ts:612

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:407

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

Parameters

name

string

Returns

number


newStreamWriter()

newStreamWriter(sheetName): JsStreamWriter

Defined in: index.ts:717

Create a new stream writer for a new sheet.

Parameters

sheetName

string

Returns

JsStreamWriter


openSheetReader()

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

Defined in: index.ts:730

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:1040

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:771

Protect the workbook structure/windows with optional password.

Parameters

config

JsWorkbookProtectionConfig

Returns

void


removeAutoFilter()

removeAutoFilter(sheet): void

Defined in: index.ts:712

Remove the auto-filter from a sheet.

Parameters

sheet

string

Returns

void


removeCol()

removeCol(sheet, col): void

Defined in: index.ts:522

Remove a column by letter.

Parameters

sheet

string

col

string

Returns

void


removeComment()

removeComment(sheet, cell): void

Defined in: index.ts:667

Remove a comment from a cell.

Parameters

sheet

string

cell

string

Returns

void


removeDataValidation()

removeDataValidation(sheet, sqref): void

Defined in: index.ts:637

Remove a data validation by sqref.

Parameters

sheet

string

sqref

string

Returns

void


removePageBreak()

removePageBreak(sheet, row): void

Defined in: index.ts:850

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:447

Remove a row (1-based).

Parameters

sheet

string

row

number

Returns

void


removeSparkline()

removeSparkline(sheet, location): void

Defined in: index.ts:970

Remove a sparkline by its location cell reference.

Parameters

sheet

string

location

string

Returns

void


renderToSvg()

renderToSvg(options): string

Defined in: index.ts:1219

Render a worksheet to an SVG string.

Parameters

options

JsRenderOptions

Returns

string


resolveThreadedComment()

resolveThreadedComment(sheet, commentId, done): void

Defined in: index.ts:692

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:348

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:343

Save the workbook to a .xlsx file.

Parameters

path

string

Returns

void


saveWithPassword()

saveWithPassword(path, password): Promise<void>

Defined in: index.ts:368

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:363

Save the workbook as an encrypted .xlsx file.

Parameters

path

string

password

string

Returns

void


setActiveSheet()

setActiveSheet(name): void

Defined in: index.ts:437

Set the active sheet by name.

Parameters

name

string

Returns

void


setAppProps()

setAppProps(props): void

Defined in: index.ts:746

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

Parameters

props

JsAppProperties

Returns

void


setAutoFilter()

setAutoFilter(sheet, range): void

Defined in: index.ts:707

Set an auto-filter on a sheet.

Parameters

sheet

string

range

string

Returns

void


setCellFormula()

setCellFormula(sheet, cell, formula): void

Defined in: index.ts:925

Set a formula on a cell.

Parameters

sheet

string

cell

string

formula

string

Returns

void


setCellHyperlink(sheet, cell, opts): void

Defined in: index.ts:860

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:1005

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:537

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:383

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:388

Set multiple cell values at once.

Parameters

sheet

string

cells

JsCellEntry[]

Returns

void


setColOutlineLevel()

setColOutlineLevel(sheet, col, level): void

Defined in: index.ts:507

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:552

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:497

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:487

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:642

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:756

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:1020

Add or update a defined name.

Parameters

config

JsDefinedNameConfig

Returns

void


setDocProps()

setDocProps(props): void

Defined in: index.ts:736

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

Parameters

props

JsDocProperties

Returns

void


setHeaderFooter()

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

Defined in: index.ts:821

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:801

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:811

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:786

Set freeze panes on a sheet.

Parameters

sheet

string

cell

string

Returns

void


setPrintOptions()

setPrintOptions(sheet, opts): void

Defined in: index.ts:835

Set print options on a sheet.

Parameters

sheet

string

opts

JsPrintOptions

Returns

void


setRowHeight()

setRowHeight(sheet, row, height): void

Defined in: index.ts:457

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:477

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:542

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:393

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:467

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:398

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:915

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:417

Rename a sheet.

Parameters

oldName

string

newName

string

Returns

void


setSheetViewOptions()

setSheetViewOptions(sheet, opts): void

Defined in: index.ts:1199

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:1209

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

Parameters

sheet

string

visibility

string

Returns

void


toCSV()

toCSV(sheet, options?): string

Defined in: index.ts:1090

Convert sheet data to a CSV string.

Parameters

sheet

string

options?

ToCsvOptions

Returns

string


toHTML()

toHTML(sheet, options?): string

Defined in: index.ts:1130

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:1055

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:617

Remove a merged cell range from a sheet.

Parameters

sheet

string

reference

string

Returns

void


unprotectSheet()

unprotectSheet(sheet): void

Defined in: index.ts:1045

Remove sheet protection.

Parameters

sheet

string

Returns

void


unprotectWorkbook()

unprotectWorkbook(): void

Defined in: index.ts:776

Remove workbook protection.

Returns

void


unsetPanes()

unsetPanes(sheet): void

Defined in: index.ts:791

Remove any freeze or split panes from a sheet.

Parameters

sheet

string

Returns

void


writeBuffer()

writeBuffer(): Promise<Buffer<ArrayBufferLike>>

Defined in: index.ts:358

Serialize the workbook to an in-memory Buffer asynchronously.

Returns

Promise<Buffer<ArrayBufferLike>>


writeBufferSync()

writeBufferSync(): Buffer

Defined in: index.ts:353

Serialize the workbook to an in-memory Buffer.

Returns

Buffer


open()

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

Defined in: index.ts:304

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:320

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:312

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:296

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:333

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:328

Open an encrypted .xlsx file using a password.

Parameters

path

string

password

string

Returns

Workbook

Released under the MIT / Apache-2.0 License.