Workbook

Workbook class

Represents a root object to create an Excel spreadsheet.

class Workbook;

Remarks

The Workbook class denotes an Excel spreadsheet. Each spreadsheet can contain multiple worksheets. The basic feature of the class is to open and save native excel files. The class has some advanced features like copying data from other Workbooks, combining two Workbooks, converting Excel to PDF, rendering Excel to image and protecting the Excel spreadsheet.

Example

The following example creates a Workbook, opens a file named designer.xls in it and makes the horizontal and vertical scroll bars invisible for the Workbook. It then replaces two string values with an Integer value and string value respectively within the spreadsheet and finally save it to file named result.xls.

const { Workbook, XlsSaveOptions } = require("aspose.cells.node");

//Open a xls file
var workbook = new Workbook("input/Book1.xls");

//Set scroll bars
workbook.getSettings().setIsHScrollBarVisible(false);
workbook.getSettings().setIsVScrollBarVisible(false);

//Replace the placeholder string with new values
workbook.replace("OldInt", 100);

var newString = "Hello world";
workbook.replace("OldString", newString);
var saveOptions = new XlsSaveOptions();
workbook.save("output/result.xls", saveOptions);

Constructors

NameDescription
constructor()Initializes a new instance of the Workbook class.
constructor(FileFormatType)Initializes a new instance of the Workbook class.
constructor(string)Initializes a new instance of the Workbook class and open a file.
constructor(Uint8Array)Initializes a new instance of the Workbook class and open a stream.
constructor(string, LoadOptions)Initializes a new instance of the Workbook class and open a file.
constructor(Uint8Array, LoadOptions)Initializes a new instance of the Workbook class and open stream.

Methods

