Class Workbook

Class Workbook

Namespace: Aspose.Cells
Assembly: Aspose.Cells.dll (25.2.0)

Represents a root object to create an Excel spreadsheet.

public class Workbook : IDisposable

Inheritance

objectWorkbook

Implements

IDisposable

Inherited Members

object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Examples

The following example loads a Workbook from an Excel file named designer.xls and makes the horizontal and vertical scroll bars invisible. It then replaces two string values with an Integer value and string value respectively within the spreadsheet and finally save the workbook as Excel xlsx file.

//Open a designer file
string designerFile = "designer.xls";
Workbook workbook = new Workbook(designerFile);

//Set scroll bars
workbook.Settings.IsHScrollBarVisible = false;
workbook.Settings.IsVScrollBarVisible = false;

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

string newString = "Hello!";
workbook.Replace("OldString", newString);
workbook.Save("result.xlsx");
'Open a designer file
Dim designerFile as String = "\designer.xls"
Dim workbook as Workbook = new Workbook(designerFile)

'Set scroll bars
workbook.IsHScrollBarVisible = False
workbook.IsVScrollBarVisible = False

'Replace the placeholder string with new values
Dim newInt as Integer = 100
workbook.Replace("OldInt", newInt)

Dim newString as String = "Hello!"
workbook.Replace("OldString", newString)
workbook.Save("result.xlsx")

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.

Constructors

Workbook()

Initializes a new instance of the Aspose.Cells.Workbook class.

public Workbook()

Examples

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

Workbook workbook = new Workbook();
Dim workbook as Workbook = new Workbook()

Remarks

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

Workbook(FileFormatType)

Initializes a new instance of the Aspose.Cells.Workbook class.

public Workbook(FileFormatType fileFormatType)

Parameters

fileFormatType FileFormatType

The new file format.

Examples

The following code shows how to use the Workbook constructor to create and initialize a new instance of the class with various file format type.

Workbook workbook = new Workbook(FileFormatType.Xlsx);
Dim workbook as Workbook = new Workbook(FileFormatType.Xlsx)

Remarks

The default file format type is Excel97To2003.

Workbook(string)

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

public Workbook(string file)

Parameters

file string

The file name.

Workbook(Stream)

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

public Workbook(Stream stream)

Parameters

stream Stream

The stream.

Workbook(string, LoadOptions)

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

public Workbook(string file, LoadOptions loadOptions)

Parameters

file string

The file name.

loadOptions LoadOptions

The load options

Workbook(Stream, LoadOptions)

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

public Workbook(Stream stream, LoadOptions loadOptions)

Parameters

stream Stream

The stream.

loadOptions LoadOptions

The load options

Properties

AbsolutePath

Gets and sets the absolute path of the file.

public string AbsolutePath { get; set; }

Property Value

string

Remarks

Only used for external links.

BuiltInDocumentProperties

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

public BuiltInDocumentPropertyCollection BuiltInDocumentProperties { get; }

Property Value

BuiltInDocumentPropertyCollection

Examples

Workbook workbook = new Workbook();
DocumentProperty doc = workbook.BuiltInDocumentProperties["Author"];
doc.Value = "John Smith";
Dim workbook as Workbook = New Workbook()
Dim doc as DocumentProperty = workbook.BuiltInDocumentProperties("Author")
doc.Value = "John Smith"

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

CellsDataTableFactory

Gets the factory for building ICellsDataTable from custom objects

public CellsDataTableFactory CellsDataTableFactory { get; }

Property Value

CellsDataTableFactory

Colors

Returns colors in the palette for the spreadsheet.

public Color[] Colors { get; }

Property Value

Color[]

Remarks

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

ContentTypeProperties

Gets the list of Aspose.Cells.Properties.ContentTypeProperty objects in the workbook.

public ContentTypePropertyCollection ContentTypeProperties { get; }

Property Value

ContentTypePropertyCollection

CountOfStylesInPool

Gets number of the styles in the style pool.

