Workbook

Workbook class

Represents a root object to create an Excel spreadsheet. 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.

new Workbook()

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

Methods

NameDescription
acceptAllRevisions()Accepts all tracked changes in the workbook.
addDigitalSignature(digitalSignatureCollection)Adds digital signature to an OOXML spreadsheet file (Excel2007 and later). Only support adding Xmldsig Digital Signature
calculateFormula()Calculates the result of formulas. For all supported formulas, please see the list at https://docs.aspose.com/display/ce
calculateFormula(ignoreError)Calculates the result of formulas.
calculateFormula(options)Calculating formulas in this workbook.
changePalette(color, index)Changes the palette for the spreadsheet in the specified index. The palette has 56 entries, each represented by an RGB v
closeAccessCache(opts)Closes the session that uses caches to access data.
combine(secondWorkbook)Combines another Workbook object. Merge Excel, ODS , CSV and other files to one file.
constructor_overload$1(fileFormatType)Initializes a new instance of the Workbook class. The default file format type is Excel97To2003.
constructor_overload$2()
constructor_overload$3(file)Initializes a new instance of the Workbook class and open a file.
constructor_overload$4(file, loadOptions)Initializes a new instance of the Workbook class and open a file.
copy(source, copyOptions)Copies another Workbook object. It’s very simple to clone an Excel file.
copy(source)Copies data from a source Workbook object.
copyTheme(source)Copies the theme from another workbook.
createBuiltinStyle(type)Creates built-in style by given type.
createCellsColor()Creates a CellsColor object.
createStyle()Creates a new style.
createStyle()
customTheme(themeName, colors)Customs the theme. The length of colors should be 12. Array indexTheme type0Backgournd11Text12Backgournd23Text24Accent15
dispose()Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
exportXml(mapName, path)Export XML data linked by the specified XML map.
exportXml(mapName, stream)Export XML data linked by the specified XML map.
getAbsolutePath()Gets and sets the absolute path of the file. Only used for external links.
getBuiltInDocumentProperties()Returns a DocumentProperty collection that represents all the built-in document properties of the spreadsheet. A new pro
getCellsDataTableFactory()Gets the factory for building ICellsDataTable from custom objects
getColors()Returns colors in the palette for the spreadsheet. The palette has 56 entries, each represented by an RGB value.
getContentTypeProperties()Gets the list of ContentTypeProperty objects in the workbook.
getCountOfStylesInPool()Gets number of the styles in the style pool.
getCustomDocumentProperties()Returns a DocumentProperty collection that represents all the custom document properties of the spreadsheet.
getCustomXmlParts()Represents a Custom XML Data Storage Part (custom XML data within a package).
getDataConnections()Gets the ExternalConnection collection.
getDataMashup()Gets mashup data.
getDataModel()
getDataSorter()Gets a DataSorter object to sort data.
getDefaultStyle()Gets or sets the default Style object of the workbook. The DefaultStyle property is useful to implement a Style for the
getDigitalSignature()Gets digital signature from file.
getFileFormat()Gets and sets the file format. The value of the property is FileFormatType integer constant.
getFileName()Gets and sets the current file name. If the file is opened by stream and there are some external formula references, ple
getFonts()Gets all fonts in the style pool.
getInterruptMonitor()Gets and sets the interrupt monitor.
getMatchingColor(rawColor)Find best matching Color in current palette.
getNamedStyle(name)Gets the named style in the style pool.
getRibbonXml()Gets and sets the XML file that defines the Ribbon UI.
getSettings()Represents the workbook settings.
getStyleInPool(index)Gets the style in the style pool. All styles in the workbook will be gathered into a pool. There is only a simple refere
getTheme()Gets the theme name.
getThemeColor(type)Gets theme color.
getVbaProject()Gets the VbaProject in a spreadsheet.
getWorksheets()Gets the WorksheetCollection collection in the spreadsheet.
hasCustomFunction()
hasExernalLinks()Indicates whether this workbook contains external links to other data sources. NOTE: This member is now obsolete. Instea
hasMacro()Indicates if this spreadsheet contains macro/VBA.
hasRevisions()Gets if the workbook has any tracked changes
importXml(url, sheetName, row, col)Imports/Updates an XML data file into the workbook.
importXml(stream, sheetName, row, col)Imports/Updates an XML data file into the workbook.
isColorInPalette(color)Checks if a color is in the palette for the spreadsheet.
isDigitallySigned()Indicates if this spreadsheet is digitally signed.
isLicensed()Indicates whether license is set.
isWorkbookProtectedWithPassword()Indicates whether structure or window is protected with password.
mergeNamedStyles()
parseFormulas(ignoreError)Parses all formulas which have not been parsed when they were loaded from template file or set to a cell.
protect(protectionType, password)Protects a workbook.
protectSharedWorkbook(password)Protects a shared workbook.
refreshAll()
refreshDynamicArrayFormulas(calculate)Refreshes dynamic array formulas(spill into new range of neighboring cells according to current data) Other formulas in
refreshDynamicArrayFormulas(calculate, copts)Refreshes dynamic array formulas(spill into new range of neighboring cells according to current data) For performance co
removeDigitalSignature()Removes digital signature from this spreadsheet.
removeExternalLinks()Removes all external links in the workbook. NOTE: This member is now obsolete. Instead, please use ExternalLinkCollectio
removeMacro()Removes VBA/macro from this spreadsheet.
removePersonalInformation()Removes personal information.
removeUnusedStyles()Remove all unused styles.
replace(placeHolder, newValue)Replaces a cell’s value with a new string.
replace(placeHolder, newValue)Replaces a cell’s value with a new integer.
replace(placeHolder, newValue)Replaces a cell’s value with a new double.
replace(placeHolder, newValues, isVertical)Replaces a cell’s value with a new string array.
replace(placeHolder, newValue, options)Replaces a cell’s value with a new string.
save(fileName, saveFormat)Saves the workbook to the disk.
save(fileName)Save the workbook to the disk.
save(fileName, saveOptions)Saves the workbook to the disk.
setAbsolutePath()Gets and sets the absolute path of the file. Only used for external links.
setDefaultStyle()Gets or sets the default Style object of the workbook. The DefaultStyle property is useful to implement a Style for the
setDigitalSignature(digitalSignatureCollection)Sets digital signature to an spreadsheet file (Excel2007 and later). Only support adding Xmldsig Digital Signature
setEncryptionOptions(encryptionType, keyLength)Set Encryption Options.
setFileFormat()Gets and sets the file format. The value of the property is FileFormatType integer constant.
setFileName()Gets and sets the current file name. If the file is opened by stream and there are some external formula references, ple
setInterruptMonitor()Gets and sets the interrupt monitor.
setRibbonXml()Gets and sets the XML file that defines the Ribbon UI.
setThemeColor(type, color)Sets the theme color
startAccessCache(opts)Starts the session that uses caches to access data. If the cache of specified data access requires some data models in w
unprotect(password)Unprotects a workbook.
unprotectSharedWorkbook(password)Unprotects a shared workbook.
updateCustomFunctionDefinition(definition)Updates definition of custom functions. This method can be used for some special scenarios. For example, if user needs s
updateLinkedDataSource(externalWorkbooks)If this workbook contains external links to other data source, Aspose.Cells will attempt to retrieve the latest data fro
createWorkbookFromStream(stream, callback) (static)Initializes a new instance of the Workbook class and open a stream.
createWorkbookFromStream(stream, loadOptions, callback) (static)Initializes a new instance of the Workbook class and open a stream.
save(workbook, stream, saveOptions) (static)Save the workbook to the stream.
save(workbook, stream, saveFormat) (static)Save the workbook to the stream.