MethodDescription
getSettings()Represents the workbook settings.
getWorksheets()Gets the WorksheetCollection collection in the spreadsheet.
isLicensed()Indicates whether license is set.
getColors()Returns colors in the palette for the spreadsheet.
getCountOfStylesInPool()Gets number of the styles in the style pool.
getDefaultStyle()Gets or sets the default Style object of the workbook.
setDefaultStyle(Style)Gets or sets the default Style object of the workbook.
isDigitallySigned()Indicates if this spreadsheet is digitally signed.
isWorkbookProtectedWithPassword()Indicates whether structure or window is protected with password.
getVbaProject()Gets the VbaProject in a spreadsheet.
getHasMacro()Indicates if this spreadsheet contains macro/VBA.
getHasRevisions()Gets if the workbook has any tracked changes
getFileName()Gets and sets the current file name.
setFileName(string)Gets and sets the current file name.
getDataSorter()Gets a DataSorter object to sort data.
getTheme()Gets the theme name.
getBuiltInDocumentProperties()Returns a DocumentProperty collection that represents all the built-in document properties of the spreadsheet.
getCustomDocumentProperties()Returns a DocumentProperty collection that represents all the custom document properties of the spreadsheet.
getFileFormat()Gets and sets the file format.
setFileFormat(FileFormatType)Gets and sets the file format.
getInterruptMonitor()Gets and sets the interrupt monitor.
setInterruptMonitor(AbstractInterruptMonitor)Gets and sets the interrupt monitor.
getContentTypeProperties()Gets the list of ContentTypeProperty objects in the workbook.
getCustomXmlParts()Represents a Custom XML Data Storage Part (custom XML data within a package).
getDataMashup()Gets mashup data.
getRibbonXml()Gets and sets the XML file that defines the Ribbon UI.
setRibbonXml(string)Gets and sets the XML file that defines the Ribbon UI.
getAbsolutePath()Gets and sets the absolute path of the file.
setAbsolutePath(string)Gets and sets the absolute path of the file.
getDataConnections()Gets the ExternalConnection collection.
getDataModel()Gets data model in the workbook.
parseFormulas(boolean)Parses all formulas which have not been parsed when they were loaded from template file or set to a cell.
startAccessCache(AccessCacheOptions)Starts the session that uses caches to access data.
closeAccessCache(AccessCacheOptions)Closes the session that uses caches to access data.
save(string, SaveFormat)Saves the workbook to the disk.
save(string)Save the workbook to the disk.
save(string, SaveOptions)Saves the workbook to the disk.
save(SaveFormat)Saves the workbook to the stream.
save(SaveOptions)Saves the workbook to the stream.
saveToStream()Saves Excel file to a MemoryStream object and returns it.
removeUnusedStyles()Remove all unused styles.
createStyle()Creates a new style.
createBuiltinStyle(BuiltinStyleType)Creates built-in style by given type.
createCellsColor()Creates a CellsColor object.
replace(string, string)Replaces a cell’s value with a new string.
replace(string, number)Replaces a cell’s value with a new integer.
replace(string, number)Replaces a cell’s value with a new double.
replace(string, string[], boolean)Replaces a cell’s value with a new string array.
replace(string, number[], boolean)Replaces cells’ values with an integer array.
replace(string, number[], boolean)Replaces cells’ values with a double array.
replace(boolean, object)Replaces cells’ values with new data.
replace(number, object)Replaces cells’ values with new data.
replace(string, string, ReplaceOptions)Replaces a cell’s value with a new string.
copy(Workbook, CopyOptions)Copies another Workbook object.
copy(Workbook)Copies data from a source Workbook object.
combine(Workbook)Combines another Workbook object.
getStyleInPool(number)Gets the style in the style pool. All styles in the workbook will be gathered into a pool. There is only a simple reference index in the cells.
getFonts()Gets all fonts in the style pool.
getNamedStyle(string)Gets the named style in the style pool.
changePalette(Color, number)Changes the palette for the spreadsheet in the specified index.
isColorInPalette(Color)Checks if a color is in the palette for the spreadsheet.
calculateFormula()Calculates the result of formulas.
calculateFormula(boolean)Calculates the result of formulas.
calculateFormula(CalculationOptions)Calculating formulas in this workbook.
refreshDynamicArrayFormulas(boolean)Refreshes dynamic array formulas(spill into new range of neighboring cells according to current data) Other formulas in the workbook will not be calculated recursively even if they were used by dynamic array formulas.
refreshDynamicArrayFormulas(boolean, CalculationOptions)Refreshes dynamic array formulas(spill into new range of neighboring cells according to current data)
getMatchingColor(Color)Find best matching Color in current palette.
setEncryptionOptions(EncryptionType, number)Set Encryption Options.
protect(ProtectionType, string)Protects a workbook.
protectSharedWorkbook(string)Protects a shared workbook.
unprotect(string)Unprotects a workbook.
unprotectSharedWorkbook(string)Unprotects a shared workbook.
removeMacro()Removes VBA/macro from this spreadsheet.
removeDigitalSignature()Removes digital signature from this spreadsheet.
acceptAllRevisions()Accepts all tracked changes in the workbook.
getThemeColor(ThemeColorType)Gets theme color.
setThemeColor(ThemeColorType, Color)Sets the theme color
customTheme(string, Color[])Customs the theme.
copyTheme(Workbook)Copies the theme from another workbook.
updateCustomFunctionDefinition(CustomFunctionDefinition)Updates definition of custom functions.
updateLinkedDataSource(Workbook[])If this workbook contains external links to other data source, Aspose.Cells will attempt to retrieve the latest data from give sources.
setInterruptMonitor(InterruptMonitor)Sets the interrupt monitor.
importXml(string, string, number, number)Imports/Updates an XML data file into the workbook.
importXml(Uint8Array, string, number, number)Imports/Updates an XML data file into the workbook.
exportXml(string, string)Export XML data linked by the specified XML map.
exportXml(string)Export XML data.
setDigitalSignature(DigitalSignatureCollection)Sets digital signature to an spreadsheet file (Excel2007 and later).
addDigitalSignature(DigitalSignatureCollection)Adds digital signature to an OOXML spreadsheet file (Excel2007 and later).
getDigitalSignature()Gets digital signature from file.
removePersonalInformation()Removes personal information.
dispose()Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
isNull()Checks whether the implementation object is null.

constructor()

Initializes a new instance of the Workbook class.

constructor();

Remarks

The default file format type is Xlsx. If you want to create other types of files, please use Workbook(FileFormatType).

Example

The following code shows how to use the Workbook constructor to create and initialize a new instance of the class.

const { Workbook } = require("aspose.cells.node");

var workbook = new Workbook();

constructor(FileFormatType)

Initializes a new instance of the Workbook class.

constructor(fileFormatType: FileFormatType);

Parameters:

ParameterTypeDescription
fileFormatTypeFileFormatTypeThe new file format.

Remarks

The default file format type is Excel97To2003.

Example

The following code shows how to use the Workbook constructor to create and initialize a new instance of the class.

const { Workbook, FileFormatType } = require("aspose.cells.node");

var workbook = new Workbook(FileFormatType.Xlsx);

constructor(string)

Initializes a new instance of the Workbook class and open a file.