public int CountOfStylesInPool { get; }

Property Value

int

CustomDocumentProperties

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

public CustomDocumentPropertyCollection CustomDocumentProperties { get; }

Property Value

CustomDocumentPropertyCollection

Examples

Workbook excel = new Workbook();
excel.CustomDocumentProperties.Add("Checked by", "Jane");
Dim excel as Workbook = New Workbook()
excel.CustomDocumentProperties.Add("Checked by", "Jane")

CustomXmlParts

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

public CustomXmlPartCollection CustomXmlParts { get; }

Property Value

CustomXmlPartCollection

DataConnections

Gets the Aspose.Cells.ExternalConnections.ExternalConnection collection.

public ExternalConnectionCollection DataConnections { get; }

Property Value

ExternalConnectionCollection

DataMashup

Gets mashup data.

public DataMashup DataMashup { get; }

Property Value

DataMashup

DataModel

Gets data model in the workbook.

public DataModel DataModel { get; }

Property Value

DataModel

DataSorter

Gets a DataSorter object to sort data.

public DataSorter DataSorter { get; }

Property Value

DataSorter

DefaultStyle

Gets or sets the default Aspose.Cells.Style object of the workbook.

public Style DefaultStyle { get; set; }

Property Value

Style

Examples

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

Workbook workbook = new Workbook();
Style defaultStyle = workbook.DefaultStyle;
defaultStyle.Font.Name = "Tahoma";
workbook.DefaultStyle = defaultStyle;
Dim workbook as Workbook = new Workbook()
Dim defaultStyle as Style = workbook.DefaultStyle
defaultStyle.Font.Name = "Tahoma"
workbook.DefaultStyle = defaultStyle

Remarks

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

FileFormat

Gets and sets the file format.

public FileFormatType FileFormat { get; set; }

Property Value

FileFormatType

FileName

Gets and sets the current file name.

public string FileName { get; set; }

Property Value

string

Remarks

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

HasMacro

Indicates if this spreadsheet contains macro/VBA.

public bool HasMacro { get; }

Property Value

bool

HasRevisions

Gets if the workbook has any tracked changes

public bool HasRevisions { get; }

Property Value

bool

InterruptMonitor

Gets and sets the interrupt monitor.

public AbstractInterruptMonitor InterruptMonitor { get; set; }

Property Value

AbstractInterruptMonitor

IsDigitallySigned

Indicates if this spreadsheet is digitally signed.

public bool IsDigitallySigned { get; }

Property Value

bool

IsLicensed

Indicates whether license is set.

public bool IsLicensed { get; }

Property Value

bool

IsWorkbookProtectedWithPassword

Indicates whether structure or window is protected with password.

public bool IsWorkbookProtectedWithPassword { get; }

Property Value

bool

RibbonXml

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

public string RibbonXml { get; set; }

Property Value

string

Settings

Represents the workbook settings.

public WorkbookSettings Settings { get; }

Property Value

WorkbookSettings

Theme

Gets the theme name.

public string Theme { get; }

Property Value

string

VbaProject

Gets the Aspose.Cells.Workbook.VbaProject in a spreadsheet.

public VbaProject VbaProject { get; }

Property Value

VbaProject

Worksheets

Gets the Aspose.Cells.WorksheetCollection collection in the spreadsheet.

public WorksheetCollection Worksheets { get; }

Property Value

WorksheetCollection

Methods

AcceptAllRevisions()

Accepts all tracked changes in the workbook.

public void AcceptAllRevisions()

AddDigitalSignature(DigitalSignatureCollection)

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

public void AddDigitalSignature(DigitalSignatureCollection digitalSignatureCollection)

Parameters

digitalSignatureCollection DigitalSignatureCollection

Remarks

Only support adding Xmldsig Digital Signature to an OOXML spreadsheet file

CalculateFormula()

Calculates the result of formulas.

public void CalculateFormula()

Remarks

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

CalculateFormula(bool)

Calculates the result of formulas.

