com.aspose.cells

Class Workbook

  • java.lang.Object
    • com.aspose.cells.Workbook
public class Workbook 
extends java.lang.Object

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 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.
//Open a designer file
String designerFile = "designer.xls";
Workbook workbook = new Workbook(designerFile);

//Set scroll bars
workbook.getSettings().setHScrollBarVisible(false);
workbook.getSettings().setVScrollBarVisible(false);

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

String newString = "Hello!";
workbook.replace("OldString", newString);
XlsSaveOptions saveOptions = new XlsSaveOptions();
workbook.save("result.xls", saveOptions);

Constructor Summary
Workbook()
Initializes a new instance of the Workbook class.
Workbook(intfileFormatType)
Initializes a new instance of the Workbook class.
Workbook(java.lang.Stringfile)
Initializes a new instance of the Workbook class and open a file.
Workbook(java.io.InputStreamstream)
Initializes a new instance of the Workbook class and open a stream.
Workbook(java.lang.Stringfile, LoadOptions loadOptions)
Initializes a new instance of the Workbook class and open a file.
Workbook(java.io.InputStreamstream, LoadOptions loadOptions)
Initializes a new instance of the Workbook class and open stream.
 
Property Getters/Setters Summary
java.lang.StringgetAbsolutePath()
void
setAbsolutePath(java.lang.Stringvalue)
           Gets and sets the absolute path of the file.
BuiltInDocumentPropertyCollectiongetBuiltInDocumentProperties()
Returns a DocumentProperties collection that represents all the built-in document properties of the spreadsheet.
com.aspose.cells.Color[]getColors()
Returns colors in the palette for the spreadsheet.
ContentTypePropertyCollectiongetContentTypeProperties()
Gets the contenttypeproperties objects in the workbook.
intgetCountOfStylesInPool()
Gets number of the styles in the style pool.
CustomDocumentPropertyCollectiongetCustomDocumentProperties()
Returns a DocumentProperties collection that represents all the custom document properties of the spreadsheet.
CustomXmlPartCollectiongetCustomXmlParts()
Represents a InnerCustom XML Data Storage Part (custom XML data within a package).
ExternalConnectionCollectiongetDataConnections()
Gets the ExternalConnection collection.
DataSortergetDataSorter()
Gets a DataSorter object to sort data.
StylegetDefaultStyle()
void
           Gets or sets the default Style object of the workbook.
intgetFileFormat()
void
setFileFormat(intvalue)
           Gets and sets the file format. The value of the property is FileFormatType integer constant.
java.lang.StringgetFileName()
void
setFileName(java.lang.Stringvalue)
           Gets and sets the current file name.
booleanhasMacro()
Indicates if this spreadsheet contains macro/VBA.
booleanhasRevisions()
Gets if the workbook has any tracked changes
InterruptMonitorgetInterruptMonitor()
void
           Gets and sets the interrupt monitor.
booleanisDigitallySigned()
Indicates if this spreadsheet is digitally signed.
booleanisLicensed()
Indicates whether license is set.
java.lang.StringgetRibbonXml()
void
setRibbonXml(java.lang.Stringvalue)
           Gets and sets the XML file that defines the Ribbon UI.
WorkbookSettingsgetSettings()
Represents the workbook settings.
java.lang.StringgetTheme()
Gets the theme name.
VbaProjectgetVbaProject()
Gets the VbaProject in a spreadsheet.
WorksheetCollectiongetWorksheets()
Gets the WorksheetCollection collection in the spreadsheet.
 