constructor(file: string);

Parameters:

ParameterTypeDescription
filestringThe file name.

constructor(Uint8Array)

Initializes a new instance of the Workbook class and open a stream.

constructor(stream: Uint8Array);

Parameters:

ParameterTypeDescription
streamUint8ArrayThe stream.

constructor(string, LoadOptions)

Initializes a new instance of the Workbook class and open a file.

constructor(file: string, loadOptions: LoadOptions);

Parameters:

ParameterTypeDescription
filestringThe file name.
loadOptionsLoadOptionsThe load options

constructor(Uint8Array, LoadOptions)

Initializes a new instance of the Workbook class and open stream.

constructor(stream: Uint8Array, loadOptions: LoadOptions);

Parameters:

ParameterTypeDescription
streamUint8ArrayThe stream.
loadOptionsLoadOptionsThe load options

getSettings()

Represents the workbook settings.

getSettings() : WorkbookSettings;

Returns

WorkbookSettings

getWorksheets()

Gets the WorksheetCollection collection in the spreadsheet.

getWorksheets() : WorksheetCollection;

Returns

WorksheetCollection collection

isLicensed()

Indicates whether license is set.

isLicensed() : boolean;

getColors()

Returns colors in the palette for the spreadsheet.

getColors() : Color[];

Returns

Color[]

Remarks

The palette has 56 entries, each represented by an RGB value.

getCountOfStylesInPool()

Gets number of the styles in the style pool.

getCountOfStylesInPool() : number;

getDefaultStyle()

Gets or sets the default Style object of the workbook.

getDefaultStyle() : Style;

Returns

Style

Remarks

The DefaultStyle property is useful to implement a Style for the whole Workbook.

setDefaultStyle(Style)

Gets or sets the default Style object of the workbook.

setDefaultStyle(value: Style) : void;

Parameters:

ParameterTypeDescription
valueStyleThe value to set.

Remarks

The DefaultStyle property is useful to implement a Style for the whole Workbook.

Example

The following code creates and instantiates a new Workbook and sets a default Style to it.

const { Workbook } = require("aspose.cells.node");

var workbook = new Workbook();
var defaultStyle = workbook.getDefaultStyle();
defaultStyle.getFont().setName("Tahoma");
workbook.setDefaultStyle(defaultStyle);

isDigitallySigned()

Indicates if this spreadsheet is digitally signed.

isDigitallySigned() : boolean;

isWorkbookProtectedWithPassword()

Indicates whether structure or window is protected with password.

isWorkbookProtectedWithPassword() : boolean;

getVbaProject()

Gets the VbaProject in a spreadsheet.

getVbaProject() : VbaProject;

Returns

VbaProject

getHasMacro()

Indicates if this spreadsheet contains macro/VBA.

getHasMacro() : boolean;

getHasRevisions()

Gets if the workbook has any tracked changes

getHasRevisions() : boolean;

getFileName()

Gets and sets the current file name.

getFileName() : string;

Remarks

If the file is opened by stream and there are some external formula references, please set the file name.

setFileName(string)

Gets and sets the current file name.

setFileName(value: string) : void;

Parameters:

ParameterTypeDescription
valuestringThe value to set.

Remarks

If the file is opened by stream and there are some external formula references, please set the file name.

getDataSorter()

Gets a DataSorter object to sort data.

getDataSorter() : DataSorter;

Returns

DataSorter

getTheme()

Gets the theme name.

getTheme() : string;

getBuiltInDocumentProperties()

Returns a DocumentProperty collection that represents all the built-in document properties of the spreadsheet.

getBuiltInDocumentProperties() : BuiltInDocumentPropertyCollection;

Returns

BuiltInDocumentPropertyCollection

Remarks

A new property cannot be added to built-in document properties list. You can only get a built-in property and change its value. The following is the built-in properties name list:

Title

Subject

Author

Keywords

Comments

Template

Last Author

Revision Number

Application Name

Last Print Date

Creation Date

Last Save Time

Total Editing Time

Number of Pages

Number of Words

Number of Characters

Security

Category

Format

Manager

Company

Number of Bytes

Number of Lines

Number of Paragraphs

Number of Slides

Number of Notes

Number of Hidden Slides

Number of Multimedia Clips

Example

const { Workbook } = require("aspose.cells.node");

var workbook = new Workbook();
var doc = workbook.getBuiltInDocumentProperties().get("Author");
doc.setValue("John Smith");

getCustomDocumentProperties()