public void CalculateFormula(bool ignoreError)

Parameters

ignoreError bool

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

CalculateFormula(CalculationOptions)

Calculating formulas in this workbook.

public void CalculateFormula(CalculationOptions options)

Parameters

options CalculationOptions

Options for calculation

ChangePalette(Color, int)

Changes the palette for the spreadsheet in the specified index.

public void ChangePalette(Color color, int index)

Parameters

color Color

Color structure.

index int

Palette 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.

ColorRedGreenBlue
Black000
White255255255
Red25500
Lime02550
Blue00255
Yellow2552550
Magenta2550255
Cyan0255255
Maroon12800
Green01280
Navy00128
Olive1281280
Purple1280128
Teal0128128
Silver192192192
Gray128128128
Color17153153255
Color1815351102
Color19255255204
Color20204255255
Color211020102
Color22255128128
Color230102204
Color24204204255
Color2500128
Color262550255
Color272552550
Color280255255
Color291280128
Color3012800
Color310128128
Color3200255
Color330204255
Color34204255255
Color35204255204
Color36255255153
Color37153204255
Color38255153204
Color39204153255
Color40255204153
Color4151102255
Color4251204204
Color431532040
Color442552040
Color452551530
Color462551020
Color47102102153
Color48150150150
Color49051102
Color5051153102
Color510510
Color5251510
Color53153510
Color5415351102
Color555151153
Color56515151

CloseAccessCache(AccessCacheOptions)

Closes the session that uses caches to access data.

public void CloseAccessCache(AccessCacheOptions opts)

Parameters

opts AccessCacheOptions

options of data access

Combine(Workbook)

Combines another Workbook object.

public void Combine(Workbook secondWorkbook)

Parameters

secondWorkbook Workbook

Another Workbook object.

Remarks

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

Copy(Workbook, CopyOptions)

Copies another Workbook object.

public void Copy(Workbook source, CopyOptions copyOptions)

Parameters

source Workbook

Source Workbook object.

copyOptions CopyOptions

The options of copying other workbook.

Remarks

It’s very simple to clone an Excel file.

Copy(Workbook)

Copies data from a source Workbook object.

public void Copy(Workbook source)

Parameters

source Workbook

Source Workbook object.

CopyTheme(Workbook)

Copies the theme from another workbook.

public void CopyTheme(Workbook source)

Parameters

source Workbook

Source workbook.

CreateBuiltinStyle(BuiltinStyleType)

Creates built-in style by given type.

public Style CreateBuiltinStyle(BuiltinStyleType type)

Parameters

type BuiltinStyleType

The builtin style stype.

Returns

Style

Aspose.Cells.Style object

CreateCellsColor()

Creates a Aspose.Cells.CellsColor object.

public CellsColor CreateCellsColor()

Returns

CellsColor

Returns a Aspose.Cells.CellsColor object.

CreateStyle()

Creates a new style.

public Style CreateStyle()

Returns

Style

Returns a style object.

CreateStyle(bool)

Creates a new style.

public Style CreateStyle(bool cloneDefaultStyle)

Parameters

cloneDefaultStyle bool

Incidates whether clones the default style

Returns

Style

Returns a style object.

CustomTheme(string, Color[])

Customs the theme.

public void CustomTheme(string themeName, Color[] colors)

Parameters

themeName string

The theme name

colors Color[]

The theme colors

Remarks

The length of colors should be 12.

Array indexTheme type
0Backgournd1
1Text1
2Backgournd2
3Text2
4Accent1
5Accent2
6Accent3
7Accent4
8Accent5
9Accent6
10Hyperlink
11Followed Hyperlink

Dispose()

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

public void Dispose()

ExportXml(string, string)

Export XML data linked by the specified XML map.

public void ExportXml(string mapName, string path)

Parameters

mapName string

name of the XML map that need to be exported

path string

the export path

Examples

The following code exported the data linked by the first XmlMap.

csharp
Workbook wb = new Workbook("Book1.xlsx");