acceptAllRevisions()

Accepts all tracked changes in the workbook.

addDigitalSignature(digitalSignatureCollection)

Adds digital signature to an OOXML spreadsheet file (Excel2007 and later). Only support adding Xmldsig Digital Signature to an OOXML spreadsheet file

ParameterTypeDescription
digitalSignatureCollectionDigitalSignatureCollection

calculateFormula()

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

calculateFormula(ignoreError)

Calculates the result of formulas.

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

calculateFormula(options)

Calculating formulas in this workbook.

ParameterTypeDescription
optionsCalculationOptionsOptions for calculation

changePalette(color, index)

Changes the palette for the spreadsheet in the specified index. 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.ColorRedGreenBlueBlack000White255255255Red25500Lime02550Blue00255Yellow2552550Magenta2550255Cyan0255255Maroon12800Green01280Navy00128Olive1281280Purple1280128Teal0128128Silver192192192Gray128128128Color17153153255Color1815351102Color19255255204Color20204255255Color211020102Color22255128128Color230102204Color24204204255Color2500128Color262550255Color272552550Color280255255Color291280128Color3012800Color310128128Color3200255Color330204255Color34204255255Color35204255204Color36255255153Color37153204255Color38255153204Color39204153255Color40255204153Color4151102255Color4251204204Color431532040Color442552040Color452551530Color462551020Color47102102153Color48150150150Color49051102Color5051153102Color510510Color5251510Color53153510Color5415351102Color555151153Color56515151