Returns a DocumentProperty collection that represents all the custom document properties of the spreadsheet.

getCustomDocumentProperties() : CustomDocumentPropertyCollection;

Returns

CustomDocumentPropertyCollection

Example

const { Workbook } = require("aspose.cells.node");

var excel = new Workbook();
excel.getCustomDocumentProperties().add("Checked by", "Jane");

getFileFormat()

Gets and sets the file format.

getFileFormat() : FileFormatType;

Returns

FileFormatType

setFileFormat(FileFormatType)

Gets and sets the file format.

setFileFormat(value: FileFormatType) : void;

Parameters:

ParameterTypeDescription
valueFileFormatTypeThe value to set.

getInterruptMonitor()

Gets and sets the interrupt monitor.

getInterruptMonitor() : AbstractInterruptMonitor;

Returns

AbstractInterruptMonitor

setInterruptMonitor(AbstractInterruptMonitor)

Gets and sets the interrupt monitor.

setInterruptMonitor(value: AbstractInterruptMonitor) : void;

Parameters:

ParameterTypeDescription
valueAbstractInterruptMonitorThe value to set.

getContentTypeProperties()

Gets the list of ContentTypeProperty objects in the workbook.

getContentTypeProperties() : ContentTypePropertyCollection;

Returns

ContentTypePropertyCollection

getCustomXmlParts()

Represents a Custom XML Data Storage Part (custom XML data within a package).

getCustomXmlParts() : CustomXmlPartCollection;

Returns

CustomXmlPartCollection

getDataMashup()

Gets mashup data.

getDataMashup() : DataMashup;

Returns

DataMashup

getRibbonXml()

Gets and sets the XML file that defines the Ribbon UI.

getRibbonXml() : string;

setRibbonXml(string)

Gets and sets the XML file that defines the Ribbon UI.

setRibbonXml(value: string) : void;

Parameters:

ParameterTypeDescription
valuestringThe value to set.

getAbsolutePath()

Gets and sets the absolute path of the file.

getAbsolutePath() : string;

Remarks

Only used for external links.

setAbsolutePath(string)

Gets and sets the absolute path of the file.

setAbsolutePath(value: string) : void;

Parameters:

ParameterTypeDescription
valuestringThe value to set.

Remarks

Only used for external links.

getDataConnections()

Gets the ExternalConnection collection.

getDataConnections() : ExternalConnectionCollection;

Returns

ExternalConnectionCollection

getDataModel()

Gets data model in the workbook.

getDataModel() : DataModel;

Returns

DataModel

parseFormulas(boolean)

Parses all formulas which have not been parsed when they were loaded from template file or set to a cell.

parseFormulas(ignoreError: boolean) : void;

Parameters:

ParameterTypeDescription
ignoreErrorbooleanWhether ignore error for invalid formula. /// For one invalid formula, if ignore error then this formula will be ignored /// and the process will continue to parse other formulas, otherwise exception will be thrown.

startAccessCache(AccessCacheOptions)

Starts the session that uses caches to access data.

startAccessCache(opts: AccessCacheOptions) : void;

Parameters:

ParameterTypeDescription
optsAccessCacheOptionsoptions of data access

Remarks

If the cache of specified data access requires some data models in worksheet to be “read-only”, then corresponding data models in every worksheet in this workbook will be taken as “read-only” and user should not change any of them.

After finishing the access to the data, CloseAccessCache(AccessCacheOptions) should be invoked with same options to clear all caches and recover normal access mode.
</br

closeAccessCache(AccessCacheOptions)

Closes the session that uses caches to access data.

closeAccessCache(opts: AccessCacheOptions) : void;

Parameters:

ParameterTypeDescription
optsAccessCacheOptionsoptions of data access

save(string, SaveFormat)

Saves the workbook to the disk.

save(fileName: string, saveFormat: SaveFormat) : void;

Parameters:

ParameterTypeDescription
fileNamestringThe file name.
saveFormatSaveFormatThe save format type.

Example

const { Workbook, SaveFormat } = require("aspose.cells.node");

var workbook = new Workbook();
var sheets = workbook.getWorksheets();
var cells = sheets.get(0).getCells();
cells.get("A1").putValue("Hello world!");
workbook.save("output/WorkbookSaveFileFormatType.xls", SaveFormat.Excel97To2003);

save(string)

Save the workbook to the disk.

save(fileName: string) : void;

Parameters:

ParameterTypeDescription
fileNamestring

save(string, SaveOptions)

Saves the workbook to the disk.