//Make sure that the source xlsx file contains a XmlMap.
XmlMap xmlMap = wb.Worksheets.XmlMaps[0];

wb.ExportXml(xmlMap.Name, "output.xml");

ExportXml(string, Stream)

Export XML data.

public void ExportXml(string mapName, Stream stream)

Parameters

mapName string

name of the XML map that need to be exported

stream Stream

the export stream

GetDigitalSignature()

Gets digital signature from file.

public DigitalSignatureCollection GetDigitalSignature()

Returns

DigitalSignatureCollection

GetFonts()

Gets all fonts in the style pool.

public Font[] GetFonts()

Returns

Font[]

GetMatchingColor(Color)

Find best matching Color in current palette.

public Color GetMatchingColor(Color rawColor)

Parameters

rawColor Color

Raw color.

Returns

Color

Best matching color.

GetNamedStyle(string)

Gets the named style in the style pool.

public Style GetNamedStyle(string name)

Parameters

name string

name of the style

Returns

Style

named style, maybe null.

GetStyleInPool(int)

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.

public Style GetStyleInPool(int index)

Parameters

index int

The index.

Returns

Style

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.

GetThemeColor(ThemeColorType)

Gets theme color.

public Color GetThemeColor(ThemeColorType type)

Parameters

type ThemeColorType

The theme color type.

Returns

Color

The theme color.

ImportXml(string, string, int, int)

Imports/Updates an XML data file into the workbook.

public void ImportXml(string url, string sheetName, int row, int col)

Parameters

url string

the url/path of the xml file.

sheetName string

the destination sheet name.

row int

the destination row

col int

the destination column

Examples

The following code imports xml data into worksheet ‘Sheet 1’ at Cell A1.

csharp
Workbook wb = new Workbook("Book1.xlsx");

wb.ImportXml("xml.xml", "Sheet1", 0, 0);

wb.Save("output.xlsx");

ImportXml(Stream, string, int, int)

Imports/Updates an XML data file into the workbook.

public void ImportXml(Stream stream, string sheetName, int row, int col)

Parameters

stream Stream

the xml file stream.

sheetName string

the destination sheet name.

row int

the destination row.

col int

the destination column.

IsColorInPalette(Color)

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

public bool IsColorInPalette(Color color)

Parameters

color Color

Color structure.

Returns

bool

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

ParseFormulas(bool)

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

public void ParseFormulas(bool ignoreError)

Parameters

ignoreError bool

Whether 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, string)

Protects a workbook.

public void Protect(ProtectionType protectionType, string password)

Parameters

protectionType ProtectionType

Protection type.

password string

Password to protect the workbook.

ProtectSharedWorkbook(string)

Protects a shared workbook.

public void ProtectSharedWorkbook(string password)

Parameters

password string

Password to protect the workbook.

RefreshDynamicArrayFormulas(bool)

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.

public void RefreshDynamicArrayFormulas(bool calculate)

Parameters

calculate bool

Whether calculates and updates cell values for those dynamic array formulas

RefreshDynamicArrayFormulas(bool, CalculationOptions)

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

public void RefreshDynamicArrayFormulas(bool calculate, CalculationOptions copts)

Parameters

calculate bool

Whether calculates and updates cell values for those dynamic array formulas

copts CalculationOptions

The 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 Aspose.Cells.Workbook.CalculateFormula(Aspose.Cells.CalculationOptions)), then using false vlaue for “calculate” flag may avoid the duplicated calculation for the benefit of performance.

RemoveDigitalSignature()

Removes digital signature from this spreadsheet.

public void RemoveDigitalSignature()

RemoveMacro()

Removes VBA/macro from this spreadsheet.

public void RemoveMacro()

RemovePersonalInformation()

Removes personal information.

public void RemovePersonalInformation()

RemoveUnusedStyles()

Remove all unused styles.

public void RemoveUnusedStyles()

Replace(string, string)

Replaces a cell’s value with a new string.

