Aspose::Cells::Workbook class

Workbook class

Represents a root object to create an Excel spreadsheet.

class Workbook

Methods

MethodDescription
AcceptAllRevisions()Accepts all tracked changes in the workbook.
AddDigitalSignature(const DigitalSignatureCollection& digitalSignatureCollection)Adds digital signature to an OOXML spreadsheet file (Excel2007 and later).
CalculateFormula()Calculates the result of formulas.
CalculateFormula(bool ignoreError)Calculates the result of formulas.
CalculateFormula(const CalculationOptions& options)Calculating formulas in this workbook.
ChangePalette(const Aspose::Cells::Color& color, int32_t index)Changes the palette for the spreadsheet in the specified index.
CloseAccessCache(AccessCacheOptions opts)Closes the session that uses caches to access data.
Combine(const Workbook& secondWorkbook)Combines another Workbook object.
Copy(const Workbook& source, const CopyOptions& copyOptions)Copies another Workbook object.
Copy(const Workbook& source)Copies data from a source Workbook object.
CopyTheme(const Workbook& source)Copies the theme from another workbook.
CreateBuiltinStyle(BuiltinStyleType type)Creates built-in style by given type.
CreateCellsColor()Creates a CellsColor object.
CreateStyle()Creates a new style.
CustomTheme(const U16String& themeName, const Vector <Aspose::Cells::Color>& colors)Customs the theme.
CustomTheme(const char16_t* themeName, const Vector <Aspose::Cells::Color>& colors)Customs the theme.
Dispose()Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
ExportXml(const U16String& mapName, const U16String& path)Export XML data linked by the specified XML map.
ExportXml(const char16_t* mapName, const char16_t* path)Export XML data linked by the specified XML map.
ExportXml(const U16String& mapName)Export XML data.
ExportXml(const char16_t* mapName)Export XML data.
GetAbsolutePath()Gets and sets the absolute path of the file.
GetBuiltInDocumentProperties()Returns a DocumentProperty collection that represents all the built-in document properties of the spreadsheet.
GetColors()Returns colors in the palette for the spreadsheet.
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.
GetDataSorter()Gets a DataSorter object to sort data.
GetDefaultStyle()Gets or sets the default Style object of the workbook.
GetDigitalSignature()Gets digital signature from file.
GetFileFormat()Gets and sets the file format.
GetFileName()Gets and sets the current file name.
GetFonts()Gets all fonts in the style pool.
GetHasMacro()Indicates if this spreadsheet contains macro/VBA.
GetHasRevisions()Gets if the workbook has any tracked changes.
GetInterruptMonitor()Gets and sets the interrupt monitor.
GetMatchingColor(const Aspose::Cells::Color& rawColor)Find best matching Color in current palette.
GetNamedStyle(const U16String& name)Gets the named style in the style pool.
GetNamedStyle(const char16_t* 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(int32_t 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.
GetTheme()Gets the theme name.
GetThemeColor(ThemeColorType type)Gets theme color.
GetVbaProject()Gets the VbaProject in a spreadsheet.
GetWorksheets()Gets the WorksheetCollection collection in the spreadsheet.
ImportXml(const U16String& url, const U16String& sheetName, int32_t row, int32_t col)Imports/Updates an XML data file into the workbook.
ImportXml(const char16_t* url, const char16_t* sheetName, int32_t row, int32_t col)Imports/Updates an XML data file into the workbook.
ImportXml(const Vector <uint8_t>& stream, const U16String& sheetName, int32_t row, int32_t col)Imports/Updates an XML data file into the workbook.
ImportXml(const Vector <uint8_t>& stream, const char16_t* sheetName, int32_t row, int32_t col)Imports/Updates an XML data file into the workbook.
IsColorInPalette(const Aspose::Cells::Color& 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.
IsNull() constChecks whether the implementation object is nullptr.
IsWorkbookProtectedWithPassword()Indicates whether structure or window is protected with password.
explicit operator bool() constoperator bool()
operator=(const Workbook& src)operator=
ParseFormulas(bool ignoreError)Parses all formulas which have not been parsed when they were loaded from template file or set to a cell.
Protect(ProtectionType protectionType, const U16String& password)Protects a workbook.
Protect(ProtectionType protectionType, const char16_t* password)Protects a workbook.
ProtectSharedWorkbook(const U16String& password)Protects a shared workbook.
ProtectSharedWorkbook(const char16_t* password)Protects a shared workbook.
RefreshDynamicArrayFormulas(bool 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.
RefreshDynamicArrayFormulas(bool calculate, const CalculationOptions& copts)Refreshes dynamic array formulas(spill into new range of neighboring cells according to current data)
RemoveDigitalSignature()Removes digital signature from this spreadsheet.
RemoveMacro()Removes VBA/macro from this spreadsheet.
RemovePersonalInformation()Removes personal information.
RemoveUnusedStyles()Remove all unused styles.
Replace(const U16String& placeHolder, const U16String& newValue)Replaces a cell’s value with a new string.
Replace(const char16_t* placeHolder, const char16_t* newValue)Replaces a cell’s value with a new string.
Replace(const U16String& placeHolder, int32_t newValue)Replaces a cell’s value with a new integer.
Replace(const char16_t* placeHolder, int32_t newValue)Replaces a cell’s value with a new integer.
Replace(const U16String& placeHolder, double newValue)Replaces a cell’s value with a new double.
Replace(const char16_t* placeHolder, double newValue)Replaces a cell’s value with a new double.
Replace(const U16String& placeHolder, const Vector <U16String>& newValues, bool isVertical)Replaces a cell’s value with a new string array.
Replace(const char16_t* placeHolder, const Vector <U16String>& newValues, bool isVertical)Replaces a cell’s value with a new string array.
Replace(const U16String& placeHolder, const Vector <int32_t>& newValues, bool isVertical)Replaces cells’ values with an integer array.
Replace(const char16_t* placeHolder, const Vector <int32_t>& newValues, bool isVertical)Replaces cells’ values with an integer array.
Replace(const U16String& placeHolder, const Vector <double>& newValues, bool isVertical)Replaces cells’ values with a double array.
Replace(const char16_t* placeHolder, const Vector <double>& newValues, bool isVertical)Replaces cells’ values with a double array.
Replace(const U16String& placeHolder, const U16String& newValue, const ReplaceOptions& options)Replaces a cell’s value with a new string.
Replace(const char16_t* placeHolder, const char16_t* newValue, const ReplaceOptions& options)Replaces a cell’s value with a new string.
Save(const U16String& fileName, SaveFormat saveFormat)Saves the workbook to the disk.
Save(const char16_t* fileName, SaveFormat saveFormat)Saves the workbook to the disk.
Save(const U16String& fileName)Save the workbook to the disk.
Save(const char16_t* fileName)Save the workbook to the disk.
Save(const U16String& fileName, const SaveOptions& saveOptions)Saves the workbook to the disk.
Save(const char16_t* fileName, const SaveOptions& saveOptions)Saves the workbook to the disk.
Save(SaveFormat saveFormat)Saves the workbook to the stream.
Save(const SaveOptions& saveOptions)Saves the workbook to the stream.
SaveToStream()Saves Excel file to a MemoryStream object and returns it.
SetAbsolutePath(const U16String& value)Gets and sets the absolute path of the file.
SetAbsolutePath(const char16_t* value)Gets and sets the absolute path of the file.
SetDefaultStyle(const Style& value)Gets or sets the default Style object of the workbook.
SetDigitalSignature(const DigitalSignatureCollection& digitalSignatureCollection)Sets digital signature to an spreadsheet file (Excel2007 and later).
SetEncryptionOptions(EncryptionType encryptionType, int32_t keyLength)Set Encryption Options.
SetFileFormat(FileFormatType value)Gets and sets the file format.
SetFileName(const U16String& value)Gets and sets the current file name.
SetFileName(const char16_t* value)Gets and sets the current file name.
SetInterruptMonitor(AbstractInterruptMonitor* value)Gets and sets the interrupt monitor.
SetInterruptMonitor(const InterruptMonitor& interruptMonitor)Sets the interrupt monitor.
SetRibbonXml(const U16String& value)Gets and sets the XML file that defines the Ribbon UI.
SetRibbonXml(const char16_t* value)Gets and sets the XML file that defines the Ribbon UI.
SetThemeColor(ThemeColorType type, const Aspose::Cells::Color& color)Sets the theme color.
StartAccessCache(AccessCacheOptions opts)Starts the session that uses caches to access data.
Unprotect(const U16String& password)Unprotects a workbook.
Unprotect(const char16_t* password)Unprotects a workbook.
UnprotectSharedWorkbook(const U16String& password)Unprotects a shared workbook.
UnprotectSharedWorkbook(const char16_t* password)Unprotects a shared workbook.
UpdateCustomFunctionDefinition(CustomFunctionDefinition* definition)Updates definition of custom functions.
UpdateLinkedDataSource(const Vector <Workbook>& externalWorkbooks)If this workbook contains external links to other data source, Aspose.Cells will attempt to retrieve the latest data from give sources.
Workbook()Initializes a new instance of the Workbook class.
explicit Workbook(FileFormatType fileFormatType)Initializes a new instance of the Workbook class.
explicit Workbook(const U16String& file)Initializes a new instance of the Workbook class and open a file.
explicit Workbook(const char16_t* file)Initializes a new instance of the Workbook class and open a file.
explicit Workbook(const Vector <uint8_t>& stream)Initializes a new instance of the Workbook class and open a stream.
Workbook(const U16String& file, const LoadOptions& loadOptions)Initializes a new instance of the Workbook class and open a file.
Workbook(const char16_t* file, const LoadOptions& loadOptions)Initializes a new instance of the Workbook class and open a file.
Workbook(const Vector <uint8_t>& stream, const LoadOptions& loadOptions)Initializes a new instance of the Workbook class and open stream.
Workbook(Workbook_Impl* impl)Constructs from an implementation object.
Workbook(const Workbook& src)Copy constructor.
~Workbook()Destructor.

Fields

FieldDescription
_implThe implementation object.

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.

Examples

Aspose::Cells::Startup();
//Open a designer file
U16String designerFile = u"designer.xls";
Workbook workbook(designerFile);

//Set scroll bars
workbook.GetSettings().SetIsHScrollBarVisible(false);
workbook.GetSettings().SetIsVScrollBarVisible(false);

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

U16String newString = u"Hello!";
workbook.Replace(u"OldString", newString);
workbook.Save(u"result.xlsx");
Aspose::Cells::Cleanup();

See Also