ParameterTypeDescription
colorColorColor structure.
indexNumberPalette index, 0 - 55.

closeAccessCache(opts)

Closes the session that uses caches to access data.

ParameterTypeDescription
optsNumberAccessCacheOptions

combine(secondWorkbook)

Combines another Workbook object. Merge Excel, ODS , CSV and other files to one file.

ParameterTypeDescription
secondWorkbookWorkbookAnother Workbook object.

constructor_overload$1(fileFormatType)

Initializes a new instance of the Workbook class. The default file format type is Excel97To2003.

ParameterTypeDescription
fileFormatTypeNumberFileFormatType

constructor_overload$2()

constructor_overload$3(file)

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

ParameterTypeDescription
fileStringThe file name.

constructor_overload$4(file, loadOptions)

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

ParameterTypeDescription
fileStringThe file name.
loadOptionsLoadOptionsThe load options

copy(source, copyOptions)

Copies another Workbook object. It’s very simple to clone an Excel file.

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

copy(source)

Copies data from a source Workbook object.

ParameterTypeDescription
sourceWorkbookSource Workbook object.

copyTheme(source)

Copies the theme from another workbook.

ParameterTypeDescription
sourceWorkbookSource workbook.

createBuiltinStyle(type)

Creates built-in style by given type.

ParameterTypeDescription
typeNumberBuiltinStyleType

Returns: Style — Style Style object

createCellsColor()

Creates a CellsColor object.

Returns: CellsColor — CellsColor Returns a CellsColor object.

createStyle()

Creates a new style.

Returns: Style — Style Returns a style object.

createStyle()

customTheme(themeName, colors)

Customs the theme. The length of colors should be 12. Array indexTheme type0Backgournd11Text12Backgournd23Text24Accent15Accent26Accent37Accent48Accent59Accent610Hyperlink11Followed Hyperlink

ParameterTypeDescription
themeNameStringThe theme name
colorsArray ofColorThe theme colors

dispose()

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

exportXml(mapName, path)

Export XML data linked by the specified XML map.

ParameterTypeDescription
mapNameStringname of the XML map that need to be exported
pathStringthe export path

exportXml(mapName, stream)

Export XML data linked by the specified XML map.

ParameterTypeDescription
mapNameStringname of the XML map that need to be exported
streamOutputStreamthe export stream

getAbsolutePath()

Gets and sets the absolute path of the file. Only used for external links.

getBuiltInDocumentProperties()

Returns a DocumentProperty collection that represents all the built-in document properties of the spreadsheet. 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: TitleSubjectAuthorKeywordsCommentsTemplateLast AuthorRevision NumberApplication NameLast Print DateCreation DateLast Save TimeTotal Editing TimeNumber of PagesNumber of WordsNumber of CharactersSecurityCategoryFormatManagerCompanyNumber of BytesNumber of LinesNumber of ParagraphsNumber of SlidesNumber of NotesNumber of Hidden SlidesNumber of Multimedia Clips

Example:

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

getCellsDataTableFactory()

Gets the factory for building ICellsDataTable from custom objects

getColors()

Returns colors in the palette for the spreadsheet. The palette has 56 entries, each represented by an RGB value.

getContentTypeProperties()

Gets the list of ContentTypeProperty objects in the workbook.

getCountOfStylesInPool()

Gets number of the styles in the style pool.

getCustomDocumentProperties()

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

Example:

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

getCustomXmlParts()

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

getDataConnections()

Gets the ExternalConnection collection.

getDataMashup()

Gets mashup data.

getDataModel()

getDataSorter()

Gets a DataSorter object to sort data.

getDefaultStyle()

Gets or sets the default Style object of the workbook. The DefaultStyle property is useful to implement a Style for the whole Workbook.

getDigitalSignature()

Gets digital signature from file.

getFileFormat()

Gets and sets the file format. The value of the property is FileFormatType integer constant.

getFileName()

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

getFonts()

Gets all fonts in the style pool.

getInterruptMonitor()

Gets and sets the interrupt monitor.

getMatchingColor(rawColor)

Find best matching Color in current palette.

ParameterTypeDescription
rawColorColorRaw color.

Returns: Color — Color Best matching color.

getNamedStyle(name)

Gets the named style in the style pool.

ParameterTypeDescription
nameStringname of the style

Returns: Style — Style named style, maybe null.

getRibbonXml()

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

getSettings()

Represents the workbook settings.

getStyleInPool(index)

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. If the returned style is changed, the style of all cells(which refers to this style) will be changed.

ParameterTypeDescription
indexNumberThe index.