public int Replace(string placeHolder, string newValue)

Parameters

placeHolder string

Cell placeholder

newValue string

String value to replace

Returns

int

Examples

Workbook workbook = new Workbook();
//......
workbook.Replace("AnOldValue", "NewValue");
Dim workbook As Workbook =  New Workbook() 
'........
workbook.Replace("AnOldValue", "NewValue")

Replace(string, int)

Replaces a cell’s value with a new integer.

public int Replace(string placeHolder, int newValue)

Parameters

placeHolder string

Cell placeholder

newValue int

Integer value to replace

Returns

int

Examples

Workbook workbook = new Workbook();
//......
int newValue = 100;
workbook.Replace("AnOldValue", newValue);
Dim workbook As Workbook =  New Workbook() 
'.........
Dim NewValue As Integer =  100 
workbook.Replace("AnOldValue", NewValue)

Replace(string, double)

Replaces a cell’s value with a new double.

public int Replace(string placeHolder, double newValue)

Parameters

placeHolder string

Cell placeholder

newValue double

Double value to replace

Returns

int

Examples

Workbook workbook = new Workbook();
//......
double newValue = 100.0;
workbook.Replace("AnOldValue", newValue);
Dim workbook As Workbook =  New Workbook() 
'.........
Dim NewValue As Double =  100.0
workbook.Replace("AnOldValue", NewValue)

Replace(string, string[], bool)

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

public int Replace(string placeHolder, string[] newValues, bool isVertical)

Parameters

placeHolder string

Cell placeholder

newValues string[]

String array to replace

isVertical bool

True - Vertical, False - Horizontal

Returns

int

Examples

Workbook workbook = new Workbook();
//......
string[] newValues = new string[]{"Tom", "Alice", "Jerry"};
workbook.Replace("AnOldValue", newValues, true);
Dim workbook As Workbook =  New Workbook() 
'.............
Dim NewValues() As String =  New String() {"Tom", "Alice", "Jerry"}		
workbook.Replace("AnOldValue", NewValues, True)

Replace(string, int[], bool)

Replaces cells’ values with an integer array.

public int Replace(string placeHolder, int[] newValues, bool isVertical)

Parameters

placeHolder string

Cell placeholder

newValues int[]

Integer array to replace

isVertical bool

True - Vertical, False - Horizontal

Returns

int

Examples

Workbook workbook = new Workbook();
//......
int[] newValues = new int[]{1, 2, 3};
workbook.Replace("AnOldValue", newValues, true);
Dim workbook As Workbook =  New Workbook() 
'...........
Dim NewValues() As Integer =  New Integer() {1, 2, 3}
workbook.Replace("AnOldValue", NewValues, True)

Replace(string, double[], bool)

Replaces cells’ values with a double array.

public int Replace(string placeHolder, double[] newValues, bool isVertical)

Parameters

placeHolder string

Cell placeholder

newValues double[]

Double array to replace

isVertical bool

True - Vertical, False - Horizontal

Returns

int

Examples

Workbook workbook = new Workbook();
//......
double[] newValues = new double[]{1.23, 2.56, 3.14159};
workbook.Replace("AnOldValue", newValues, true);
Dim workbook As Workbook =  New Workbook() 
'...........
Dim NewValues() As Double =  New Double() {1.23, 2.56, 3.14159}
workbook.Replace("AnOldValue", NewValues, True)

Replace(string, DataTable)

Replaces cells’ values with data from a System.Data.DataTable.

public int Replace(string placeHolder, DataTable insertTable)

Parameters

placeHolder string

Cell placeholder

insertTable DataTable

DataTable to replace

Returns

int

Examples

Workbook workbook = new Workbook();
DataTable myDataTable = new DataTable("Customers");
// Adds data to myDataTable
//........
workbook.Replace("AnOldValue", myDataTable);
Dim workbook As Workbook =  New Workbook() 
Dim myDataTable As DataTable =  New DataTable("Customers") 
' Adds data to myDataTable
'.............
workbook.Replace("AnOldValue", myDataTable)

