Workbook

Workbook

A workbook.

Constructor

new Workbook()

Source:

Members

formulaParser

Source:

Get formula parser instance.

Methods

activeSheet() → {Sheet}

Source:

Get the active sheet in the workbook.

Returns:

The active sheet.

Type
Sheet

activeSheet(sheet) → {Workbook}

Source:

Set the active sheet in the workbook.

Parameters:
Name Type Description
sheet Sheet | string | number

The sheet or name of sheet or index of sheet to activate. The sheet must not be hidden.

Returns:

The workbook.

Type
Workbook

addSheet(name, indexOrBeforeSheetopt) → {Sheet}

Source:

Add a new sheet to the workbook.

Parameters:
Name Type Attributes Description
name string

The name of the sheet. Must be unique, less than 31 characters, and may not contain the following characters: \ / * [ ] : ?

indexOrBeforeSheet number | string | Sheet <optional>

The index to move the sheet to or the sheet (or name of sheet) to move this sheet before. Omit this argument to move to the end of the workbook.

Returns:

The new sheet.

Type
Sheet

cloneSheet(from, name, indexOrBeforeSheetopt) → {Sheet}

Source:

Add a new sheet to the workbook.

WARN: this function has limits: if you clone a sheet with some images or other things link outside the Sheet object, these things in the cloned sheet will be locked when you open in MS Excel app.

Parameters:
Name Type Attributes Description
from Sheet

The sheet to be cloned.

name string

The name of the new sheet. Must be unique, less than 31 characters, and may not contain the following characters: \ / * [ ] : ?

indexOrBeforeSheet number | string | Sheet <optional>

The index to move the sheet to or the sheet (or name of sheet) to move this sheet before. Omit this argument to move to the end of the workbook.

Returns:

The new sheet.

Type
Sheet

definedName(name, refersTo) → {Workbook}

Source:

Set a defined name scoped to the workbook.

Parameters:
Name Type Description
name string

The defined name.

refersTo string | Cell | Range | Row | Column

What the name refers to.

Returns:

The workbook.

Type
Workbook

deleteSheet(sheet) → {Workbook}

Source:

Delete a sheet from the workbook.

Parameters:
Name Type Description
sheet Sheet | string | number

The sheet or name of sheet or index of sheet to move.

Returns:

The workbook.

Type
Workbook

find(pattern, replacementopt) → {boolean}

Source:

Find the given pattern in the workbook and optionally replace it.

Parameters:
Name Type Attributes Description
pattern string | RegExp

The pattern to look for. Providing a string will result in a case-insensitive substring search. Use a RegExp for more sophisticated searches.

replacement string | function <optional>

The text to replace or a String.replace callback function. If pattern is a string, all occurrences of the pattern in each cell will be replaced.

Returns:

A flag indicating if the pattern was found.

Type
boolean

getSheetRIdByName(sheetName) → {undefined|number}

Source:

Return the number in r:id by sheet name defined in workbook.xml

Parameters:
Name Type Description
sheetName string

Sheet name.

Returns:

Sheet Id.

Type
undefined | number

moveSheet(sheet, indexOrBeforeSheetopt) → {Workbook}

Source:

Move a sheet to a new position.

Parameters:
Name Type Attributes Description
sheet Sheet | string | number

The sheet or name of sheet or index of sheet to move.

indexOrBeforeSheet number | string | Sheet <optional>

The index to move the sheet to or the sheet (or name of sheet) to move this sheet before. Omit this argument to move to the end of the workbook.

Returns:

The workbook.

Type
Workbook

outputAsync(optsopt) → {string|Uint8Array|ArrayBuffer|Blob|Buffer}

Source:

Generates the workbook output.

Parameters:
Name Type Attributes Description
opts Object <optional>

Options

Properties
Name Type Attributes Description
type string <optional>

The type of the data to return: base64, binarystring, uint8array, arraybuffer, blob, nodebuffer. Defaults to 'nodebuffer' in Node.js and 'blob' in browsers.

password string <optional>

The password to use to encrypt the workbook.

Returns:

The data.

Type
string | Uint8Array | ArrayBuffer | Blob | Buffer

properties() → {CoreProperties}

Source:

Get access to core properties object

Returns:

The core properties.

Type
CoreProperties

property(name) → {*}

Source:

Gets an individual property.

Parameters:
Name Type Description
name string

The name of the property.

Returns:

The property.

Type
*

property(names) → {object.<string, *>}

Source:

Gets multiple properties.

Parameters:
Name Type Description
names Array.<string>

The names of the properties.

Returns:

Object whose keys are the property names and values are the properties.

Type
object.<string, *>

property(name, value) → {Workbook}

Source:

Sets an individual property.

Parameters:
Name Type Description
name string

The name of the property.

value *

The value to set.

Returns:

The workbook.

Type
Workbook

property(properties) → {Workbook}

Source:

Sets multiple properties.

Parameters:
Name Type Description
properties object.<string, *>

Object whose keys are the property names and values are the values to set.

Returns:

The workbook.

Type
Workbook

sheet(sheetNameOrIndex) → {Sheet|undefined}

Source:

Gets the sheet with the provided name or index (0-based).

Parameters:
Name Type Description
sheetNameOrIndex string | number

The sheet name or index.

Returns:

The sheet or undefined if not found.

Type
Sheet | undefined

sheets() → {Array.<Sheet>}

Source:

Get an array of all the sheets in the workbook.

Returns:

The sheets.

Type
Array.<Sheet>

theme() → {Theme}

Source:

Get the theme of this workbook.

Returns:

The theme object.

Type
Theme

toFileAsync(path, optsopt) → {Promise.<undefined>}

Source:

Write the workbook to file. (Not supported in browsers.)

Parameters:
Name Type Attributes Description
path string

The path of the file to write.

opts Object <optional>

Options

Properties
Name Type Attributes Description
password string <optional>

The password to encrypt the workbook.

Returns:

A promise.

Type
Promise.<undefined>