save(fileName: string, saveOptions: SaveOptions) : void;

Parameters:

ParameterTypeDescription
fileNamestringThe file name.
saveOptionsSaveOptionsThe save options.

save(SaveFormat)

Saves the workbook to the stream.

save(saveFormat: SaveFormat) : Uint8Array;

Parameters:

ParameterTypeDescription
saveFormatSaveFormatThe save file format type.

Returns

The result stream

save(SaveOptions)

Saves the workbook to the stream.

save(saveOptions: SaveOptions) : Uint8Array;

Parameters:

ParameterTypeDescription
saveOptionsSaveOptionsThe save options.

Returns

The result stream

saveToStream()

Saves Excel file to a MemoryStream object and returns it.

saveToStream() : Uint8Array;

Returns

MemoryStream object which contains an Excel file.

Remarks

This method provides same function as Save method and only save the workbook as Excel97-2003 xls file. It’s mainly for calling from COM clients.

removeUnusedStyles()

Remove all unused styles.

removeUnusedStyles() : void;

createStyle()

Creates a new style.

createStyle() : Style;

Returns

Returns a style object.

createBuiltinStyle(BuiltinStyleType)

Creates built-in style by given type.

createBuiltinStyle(type: BuiltinStyleType) : Style;

Parameters:

ParameterTypeDescription
typeBuiltinStyleTypeThe builtin style stype.

Returns

Style object

createCellsColor()

Creates a CellsColor object.

createCellsColor() : CellsColor;

Returns

Returns a CellsColor object.

replace(string, string)

Replaces a cell’s value with a new string.

replace(placeHolder: string, newValue: string) : number;

Parameters:

ParameterTypeDescription
placeHolderstringCell placeholder
newValuestringString value to replace

Example

const { Workbook } = require("aspose.cells.node");

var workbook = new Workbook();
workbook.replace("AnOldValue", "NewValue");

replace(string, number)

Replaces a cell’s value with a new integer.

replace(placeHolder: string, newValue: number) : number;

Parameters:

ParameterTypeDescription
placeHolderstringCell placeholder
newValuenumberInteger value to replace

Example

const { Workbook } = require("aspose.cells.node");

var workbook = new Workbook();
var newValue = 100;
workbook.replace("AnOldValue", newValue);

replace(string, number)

Replaces a cell’s value with a new double.

replace(placeHolder: string, newValue: number) : number;

Parameters:

ParameterTypeDescription
placeHolderstringCell placeholder
newValuenumberDouble value to replace

Example

const { Workbook } = require("aspose.cells.node");

var workbook = new Workbook();
var newValue = 100.0;
workbook.replace("AnOldValue", newValue);

replace(string, string[], boolean)

Replaces a cell’s value with a new string array.

replace(placeHolder: string, newValues: string[], isVertical: boolean) : number;

Parameters:

ParameterTypeDescription
placeHolderstringCell placeholder
newValuesstring[]String array to replace
isVerticalbooleanTrue - Vertical, False - Horizontal

Example

const { Workbook } = require("aspose.cells.node");

var workbook = new Workbook("input/Replace.xls");
var newValues = ["Tom", "Alice", "Jerry"];
workbook.replace("AnOldValue", newValues, true);

workbook.save("output/ReplaceResult1.xls");

replace(string, number[], boolean)

Replaces cells’ values with an integer array.

replace(placeHolder: string, newValues: number[], isVertical: boolean) : number;

Parameters:

ParameterTypeDescription
placeHolderstringCell placeholder
newValuesnumber[]Integer array to replace
isVerticalbooleanTrue - Vertical, False - Horizontal

Example

const { Workbook } = require("aspose.cells.node");

var workbook = new Workbook("input/Replace.xls");
var newValues = [1, 2, 3];
workbook.replace("AnOldValue", newValues, true);

workbook.save("output/ReplaceResult2.xls");

replace(string, number[], boolean)

Replaces cells’ values with a double array.

replace(placeHolder: string, newValues: number[], isVertical: boolean) : number;

Parameters:

ParameterTypeDescription
placeHolderstringCell placeholder
newValuesnumber[]Double array to replace
isVerticalbooleanTrue - Vertical, False - Horizontal

Example

const { Workbook } = require("aspose.cells.node");

var workbook = new Workbook("input/Replace.xls");
var newValues = [1.23, 2.56, 3.14159];
workbook.replace("AnOldValue", newValues, true);

workbook.save("output/ReplaceResult3.xls");

replace(boolean, object)

Replaces cells’ values with new data.