Replace(bool, object)

Replaces cells’ values with new data.

public int Replace(bool boolValue, object newValue)

Parameters

boolValue bool

The boolean value to be replaced.

newValue object

New value. Can be string, integer, double or DateTime value.

Returns

int

Replace(int, object)

Replaces cells’ values with new data.

public int Replace(int intValue, object newValue)

Parameters

intValue int

The integer value to be replaced.

newValue object

New value. Can be string, integer, double or DateTime value.

Returns

int

Replace(string, string, ReplaceOptions)

Replaces a cell’s value with a new string.

public int Replace(string placeHolder, string newValue, ReplaceOptions options)

Parameters

placeHolder string

Cell placeholder

newValue string

String value to replace

options ReplaceOptions

The replace options

Returns

int

Save(string, SaveFormat)

Saves the workbook to the disk.

public void Save(string fileName, SaveFormat saveFormat)

Parameters

fileName string

The file name.

saveFormat SaveFormat

The save format type.

Save(string)

Save the workbook to the disk.

public void Save(string fileName)

Parameters

fileName string

Save(string, SaveOptions)

Saves the workbook to the disk.

public void Save(string fileName, SaveOptions saveOptions)

Parameters

fileName string

The file name.

saveOptions SaveOptions

The save options.

Save(Stream, SaveFormat)

Saves the workbook to the stream.

public void Save(Stream stream, SaveFormat saveFormat)

Parameters

stream Stream

The file stream.

saveFormat SaveFormat

The save file format type.

Save(Stream, SaveOptions)

Saves the workbook to the stream.

public void Save(Stream stream, SaveOptions saveOptions)

Parameters

stream Stream

The file stream.

saveOptions SaveOptions

The save options.

SaveToStream()

Saves Excel file to a MemoryStream object and returns it.

public MemoryStream SaveToStream()

Returns

MemoryStream

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.

SetDigitalSignature(DigitalSignatureCollection)

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

public void SetDigitalSignature(DigitalSignatureCollection digitalSignatureCollection)

Parameters

digitalSignatureCollection DigitalSignatureCollection

Remarks

Only support adding Xmldsig Digital Signature

SetEncryptionOptions(EncryptionType, int)

Set Encryption Options.

public void SetEncryptionOptions(EncryptionType encryptionType, int keyLength)

Parameters

encryptionType EncryptionType

The encryption type.

keyLength int

The key length.

SetThemeColor(ThemeColorType, Color)

Sets the theme color

public void SetThemeColor(ThemeColorType type, Color color)

Parameters

type ThemeColorType

The theme color type.

color Color

the theme color

StartAccessCache(AccessCacheOptions)

Starts the session that uses caches to access data.

public void StartAccessCache(AccessCacheOptions opts)

Parameters

opts AccessCacheOptions

options 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, Aspose.Cells.Workbook.CloseAccessCache(Aspose.Cells.AccessCacheOptions) should be invoked with same options to clear all caches and recover normal access mode.

Unprotect(string)

Unprotects a workbook.

public void Unprotect(string password)

Parameters

password string

Password to unprotect the workbook.

UnprotectSharedWorkbook(string)

Unprotects a shared workbook.

public void UnprotectSharedWorkbook(string password)

Parameters

password string

Password to unprotect the workbook.

UpdateCustomFunctionDefinition(CustomFunctionDefinition)

Updates definition of custom functions.

public void UpdateCustomFunctionDefinition(CustomFunctionDefinition definition)

Parameters

definition CustomFunctionDefinition

Special 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 Aspose.Cells.CustomFunctionDefinition.GetArrayModeParameters(System.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.

public void UpdateLinkedDataSource(Workbook[] externalWorkbooks)

Parameters

externalWorkbooks Workbook[]

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 Aspose.Cells.Workbook.FileName and Aspose.Cells.ExternalLink.DataSource. So please make sure Aspose.Cells.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.