Returns: Style — Style The style in the pool corresponds to given index, may be null.

getTheme()

Gets the theme name.

getThemeColor(type)

Gets theme color.

ParameterTypeDescription
typeNumberThemeColorType

Returns: Color — Color The theme color.

getVbaProject()

Gets the VbaProject in a spreadsheet.

getWorksheets()

Gets the WorksheetCollection collection in the spreadsheet.

Returns: WorksheetCollection — WorksheetCollection WorksheetCollection collection

hasCustomFunction()

Indicates whether this workbook contains external links to other data sources. NOTE: This member is now obsolete. Instead, please use ExternalLinkCollection.Count to check whether there are external links in this workbook. This method will be removed 12 months later since December 2021. Aspose apologizes for any inconvenience you may have experienced.@return {boolean} Whether this workbook contains external links to other data sources.

hasMacro()

Indicates if this spreadsheet contains macro/VBA.

hasRevisions()

Gets if the workbook has any tracked changes

importXml(url, sheetName, row, col)

Imports/Updates an XML data file into the workbook.

ParameterTypeDescription
urlStringthe url/path of the xml file.
sheetNameStringthe destination sheet name.
rowNumberthe destination row
colNumberthe destination column

importXml(stream, sheetName, row, col)

Imports/Updates an XML data file into the workbook.

ParameterTypeDescription
streamInputStreamthe xml file stream.
sheetNameStringthe destination sheet name.
rowNumberthe destination row.
colNumberthe destination column.

isColorInPalette(color)

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

ParameterTypeDescription
colorColorColor structure.

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

isDigitallySigned()

Indicates if this spreadsheet is digitally signed.

isLicensed()

Indicates whether license is set.

isWorkbookProtectedWithPassword()

Indicates whether structure or window is protected with password.

mergeNamedStyles()

parseFormulas(ignoreError)

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

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.

protect(protectionType, password)

Protects a workbook.

ParameterTypeDescription
protectionTypeNumberProtectionType
passwordStringPassword to protect the workbook.

protectSharedWorkbook(password)

Protects a shared workbook.

ParameterTypeDescription
passwordStringPassword to protect the workbook.

refreshAll()

refreshDynamicArrayFormulas(calculate)

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.

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

refreshDynamicArrayFormulas(calculate, copts)

Refreshes dynamic array formulas(spill into new range of neighboring cells according to current data) 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 calculateFormula(com.aspose.cells.CalculationOptions)), then using false vlaue for “calculate” flag may avoid the duplicated calculation for the benefit of performance.

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

removeDigitalSignature()

Removes digital signature from this spreadsheet.

Removes all external links in the workbook. NOTE: This member is now obsolete. Instead, please use ExternalLinkCollection.Clear() method. This method will be removed 12 months later since December 2021. Aspose apologizes for any inconvenience you may have experienced.

removeMacro()

Removes VBA/macro from this spreadsheet.

removePersonalInformation()

Removes personal information.

removeUnusedStyles()

Remove all unused styles.

replace(placeHolder, newValue)

Replaces a cell’s value with a new string.

ParameterTypeDescription
placeHolderStringCell placeholder
newValueStringString value to replace

Example:

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

replace(placeHolder, newValue)

Replaces a cell’s value with a new integer.

ParameterTypeDescription
placeHolderStringCell placeholder
newValueNumberInteger value to replace

Example:

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

replace(placeHolder, newValue)

Replaces a cell’s value with a new double.

ParameterTypeDescription
placeHolderStringCell placeholder
newValueNumberDouble value to replace

Example:

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

replace(placeHolder, newValues, isVertical)

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

ParameterTypeDescription
placeHolderStringCell placeholder
newValuesArray of StringString array to replace
isVerticalbooleanTrue - Vertical, False - Horizontal

Example:

var aspose = aspose || {};
aspose.cells = require("aspose.cells");
var java = require("java");
var workbook = new aspose.cells.Workbook();
var newValues = java.newArray("java.lang.String", ["Tom", "Alice", "Jerry"]);
workbook.replace("AnOldValue", newValues, true);

replace(placeHolder, newValue, options)

Replaces a cell’s value with a new string.

ParameterTypeDescription
placeHolderStringCell placeholder
newValueStringString value to replace
optionsReplaceOptionsThe replace options

save(fileName, saveFormat)

Saves the workbook to the disk.

ParameterTypeDescription
fileNameStringThe file name.
saveFormatNumberSaveFormat

Example:

var workbook = new aspose.cells.Workbook();
var sheets = workbook.getWorksheets();
var cells = sheets.get(0).getCells();
cells.get("A1").putValue("Hello world!");
workbook.save("Book1.xls", aspose.cells.SaveFormat.EXCEL_97_TO_2003);