replace(boolValue: boolean, newValue: object) : number;

Parameters:

ParameterTypeDescription
boolValuebooleanThe boolean value to be replaced.
newValueobjectNew value. Can be string, integer, double or DateTime value.

replace(number, object)

Replaces cells’ values with new data.

replace(intValue: number, newValue: object) : number;

Parameters:

ParameterTypeDescription
intValuenumberThe integer value to be replaced.
newValueobjectNew value. Can be string, integer, double or DateTime value.

replace(string, string, ReplaceOptions)

Replaces a cell’s value with a new string.

replace(placeHolder: string, newValue: string, options: ReplaceOptions) : number;

Parameters:

ParameterTypeDescription
placeHolderstringCell placeholder
newValuestringString value to replace
optionsReplaceOptionsThe replace options

copy(Workbook, CopyOptions)

Copies another Workbook object.

copy(source: Workbook, copyOptions: CopyOptions) : void;

Parameters:

ParameterTypeDescription
sourceWorkbookSource Workbook object.
copyOptionsCopyOptionsThe options of copying other workbook.

Remarks

It’s very simple to clone an Excel file.

copy(Workbook)

Copies data from a source Workbook object.

copy(source: Workbook) : void;

Parameters:

ParameterTypeDescription
sourceWorkbookSource Workbook object.

combine(Workbook)

Combines another Workbook object.

combine(secondWorkbook: Workbook) : void;

Parameters:

ParameterTypeDescription
secondWorkbookWorkbookAnother Workbook object.

Remarks

Merge Excel, ODS , CSV and other files to one file.

getStyleInPool(number)

Gets the style in the style pool. All styles in the workbook will be gathered into a pool. There is only a simple reference index in the cells.

getStyleInPool(index: number) : Style;

Parameters:

ParameterTypeDescription
indexnumberThe index.

Returns

The style in the pool corresponds to given index, may be null.

Remarks

If the returned style is changed, the style of all cells(which refers to this style) will be changed.

getFonts()

Gets all fonts in the style pool.

getFonts() : Font[];

Returns

Font[]

getNamedStyle(string)

Gets the named style in the style pool.

getNamedStyle(name: string) : Style;

Parameters:

ParameterTypeDescription
namestringname of the style

Returns

named style, maybe null.

changePalette(Color, number)

Changes the palette for the spreadsheet in the specified index.

changePalette(color: Color, index: number) : void;

Parameters:

ParameterTypeDescription
colorColorColor structure.
indexnumberPalette index, 0 - 55.

Remarks

The palette has 56 entries, each represented by an RGB value.

If you set a color which is not in the palette, it will not take effect.

So if you want to set a custom color, please change the palette at first.

The following is the standard color palette.

Color Red Green Blue Black 0 0 0 White 255 255 255 Red 255 0 0 Lime 0 255 0 Blue 0 0 255 Yellow 255 255 0 Magenta 255 0 255 Cyan 0 255 255 Maroon 128 0 0 Green 0 128 0 Navy 0 0 128 Olive 128 128 0 Purple 128 0 128 Teal 0 128 128 Silver 192 192 192 Gray 128 128 128 Color17 153 153 255 Color18 153 51 102 Color19 255 255 204 Color20 204 255 255 Color21 102 0 102 Color22 255 128 128 Color23 0 102 204 Color24 204 204 255 Color25 0 0 128 Color26 255 0 255 Color27 255 255 0 Color28 0 255 255 Color29 128 0 128 Color30 128 0 0 Color31 0 128 128 Color32 0 0 255 Color33 0 204 255 Color34 204 255 255 Color35 204 255 204 Color36 255 255 153 Color37 153 204 255 Color38 255 153 204 Color39 204 153 255 Color40 255 204 153 Color41 51 102 255 Color42 51 204 204 Color43 153 204 0 Color44 255 204 0 Color45 255 153 0 Color46 255 102 0 Color47 102 102 153 Color48 150 150 150 Color49 0 51 102 Color50 51 153 102 Color51 0 51 0 Color52 51 51 0 Color53 153 51 0 Color54 153 51 102 Color55 51 51 153 Color56 51 51 51 </list

isColorInPalette(Color)

Checks if a color is in the palette for the spreadsheet.

isColorInPalette(color: Color) : boolean;

Parameters:

ParameterTypeDescription
colorColorColor structure.

Returns

Returns true if this color is in the palette. Otherwise, returns false

calculateFormula()

Calculates the result of formulas.

calculateFormula() : void;