Method Summary
voidacceptAllRevisions()
Accepts all tracked changes in the workbook.
voidaddDigitalSignature(DigitalSignatureCollection digitalSignatureCollection)
Adds digital signature to an OOXML spreadsheet file (Excel2007 and later).
voidcalculateFormula()
Calculates the result of formulas.
voidcalculateFormula(boolean ignoreError)
Calculates the result of formulas.
voidcalculateFormula(boolean ignoreError, ICustomFunction customFunction)
Calculates the result of formulas.
voidcalculateFormula(CalculationOptions options)
Calcualting formulas in this workbook.
voidchangePalette(com.aspose.cells.Color color, int index)
Changes the palette for the spreadsheet in the specified index.
voidcombine(Workbook secondWorkbook)
Combines another Workbook object.
voidcopy(Workbook source0)
Copies data from a source Workbook object.
voidcopyTheme(Workbook source)
Copies the theme from another workbook.
StylecreateBuiltinStyle(int type)
Creates built-in style by given type.
CellsColorcreateCellsColor()
Creates a CellsColor object.
StylecreateStyle()
Creates a new style.
voidcustomTheme(java.lang.String themeName, com.aspose.cells.Color[] colors)
Customs the theme.
voiddispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
voidexportXml(java.lang.String mapName, java.lang.String path)
Export XML data.
DigitalSignatureCollectiongetDigitalSignature()
Gets digital signature from file.
com.aspose.cells.Font[]getFonts()
Gets all fonts in the style pool.
com.aspose.cells.ColorgetMatchingColor(com.aspose.cells.Color rawColor)
Find best matching Color in current palette.
StylegetNamedStyle(java.lang.String name)
Gets the named style in the style pool.
StylegetStyleInPool(int 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.
com.aspose.cells.ColorgetThemeColor(int type)
Gets theme color.
booleanhasExernalLinks()
Indicates whether this workbook contains external links to other data sources.
voidimportXml(java.lang.String url, java.lang.String sheetName, int row, int col)
Imports an xml file into the workbook.
booleanisColorInPalette(com.aspose.cells.Color color)
Checks if a color is in the palette for the spreadsheet.
voidprotect(int protectionType, java.lang.String password)
Protects a workbook.
voidprotectSharedWorkbook(java.lang.String password)
Protects a shared workbook.
voidremoveDigitalSignature()
Removes digital signature from this spreadsheet.
voidremoveExternalLinks()
Removes all external links in the workbook.
voidremoveMacro()
Removes VBA/macro from this spreadsheet.
voidremoveUnusedStyles()
Remove all unused styles.
intreplace(boolean boolValue, java.lang.Object newValue)
Replaces cells' values with new data.
intreplace(int intValue, java.lang.Object newValue)
Replaces cells' values with new data.
intreplace(java.lang.String placeHolder, double newValue)
Replaces a cell's value with a new double.
intreplace(java.lang.String placeHolder, double[] newValues, boolean isVertical)
Replaces cells' values with a double array.
intreplace(java.lang.String placeHolder, int newValue)
Replaces a cell's value with a new integer.
intreplace(java.lang.String placeHolder, int[] newValues, boolean isVertical)
Replaces cells' values with an integer array.
intreplace(java.lang.String placeHolder, java.lang.String newValue)
Replaces a cell's value with a new string.
intreplace(java.lang.String placeHolder, java.lang.String newValue, ReplaceOptions options)
Replaces a cell's value with a new string.
intreplace(java.lang.String placeHolder, java.lang.String[] newValues, boolean isVertical)
Replaces a cell's value with a new string array.
voidsave(java.io.OutputStream stream, SaveOptions saveOptions)
Save the workbook to the stream.
voidsave(java.io.OutputStream stream, int saveFormat)
Save the workbook to the stream.
voidsave(java.lang.String fileName)
voidsave(java.lang.String fileName, SaveOptions saveOptions)
Saves the workbook to the disk.
voidsave(java.lang.String fileName, int saveFormat)
Saves the workbook to the disk.
voidsetDigitalSignature(DigitalSignatureCollection digitalSignatureCollection)
Sets digital signature to an spreadsheet file (Excel2007 and later).
voidsetEncryptionOptions(int encryptionType, int keyLength)
Set Encryption Options.
voidsetThemeColor(int type, com.aspose.cells.Color color)
Sets the theme color
voidunprotect(java.lang.String password)
Unprotects a workbook.
voidunprotectSharedWorkbook(java.lang.String password)
Unprotects a shared workbook.
voidupdateLinkedDataSource(com.aspose.cells.Workbook[] exteralWorkbooks)
If this workbook contains external links to other data source, Aspose.Cells will attempt to retrieve the latest data.
 

    • Constructor Detail

      • Workbook

        public Workbook()
        Initializes a new instance of the Workbook class. The default file format type is Excel97To2003.If want create other format file type, please call Workbook(FileFormatType fileFormatType).
      • Workbook

        public Workbook(int fileFormatType)
        Initializes a new instance of the Workbook class. The default file format type is Excel97To2003.
        Parameters:
        fileFormatType - A FileFormatType value. The new file format.

        Example:

        The following code shows how to use the Workbook constructor to create and initialize a new instance of the class.
        Workbook workbook = new Workbook(FileFormatType.XLSX);
      • Workbook

        public Workbook(java.lang.String file)
                 throws java.lang.Exception
        Initializes a new instance of the Workbook class and open a file.
        Parameters:
        file - The file name.
      • Workbook

        public Workbook(java.io.InputStream stream)
                 throws java.lang.Exception
        Initializes a new instance of the Workbook class and open a stream.
        Parameters:
        stream - The stream.
      • Workbook

        public Workbook(java.lang.String file, LoadOptions loadOptions)
                 throws java.lang.Exception
        Initializes a new instance of the Workbook class and open a file.
        Parameters:
        file - The file name.
        loadOptions - The load options
      • Workbook

        public Workbook(java.io.InputStream stream, LoadOptions loadOptions)
                 throws java.lang.Exception
        Initializes a new instance of the Workbook class and open stream.
        Parameters:
        stream - The stream.
        loadOptions - The load options
    • Property Getters/Setters Detail

      • getSettings

        public WorkbookSettings getSettings()
        
        Represents the workbook settings.
      • isLicensed

        public boolean isLicensed()
        
        Indicates whether license is set.
      • getColors

        public com.aspose.cells.Color[] getColors()
        
        Returns colors in the palette for the spreadsheet. The palette has 56 entries, each represented by an RGB value.
      • getCountOfStylesInPool

        public int getCountOfStylesInPool()
        
        Gets number of the styles in the style pool.
      • getDefaultStyle/setDefaultStyle

        public Style getDefaultStyle() / public void setDefaultStyle(Style value)
        
        Gets or sets the default Style object of the workbook. 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.
        Workbook workbook = new Workbook();
        Style defaultStyle = workbook.getDefaultStyle();
        defaultStyle.getFont().setName("Tahoma");
        workbook.setDefaultStyle(defaultStyle);
      • isDigitallySigned

        public boolean isDigitallySigned()
        
        Indicates if this spreadsheet is digitally signed.
      • getVbaProject

        public VbaProject getVbaProject()
        
        Gets the VbaProject in a spreadsheet.
      • hasMacro

        public boolean hasMacro()
        
        Indicates if this spreadsheet contains macro/VBA.
      • hasRevisions

        public boolean hasRevisions()
        
        Gets if the workbook has any tracked changes
      • getFileName/setFileName

        public java.lang.String getFileName() / public void setFileName(java.lang.String value)
        
        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.
      • getDataSorter

        public DataSorter getDataSorter()
        
        Gets a DataSorter object to sort data.
      • getTheme

        public java.lang.String getTheme()
        
        Gets the theme name.
      • getBuiltInDocumentProperties

        public BuiltInDocumentPropertyCollection getBuiltInDocumentProperties()
        
        Returns a DocumentProperties 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:

        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:

        DocumentProperty doc = workbook.getBuiltInDocumentProperties().get("Author");
        doc.setValue("John Smith");
      • getCustomDocumentProperties

        public CustomDocumentPropertyCollection getCustomDocumentProperties()
        
        Returns a DocumentProperties collection that represents all the custom document properties of the spreadsheet.

        Example:

        excel.getCustomDocumentProperties().add("Checked by", "Jane");
      • getFileFormat/setFileFormat

        public int getFileFormat() / public void setFileFormat(int value)
        
        Gets and sets the file format. The value of the property is FileFormatType integer constant.
      • getInterruptMonitor/setInterruptMonitor

        public InterruptMonitor getInterruptMonitor() / public void setInterruptMonitor(InterruptMonitor value)
        
        Gets and sets the interrupt monitor.
      • getContentTypeProperties

        public ContentTypePropertyCollection getContentTypeProperties()
        
        Gets the contenttypeproperties objects in the workbook.
      • getCustomXmlParts

        public CustomXmlPartCollection getCustomXmlParts()
        
        Represents a InnerCustom XML Data Storage Part (custom XML data within a package).
      • getRibbonXml/setRibbonXml

        public java.lang.String getRibbonXml() / public void setRibbonXml(java.lang.String value)
        
        Gets and sets the XML file that defines the Ribbon UI.
      • getAbsolutePath/setAbsolutePath

        public java.lang.String getAbsolutePath() / public void setAbsolutePath(java.lang.String value)
        
        Gets and sets the absolute path of the file. Only used for external links.

    setDefaultStyle

    public voidsetDefaultStyle(Style value)
    
    Gets or sets the default Style object of the workbook. 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.
    Workbook workbook = new Workbook();
    Style defaultStyle = workbook.getDefaultStyle();
    defaultStyle.getFont().setName("Tahoma");
    workbook.setDefaultStyle(defaultStyle);

    setFileName

    public voidsetFileName(java.lang.Stringvalue)
    
    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.

    setFileFormat

    public voidsetFileFormat(intvalue)
    
    Gets and sets the file format. The value of the property is FileFormatType integer constant.

    setInterruptMonitor

    public voidsetInterruptMonitor(InterruptMonitor value)
    
    Gets and sets the interrupt monitor.

    setRibbonXml

    public voidsetRibbonXml(java.lang.Stringvalue)
    
    Gets and sets the XML file that defines the Ribbon UI.

    setAbsolutePath

    public voidsetAbsolutePath(java.lang.Stringvalue)
    
    Gets and sets the absolute path of the file. Only used for external links.
    • Method Detail

      • save

        public void save(java.lang.String fileName, int saveFormat)
                 throws java.lang.Exception
        Saves the workbook to the disk.
        Parameters:
        fileName - The file name.
        saveFormat - A SaveFormat value. The save format type.

        Example:

        Workbook workbook = new Workbook();
        WorksheetCollection sheets = workbook.getWorksheets();
        Cells cells = sheets.get(0).getCells();
        cells.get("A1").putValue("Hello world!");
        workbook.save("D:\\test.xls", SaveFormat.EXCEL_97_TO_2003);
      • save

        public void save(java.lang.String fileName)
                 throws java.lang.Exception
        Parameters:
        fileName -
      • save

        public void save(java.lang.String fileName, SaveOptions saveOptions)
                 throws java.lang.Exception
        Saves the workbook to the disk.
        Parameters:
        fileName - The file name.
        saveOptions - The save options.
      • save

        public void save(java.io.OutputStream stream, SaveOptions saveOptions)
                 throws java.lang.Exception
        Save the workbook to the stream.
        Parameters:
        stream - The file stream.
        saveOptions - The save options.
      • save

        public void save(java.io.OutputStream stream, int saveFormat)
                 throws java.lang.Exception
        Save the workbook to the stream.
        Parameters:
        stream - The file stream.
        saveFormat - A SaveFormat value. The save file format type.
      • removeUnusedStyles

        public void removeUnusedStyles()
        Remove all unused styles.
      • createStyle

        public Style createStyle()
        Creates a new style.
        Returns:
        Returns a style object.
      • createBuiltinStyle

        public Style createBuiltinStyle(int type)
        Creates built-in style by given type.
        Parameters:
        type - A BuiltinStyleType value.
        Returns:
        style object
      • replace

        public int replace(java.lang.String placeHolder, java.lang.String newValue)
        Replaces a cell's value with a new string.
        Parameters:
        placeHolder - Cell placeholder
        newValue - String value to replace

        Example:

        Workbook workbook = new Workbook();
        Cells cells = workbook.getWorksheets().get(0).getCells();
        cells.get(0, 0).putValue("AnOldValue");
        cells.get(0, 1).putValue("AnotherOldValue");
        workbook.replace("AnOldValue", "NewValue");
      • replace

        public int replace(java.lang.String placeHolder, int newValue)
        Replaces a cell's value with a new integer.
        Parameters:
        placeHolder - Cell placeholder
        newValue - Integer value to replace

        Example:

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

        public int replace(java.lang.String placeHolder, double newValue)
        Replaces a cell's value with a new double.
        Parameters:
        placeHolder - Cell placeholder
        newValue - Double value to replace

        Example:

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

        public int replace(java.lang.String placeHolder, java.lang.String[] newValues, boolean isVertical)
        Replaces a cell's value with a new string array.
        Parameters:
        placeHolder - Cell placeholder
        newValues - String array to replace
        isVertical - True - Vertical, False - Horizontal

        Example:

        Workbook workbook = new Workbook();
        String[] newValues = new String[]{"Tom", "Alice", "Jerry"};
        workbook.replace("AnOldValue", newValues, true);
      • replace

        public int replace(java.lang.String placeHolder, int[] newValues, boolean isVertical)
        Replaces cells' values with an integer array.
        Parameters:
        placeHolder - Cell placeholder
        newValues - Integer array to replace
        isVertical - True - Vertical, False - Horizontal

        Example:

        Workbook workbook = new Workbook();
        int[] newValues = new int[]{1, 2, 3};
        workbook.replace("AnOldValue", newValues, true);
      • replace

        public int replace(java.lang.String placeHolder, double[] newValues, boolean isVertical)
        Replaces cells' values with a double array.
        Parameters:
        placeHolder - Cell placeholder
        newValues - Double array to replace
        isVertical - True - Vertical, False - Horizontal

        Example:

        Workbook workbook = new Workbook();
        double[] newValues = new double[]{1.23, 2.56, 3.14159};
        workbook.replace("AnOldValue", newValues, true);
      • replace

        public int replace(boolean boolValue, java.lang.Object newValue)
        Replaces cells' values with new data.
        Parameters:
        boolValue - The boolean value to be replaced.
        newValue - New value. Can be string, integer, double or DateTime value.
      • replace

        public int replace(int intValue, java.lang.Object newValue)
        Replaces cells' values with new data.
        Parameters:
        intValue - The integer value to be replaced.
        newValue - New value. Can be string, integer, double or DateTime value.
      • replace

        public int replace(java.lang.String placeHolder, java.lang.String newValue, ReplaceOptions options)
        Replaces a cell's value with a new string.
        Parameters:
        placeHolder - Cell placeholder
        newValue - String value to replace
        options - The replace options
      • copy

        public void copy(Workbook source0)
                 throws java.lang.Exception
        Copies data from a source Workbook object.
        Parameters:
        source0 - Source Workbook object.
      • combine

        public void combine(Workbook secondWorkbook)
                    throws java.lang.Exception
        Combines another Workbook object. Currently, only cell data and cell style of the second Workbook object can be combined. Images, charts and other drawing objects are not supported.
        Parameters:
        secondWorkbook - Another Workbook object.
      • getStyleInPool

        public Style getStyleInPool(int 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.
        Parameters:
        index - The index.
        Returns:
        The style in the pool corresponds to given index, may be null.
      • getFonts

        public com.aspose.cells.Font[] getFonts()
        Gets all fonts in the style pool.
      • getNamedStyle

        public Style getNamedStyle(java.lang.String name)
        Gets the named style in the style pool.
        Parameters:
        name - name of the style
        Returns:
        named style, maybe null.
      • changePalette

        public void changePalette(com.aspose.cells.Color color, int 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.

        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 
        Parameters:
        color - Color structure.
        index - Palette index, 0 - 55.
      • isColorInPalette

        public boolean isColorInPalette(com.aspose.cells.Color color)
        Checks if a color is in the palette for the spreadsheet.
        Parameters:
        color - Color structure.
        Returns:
        Returns true if this color is in the palette. Otherwise, returns false
      • calculateFormula

        public void calculateFormula()
        Calculates the result of formulas.

        Now Workbook built-in functions are not supported in this method:

        [A]

        ASC

        [B]

        BAHTTEXT

        [C]

        CALL, CLEAN, CODE, CONVERT, CUBEKPIMEMBER, CUBEMEMBER, CUBEMEMBERPROPERTY, CUBERANKEDMEMBER, CUBESET, CUBESETCOUNT, CUBEVALUE

        [E]

        EUROCONVERT

        [I]

        INFO

        [J]

        JIS

        [P]

        PHONETIC

        [R]

        REGISTER.ID, RTD

        [S]

        SQL.REQUEST

      • calculateFormula

        public void calculateFormula(boolean ignoreError)
        Calculates the result of formulas.
        Parameters:
        ignoreError - Indicates if hide the error in calculating formulas. The error may be unsupported function, external links, etc.
      • calculateFormula

        public void calculateFormula(boolean ignoreError, ICustomFunction customFunction)
        Calculates the result of formulas.
        Parameters:
        ignoreError - Indicates if hide the error in calculating formulas. The error may be unsupported function, external links, etc.
        customFunction - The custom formula calculation functions to extend the calculation engine.
      • calculateFormula

        public void calculateFormula(CalculationOptions options)
        Calcualting formulas in this workbook.
        Parameters:
        options - Options for calculation
      • getMatchingColor

        public com.aspose.cells.Color getMatchingColor(com.aspose.cells.Color rawColor)
        Find best matching Color in current palette.
        Parameters:
        rawColor - Raw color.
        Returns:
        Best matching color.
      • setEncryptionOptions

        public void setEncryptionOptions(int encryptionType, int keyLength)
        Set Encryption Options.
        Parameters:
        encryptionType - A EncryptionType value. The encryption type.
        keyLength - The key length.
      • protect

        public void protect(int protectionType, java.lang.String password)
        Protects a workbook.
        Parameters:
        protectionType - A ProtectionType value. Protection type.
        password - Password to protect the workbook.
      • protectSharedWorkbook

        public void protectSharedWorkbook(java.lang.String password)
        Protects a shared workbook.
        Parameters:
        password - Password to protect the workbook.
      • unprotect

        public void unprotect(java.lang.String password)
        Unprotects a workbook.
        Parameters:
        password - Password to unprotect the workbook.
      • unprotectSharedWorkbook

        public void unprotectSharedWorkbook(java.lang.String password)
        Unprotects a shared workbook.
        Parameters:
        password - Password to unprotect the workbook.
      • removeMacro

        public void removeMacro()
        Removes VBA/macro from this spreadsheet.
      • removeDigitalSignature

        public void removeDigitalSignature()
        Removes digital signature from this spreadsheet.
      • acceptAllRevisions

        public void acceptAllRevisions()
        Accepts all tracked changes in the workbook.
      • removeExternalLinks

        public void removeExternalLinks()
        Removes all external links in the workbook.
      • getThemeColor

        public com.aspose.cells.Color getThemeColor(int type)
        Gets theme color.
        Parameters:
        type - A ThemeColorType value. The theme color type.
        Returns:
        The theme color.
      • setThemeColor

        public void setThemeColor(int type, com.aspose.cells.Color color)
        Sets the theme color
        Parameters:
        type - A ThemeColorType value. The theme color type.
        color - the theme color
      • customTheme

        public void customTheme(java.lang.String themeName, com.aspose.cells.Color[] colors)
        Customs the theme. 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 
        Parameters:
        themeName - The theme name
        colors - The theme colors
      • copyTheme

        public void copyTheme(Workbook source)
        Copies the theme from another workbook.
        Parameters:
        source - Source workbook.
      • hasExernalLinks

        public boolean hasExernalLinks()
        Indicates whether this workbook contains external links to other data sources.
        Returns:
        Whether this workbook contains external links to other data sources.
      • updateLinkedDataSource

        public void updateLinkedDataSource(com.aspose.cells.Workbook[] exteralWorkbooks)
                                   throws java.lang.Exception
        If this workbook contains external links to other data source, Aspose.Cells will attempt to retrieve the latest data. If the method is not called before calculating formulas, Aspose.Cells will use the previous information(cached in the file); Please set CellsHelper.StartupPath,CellsHelper.AltStartPath,CellsHelper.LibraryPath. And please set Workbook.FilePath if this workbook is from a stream, otherwise Aspose.Cells could not get the external link full path sometimes.
        Parameters:
        exteralWorkbooks - External workbooks are referenced by this workbook. If it's null, we will directly open the external linked files.. If it's not null, we will check whether the external link in the array first; if not, we will open the external linked files again.
      • importXml

        public void importXml(java.lang.String url, java.lang.String sheetName, int row, int col)
                      throws java.lang.Exception
        Imports an xml file into the workbook.
        Parameters:
        url - the path of the xml file.
        sheetName - the destination sheet name .
        row - the destination row of the xml.
        col - the destination column of the xml.
      • exportXml

        public void exportXml(java.lang.String mapName, java.lang.String path)
                      throws java.lang.Exception
        Export XML data.
        Parameters:
        mapName - name of the XML map that need to be exported
        path - the export path
      • setDigitalSignature

        public void setDigitalSignature(DigitalSignatureCollection digitalSignatureCollection)
        Sets digital signature to an spreadsheet file (Excel2007 and later). Only support adding Xmldsig Digital Signature
        Parameters:
        digitalSignatureCollection -
      • addDigitalSignature

        public void addDigitalSignature(DigitalSignatureCollection digitalSignatureCollection)
        Adds digital signature to an OOXML spreadsheet file (Excel2007 and later). Only support adding Xmldsig Digital Signature to an OOXML spreadsheet file
        Parameters:
        digitalSignatureCollection -
      • dispose

        public void dispose()
        Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.