save(fileName)

Save the workbook to the disk.

ParameterTypeDescription
fileNameString

save(fileName, saveOptions)

Saves the workbook to the disk.

ParameterTypeDescription
fileNameStringThe file name.
saveOptionsSaveOptionsThe save options.

setAbsolutePath()

Gets and sets the absolute path of the file. Only used for external links.

setDefaultStyle()

Gets or sets the default Style object of the workbook. The DefaultStyle property is useful to implement a Style for the whole Workbook.

setDigitalSignature(digitalSignatureCollection)

Sets digital signature to an spreadsheet file (Excel2007 and later). Only support adding Xmldsig Digital Signature

ParameterTypeDescription
digitalSignatureCollectionDigitalSignatureCollection

setEncryptionOptions(encryptionType, keyLength)

Set Encryption Options.

ParameterTypeDescription
encryptionTypeNumberEncryptionType
keyLengthNumberThe key length.

setFileFormat()

Gets and sets the file format. The value of the property is FileFormatType integer constant.

setFileName()

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

setInterruptMonitor()

Gets and sets the interrupt monitor.

setRibbonXml()

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

setThemeColor(type, color)

Sets the theme color

ParameterTypeDescription
typeNumberThemeColorType
colorColorthe theme color

startAccessCache(opts)

Starts the session that uses caches to access data. 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(int) should be invoked with same options to clear all caches and recover normal access mode.

ParameterTypeDescription
optsNumberAccessCacheOptions

unprotect(password)

Unprotects a workbook.

ParameterTypeDescription
passwordStringPassword to unprotect the workbook.

unprotectSharedWorkbook(password)

Unprotects a shared workbook.

ParameterTypeDescription
passwordStringPassword to unprotect the workbook.

updateCustomFunctionDefinition(definition)

Updates definition of custom functions. 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(java.lang.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.

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

updateLinkedDataSource(externalWorkbooks)

If this workbook contains external links to other data source, Aspose.Cells will attempt to retrieve the latest data from give sources. 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.

ParameterTypeDescription
externalWorkbooksArray ofWorkbookWorkbooks 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

createWorkbookFromStream(stream, callback) (static)

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

ParameterTypeDescription
streamReadableStreamThe stream
callbackCallbackThe callback function

Example:

var aspose = aspose || {};
aspose.cells = require("aspose.cells");
var fs = require("fs");
var readStream = fs.createReadStream("Book2.xlsx");
aspose.cells.Workbook.createWorkbookFromStream(readStream, function(workbook, err) {
if (err) {
console.log("open workbook error");
return;
}
workbook.save('result.xlsx');
console.log('saved to file');
});

createWorkbookFromStream(stream, loadOptions, callback) (static)

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

ParameterTypeDescription
streamReadableStreamThe stream
loadOptionsLoadOptionsThe load options
callbackCallbackThe callback function

Example:

var aspose = aspose || {};
aspose.cells = require("aspose.cells");
var fs = require("fs");
var readStream = fs.createReadStream("Book2.xlsx");
var loadOptions = new aspose.cells.LoadOptions();
aspose.cells.Workbook.createWorkbookFromStream(readStream, loadOptions, function(workbook, err) {
if (err) {
console.log("open workbook error");
return;
}
workbook.save('result.xlsx');
console.log('saved to file');
});

save(workbook, stream, saveOptions) (static)

Save the workbook to the stream.

ParameterTypeDescription
workbookWorkbookThe workbook object to save
streamWritableStreamThe stream
saveOptionsSaveOptionsThe save options

Example:

var aspose = aspose || {};
aspose.cells = require("aspose.cells");
var fs = require("fs");
var workbook = new aspose.cells.Workbook("Book2.xlsx");
var saveOptions = new aspose.cells.XlsSaveOptions();
var writeStream = fs.createWriteStream("result-stream.xls");
aspose.cells.Workbook.saveToStream(workbook, writeStream, saveOptions);

save(workbook, stream, saveFormat) (static)

Save the workbook to the stream.

ParameterTypeDescription
workbookWorkbookThe workbook object to save
streamWritableStreamThe stream
saveFormatNumberThe save file format type

Example:

var aspose = aspose || {};
aspose.cells = require("aspose.cells");
var fs = require("fs");
var workbook = new aspose.cells.Workbook("Book2.xlsx");
var writeStream = fs.createWriteStream("result-stream.xlsx");
aspose.cells.Workbook.saveToStream(workbook, writeStream, aspose.cells.SaveFormat.XLSX);