Remarks

For all supported formulas, please see the list at https://docs.aspose.com/display/cellsnet/Supported+Formula+Functions

calculateFormula(boolean)

Calculates the result of formulas.

calculateFormula(ignoreError: boolean) : void;

Parameters:

ParameterTypeDescription
ignoreErrorbooleanIndicates if hide the error in calculating formulas. The error may be unsupported function, external links, etc.

calculateFormula(CalculationOptions)

Calculating formulas in this workbook.

calculateFormula(options: CalculationOptions) : void;

Parameters:

ParameterTypeDescription
optionsCalculationOptionsOptions for calculation

refreshDynamicArrayFormulas(boolean)

Refreshes dynamic array formulas(spill into new range of neighboring cells according to current data) Other formulas in the workbook will not be calculated recursively even if they were used by dynamic array formulas.

refreshDynamicArrayFormulas(calculate: boolean) : void;

Parameters:

ParameterTypeDescription
calculatebooleanWhether calculates and updates cell values for those dynamic array formulas

refreshDynamicArrayFormulas(boolean, CalculationOptions)

Refreshes dynamic array formulas(spill into new range of neighboring cells according to current data)

refreshDynamicArrayFormulas(calculate: boolean, copts: CalculationOptions) : void;

Parameters:

ParameterTypeDescription
calculatebooleanWhether calculates and updates cell values for those dynamic array formulas
coptsCalculationOptionsThe options for calculating formulas

Remarks

For performance consideration, we do not refresh all dynamic array formulas automatically when the formula itself or the data it references to changed. So user need to call this method manually after those operations which may influence dynamic array formulas, such as importing/setting cell values, inserting/deleting rows/columns/ranges, …etc.

For most formulas with functions, calculating the spill range also needs to calculating the formula, so in general true value for “calculate” flag is preferred. If the formula is simple, such as a range reference or array(for example “=C1:E5”, “={1,2;3,4}”, …), simple function on a range or array(for example “=ABS(C1:E5)”, “=1+{1,2;3,4}”, …), and all formulas will be calculated later(such as by Workbook.CalculateFormula(CalculationOptions)), then using false vlaue for “calculate” flag may avoid the duplicated calculation for the benefit of performance.

getMatchingColor(Color)

Find best matching Color in current palette.

getMatchingColor(rawColor: Color) : Color;

Parameters:

ParameterTypeDescription
rawColorColorRaw color.

Returns

Best matching color.

setEncryptionOptions(EncryptionType, number)

Set Encryption Options.

setEncryptionOptions(encryptionType: EncryptionType, keyLength: number) : void;

Parameters:

ParameterTypeDescription
encryptionTypeEncryptionTypeThe encryption type.
keyLengthnumberThe key length.

protect(ProtectionType, string)

Protects a workbook.

protect(protectionType: ProtectionType, password: string) : void;

Parameters:

ParameterTypeDescription
protectionTypeProtectionTypeProtection type.
passwordstringPassword to protect the workbook.

protectSharedWorkbook(string)

Protects a shared workbook.

protectSharedWorkbook(password: string) : void;

Parameters:

ParameterTypeDescription
passwordstringPassword to protect the workbook.

unprotect(string)

Unprotects a workbook.

unprotect(password: string) : void;

Parameters:

ParameterTypeDescription
passwordstringPassword to unprotect the workbook.

unprotectSharedWorkbook(string)

Unprotects a shared workbook.

unprotectSharedWorkbook(password: string) : void;

Parameters:

ParameterTypeDescription
passwordstringPassword to unprotect the workbook.

removeMacro()

Removes VBA/macro from this spreadsheet.

removeMacro() : void;

removeDigitalSignature()

Removes digital signature from this spreadsheet.

removeDigitalSignature() : void;

acceptAllRevisions()

Accepts all tracked changes in the workbook.

acceptAllRevisions() : void;

getThemeColor(ThemeColorType)

Gets theme color.

getThemeColor(type: ThemeColorType) : Color;

Parameters:

ParameterTypeDescription
typeThemeColorTypeThe theme color type.

Returns

The theme color.

setThemeColor(ThemeColorType, Color)

Sets the theme color

setThemeColor(type: ThemeColorType, color: Color) : void;

Parameters:

ParameterTypeDescription
typeThemeColorTypeThe theme color type.
colorColorthe theme color

customTheme(string, Color[])

Customs the theme.

customTheme(themeName: string, colors: Color[]) : void;

Parameters:

ParameterTypeDescription
themeNamestringThe theme name
colorsColor[]The theme colors

Remarks

The length of colors should be 12. Array index Theme type 0 Backgournd1 1 Text1 2 Backgournd2 3 Text2 4 Accent1 5 Accent2 6 Accent3 7 Accent4 8 Accent5 9 Accent6 10 Hyperlink 11 Followed Hyperlink </list

copyTheme(Workbook)

Copies the theme from another workbook.

copyTheme(source: Workbook) : void;

Parameters:

ParameterTypeDescription
sourceWorkbookSource workbook.

updateCustomFunctionDefinition(CustomFunctionDefinition)

Updates definition of custom functions.

updateCustomFunctionDefinition(definition: CustomFunctionDefinition) : void;

Parameters:

ParameterTypeDescription
definitionCustomFunctionDefinitionSpecial definition of custom functions for user’s special requirement.

Remarks

This method can be used for some special scenarios. For example, if user needs some parameters of some custom functions be calculated in array mode, then user may provide their own definition with implemented CustomFunctionDefinition.GetArrayModeParameters(string) for those functions. After the data of formulas being updated, those specified parameters will be calculated in array mode automatically when calculating corresponding custom functions.

updateLinkedDataSource(Workbook[])

If this workbook contains external links to other data source, Aspose.Cells will attempt to retrieve the latest data from give sources.

updateLinkedDataSource(externalWorkbooks: Workbook[]) : void;

Parameters:

ParameterTypeDescription
externalWorkbooksWorkbook[]Workbooks that will be used to update data of external links referenced by this workbook. /// The match of those workbooks with external links is determined by Workbook.FileName /// and ExternalLink.DataSource. So please make sure Workbook.FileName has /// been specified with the proper value for every workbook so they can be linked to corresponding external link.

Remarks

If corresponding external link cannot be found for one workbook, then this workbook will be ignored. So when you set a formula later with one new external link which you intend to make the ignored workbook be linked to it, the link cannot be performed until you call this this method again with those workbooks.

setInterruptMonitor(InterruptMonitor)

Sets the interrupt monitor.

setInterruptMonitor(interruptMonitor: InterruptMonitor) : void;

Parameters:

ParameterTypeDescription
interruptMonitorInterruptMonitorAn InterruptMonitor object.

importXml(string, string, number, number)

Imports/Updates an XML data file into the workbook.

importXml(url: string, sheetName: string, row: number, col: number) : void;

Parameters:

ParameterTypeDescription
urlstringthe url/path of the xml file.
sheetNamestringthe destination sheet name.
rownumberthe destination row
colnumberthe destination column

importXml(Uint8Array, string, number, number)

Imports/Updates an XML data file into the workbook.

importXml(stream: Uint8Array, sheetName: string, row: number, col: number) : void;

Parameters:

ParameterTypeDescription
streamUint8Arraythe xml file stream.
sheetNamestringthe destination sheet name.
rownumberthe destination row.
colnumberthe destination column.

exportXml(string, string)

Export XML data linked by the specified XML map.

exportXml(mapName: string, path: string) : void;

Parameters:

ParameterTypeDescription
mapNamestringname of the XML map that need to be exported
pathstringthe export path

exportXml(string)

Export XML data.

exportXml(mapName: string) : Uint8Array;

Parameters:

ParameterTypeDescription
mapNamestringname of the XML map that need to be exported

Returns

The result stream

setDigitalSignature(DigitalSignatureCollection)

Sets digital signature to an spreadsheet file (Excel2007 and later).

setDigitalSignature(digitalSignatureCollection: DigitalSignatureCollection) : void;

Parameters:

ParameterTypeDescription
digitalSignatureCollectionDigitalSignatureCollection

Remarks

Only support adding Xmldsig Digital Signature

addDigitalSignature(DigitalSignatureCollection)

Adds digital signature to an OOXML spreadsheet file (Excel2007 and later).

addDigitalSignature(digitalSignatureCollection: DigitalSignatureCollection) : void;

Parameters:

ParameterTypeDescription
digitalSignatureCollectionDigitalSignatureCollection

Remarks

Only support adding Xmldsig Digital Signature to an OOXML spreadsheet file

getDigitalSignature()

Gets digital signature from file.

getDigitalSignature() : DigitalSignatureCollection;

Returns

DigitalSignatureCollection

removePersonalInformation()

Removes personal information.

removePersonalInformation() : void;

dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

dispose() : void;

isNull()

Checks whether the implementation object is null.

isNull() : boolean;