public class Workbook
extends java.lang.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.Example
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.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);
workbook.save("result.xlsx");
| Constructor and Description |
|---|
Workbook()
Initializes a new instance of the
Workbook class. |
Workbook(java.io.InputStream stream)
Initializes a new instance of the
Workbook class and open a stream. |
Workbook(java.io.InputStream stream,
LoadOptions loadOptions)
Initializes a new instance of the
Workbook class and open stream. |
Workbook(int fileFormatType)
Initializes a new instance of the
Workbook class. |
Workbook(java.lang.String file)
Initializes a new instance of the
Workbook class and open a file. |
Workbook(java.lang.String file,
LoadOptions loadOptions)
Initializes a new instance of the
Workbook class and open a file. |
| Modifier and Type | Method and Description |
|---|---|
void |
acceptAllRevisions()
Accepts all tracked changes in the workbook.
|
void |
addDigitalSignature(DigitalSignatureCollection digitalSignatureCollection)
Adds digital signature to an OOXML spreadsheet file (Excel2007 and later).
|
void |
calculateFormula()
Calculates the result of formulas.
|
void |
calculateFormula(boolean ignoreError)
Calculates the result of formulas.
|
void |
calculateFormula(CalculationOptions options)
Calculating formulas in this workbook.
|
void |
changePalette(Color color,
int index)
Changes the palette for the spreadsheet in the specified index.
|
void |
closeAccessCache(int opts)
Closes the session that uses caches to access data.
|
void |
combine(Workbook secondWorkbook)
Combines another Workbook object.
|
void |
copy(Workbook source)
Copies data from a source Workbook object.
|
void |
copy(Workbook source,
CopyOptions copyOptions)
Copies another Workbook object.
|
void |
copyTheme(Workbook source)
Copies the theme from another workbook.
|
Style |
createBuiltinStyle(int type)
Creates built-in style by given type.
|
CellsColor |
createCellsColor()
Creates a
CellsColor object. |
Style |
createStyle()
Creates a new style.
|
Style |
createStyle(boolean cloneDefaultStyle)
Creates a new style.
|
void |
customTheme(java.lang.String themeName,
Color[] colors)
Customs the theme.
|
void |
dispose()
Performs application-defined tasks associated with freeing, releasing, or
resetting unmanaged resources.
|
void |
exportXml(java.lang.String mapName,
java.io.OutputStream stream)
Export XML data linked by the specified XML map.
|
void |
exportXml(java.lang.String mapName,
java.lang.String path)
Export XML data linked by the specified XML map.
|
java.lang.String |
getAbsolutePath()
Gets the absolute path of the file.
|
BuiltInDocumentPropertyCollection |
getBuiltInDocumentProperties()
Returns a
DocumentProperty collection that represents all the built-in document properties of the spreadsheet. |
CellsDataTableFactory |
getCellsDataTableFactory()
Gets the factory for building ICellsDataTable from custom objects
|
Color[] |
getColors()
Returns colors in the palette for the spreadsheet.
|
ContentTypePropertyCollection |
getContentTypeProperties()
Gets the list of
ContentTypeProperty objects in the workbook. |
int |
getCountOfStylesInPool()
Gets number of the styles in the style pool.
|
CustomDocumentPropertyCollection |
getCustomDocumentProperties()
Returns a
DocumentProperty collection that represents all the custom document properties of the spreadsheet. |
CustomXmlPartCollection |
getCustomXmlParts()
Represents a Custom XML Data Storage Part (custom XML data within a package).
|
ExternalConnectionCollection |
getDataConnections()
Gets the
ExternalConnection collection. |
DataMashup |
getDataMashup()
Gets mashup data.
|
DataModel |
getDataModel()
Gets data model in the workbook.
|
DataSorter |
getDataSorter()
Gets a DataSorter object to sort data.
|
Style |
getDefaultStyle()
Gets the default
Style object of the workbook. |
DigitalSignatureCollection |
getDigitalSignature()
Gets digital signature from file.
|
int |
getFileFormat()
Gets the file format.
|
java.lang.String |
getFileName()
Gets the current file name.
|
Font[] |
getFonts()
Gets all fonts in the style pool.
|
AbstractInterruptMonitor |
getInterruptMonitor()
Gets the interrupt monitor.
|
Color |
getMatchingColor(Color rawColor)
Find best matching Color in current palette.
|
Style |
getNamedStyle(java.lang.String name)
Gets the named style in the style pool.
|
java.lang.String |
getRibbonXml()
Gets the XML file that defines the Ribbon UI.
|
WorkbookSettings |
getSettings()
Represents the workbook settings.
|
Style |
getStyleInPool(int index)
Gets the style in the style pool.
|
java.lang.String |
getTheme()
Gets the theme name.
|
Color |
getThemeColor(int type)
Gets theme color.
|
VbaProject |
getVbaProject()
Gets the
getVbaProject() in a spreadsheet. |
WorksheetCollection |
getWorksheets()
Gets the
WorksheetCollection collection in the spreadsheet. |
boolean |
hasCustomFunction()
Detects whether there is custom function used in this workbook,
such as in cell's formula, in defined names...
|
boolean |
hasExernalLinks()
Deprecated.
Use ExternalLinkCollection.Count property instead.
|
boolean |
hasMacro()
Indicates if this spreadsheet contains macro/VBA.
|
boolean |
hasRevisions()
Gets if the workbook has any tracked changes
|
void |
importXml(java.io.InputStream stream,
java.lang.String sheetName,
int row,
int col)
Imports/Updates an XML data file into the workbook.
|
void |
importXml(java.lang.String url,
java.lang.String sheetName,
int row,
int col)
Imports/Updates an XML data file into the workbook.
|
boolean |
isColorInPalette(Color color)
Checks if a color is in the palette for the spreadsheet.
|
boolean |
isDigitallySigned()
Indicates if this spreadsheet is digitally signed.
|
boolean |
isLicensed()
Indicates whether license is set.
|
boolean |
isWorkbookProtectedWithPassword()
Indicates whether structure or window is protected with password.
|
void |
mergeNamedStyles(Workbook source)
Merges named styles from the other Excel file.
|
void |
parseFormulas(boolean ignoreError)
Parses all formulas which have not been parsed when they were loaded from template file or set to a cell.
|
void |
protect(int protectionType,
java.lang.String password)
Protects a workbook.
|
void |
protectSharedWorkbook(java.lang.String password)
Protects a shared workbook.
|
void |
refreshDynamicArrayFormulas(boolean 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.
|
void |
refreshDynamicArrayFormulas(boolean calculate,
CalculationOptions copts)
Refreshes dynamic array formulas(spill into new range of neighboring cells according to current data)
|
void |
removeDigitalSignature()
Removes digital signature from this spreadsheet.
|
void |
removeExternalLinks()
Deprecated.
Use ExternalLinkCollection.Clear() method instead.
|
void |
removeMacro()
Removes VBA/macro from this spreadsheet.
|
void |
removePersonalInformation()
Removes personal information.
|
void |
removeUnusedStyles()
Remove all unused styles.
|
int |
replace(boolean boolValue,
java.lang.Object newValue)
Replaces cells' values with new data.
|
int |
replace(int intValue,
java.lang.Object newValue)
Replaces cells' values with new data.
|
int |
replace(java.lang.String placeHolder,
double newValue)
Replaces a cell's value with a new double.
|
int |
replace(java.lang.String placeHolder,
double[] newValues,
boolean isVertical)
Replaces cells' values with a double array.
|
int |
replace(java.lang.String placeHolder,
int newValue)
Replaces a cell's value with a new integer.
|
int |
replace(java.lang.String placeHolder,
int[] newValues,
boolean isVertical)
Replaces cells' values with an integer array.
|
int |
replace(java.lang.String placeHolder,
java.lang.String newValue)
Replaces a cell's value with a new string.
|
int |
replace(java.lang.String placeHolder,
java.lang.String[] newValues,
boolean isVertical)
Replaces a cell's value with a new string array.
|
int |
replace(java.lang.String placeHolder,
java.lang.String newValue,
ReplaceOptions options)
Replaces a cell's value with a new string.
|
void |
save(java.io.OutputStream stream,
int saveFormat)
Save the workbook to the stream.
|
void |
save(java.io.OutputStream stream,
SaveOptions saveOptions)
Save the workbook to the stream.
|
void |
save(java.lang.String fileName)
Save the workbook to the disk.
|
void |
save(java.lang.String fileName,
int saveFormat)
Saves the workbook to the disk.
|
void |
save(java.lang.String fileName,
SaveOptions saveOptions)
Saves the workbook to the disk.
|
void |
setAbsolutePath(java.lang.String value)
Sets the absolute path of the file.
|
void |
setDefaultStyle(Style value)
Sets the default
Style object of the workbook. |
void |
setDigitalSignature(DigitalSignatureCollection digitalSignatureCollection)
Sets digital signature to an spreadsheet file (Excel2007 and later).
|
void |
setEncryptionOptions(int encryptionType,
int keyLength)
Set Encryption Options.
|
void |
setFileFormat(int value)
Sets the file format.
|
void |
setFileName(java.lang.String value)
Sets the current file name.
|
void |
setInterruptMonitor(AbstractInterruptMonitor value)
Sets the interrupt monitor.
|
void |
setRibbonXml(java.lang.String value)
Sets the XML file that defines the Ribbon UI.
|
void |
setThemeColor(int type,
Color color)
Sets the theme color
|
void |
startAccessCache(int opts)
Starts the session that uses caches to access data.
|
void |
unprotect(java.lang.String password)
Unprotects a workbook.
|
void |
unprotectSharedWorkbook(java.lang.String password)
Unprotects a shared workbook.
|
void |
updateCustomFunctionDefinition(CustomFunctionDefinition definition)
Updates definition of custom functions.
|
void |
updateLinkedDataSource(Workbook[] externalWorkbooks)
If this workbook contains external links to other data source,
Aspose.Cells will attempt to retrieve the latest data from give sources.
|
public Workbook()
Workbook class.
Remarks
The default file format type is Xlsx. If you want to create other types of files, please use Workbook(FileFormatType).Example
The following code shows how to use the Workbook constructor to create and initialize a new instance of the class.
Workbook workbook = new Workbook();
public Workbook(int fileFormatType)
Workbook class.
Remarks
The default file format type is Excel97To2003.Example
The following code shows how to use the Workbook constructor to create and initialize a new instance of the class with various file format type.
Workbook workbook = new Workbook(FileFormatType.XLSX);
fileFormatType - FileFormatType.
The new file format.public Workbook(java.lang.String file)
Workbook class and open a file.file - The file name.public Workbook(java.io.InputStream stream)
Workbook class and open a stream.stream - The stream.public Workbook(java.lang.String file,
LoadOptions loadOptions)
Workbook class and open a file.file - The file name.loadOptions - The load optionspublic Workbook(java.io.InputStream stream,
LoadOptions loadOptions)
Workbook class and open stream.stream - The stream.loadOptions - The load optionspublic WorkbookSettings getSettings()
public void parseFormulas(boolean ignoreError)
ignoreError - 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.public void startAccessCache(int opts)
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.closeAccessCache(int) should
be invoked with same options to clear all caches and recover normal access mode.
opts - AccessCacheOptions. options of data accesspublic void closeAccessCache(int opts)
opts - AccessCacheOptions. options of data accesspublic void save(java.lang.String fileName,
int saveFormat)
fileName - The file name.saveFormat - SaveFormat. The save format type.public void save(java.lang.String fileName)
fileName - public void save(java.lang.String fileName,
SaveOptions saveOptions)
fileName - The file name.saveOptions - The save options.public void save(java.io.OutputStream stream,
SaveOptions saveOptions)
stream - The file stream.saveOptions - The save options.public void save(java.io.OutputStream stream,
int saveFormat)
stream - The file stream.saveFormat - SaveFormat. The save file format type.public WorksheetCollection getWorksheets()
WorksheetCollection collection in the spreadsheet.WorksheetCollection collectionpublic boolean isLicensed()
public void removeUnusedStyles()
public Style createStyle()
public Style createStyle(boolean cloneDefaultStyle)
cloneDefaultStyle - Incidates whether clones the default stylepublic Style createBuiltinStyle(int type)
type - BuiltinStyleType. The builtin style stype.Style objectpublic CellsColor createCellsColor()
CellsColor object.CellsColor object.public int replace(java.lang.String placeHolder,
java.lang.String newValue)
Example
Workbook workbook = new Workbook();
//......
workbook.replace("AnOldValue", "NewValue");
placeHolder - Cell placeholdernewValue - String value to replacepublic int replace(java.lang.String placeHolder,
int newValue)
Example
Workbook workbook = new Workbook();
//......
int newValue = 100;
workbook.replace("AnOldValue", newValue);
placeHolder - Cell placeholdernewValue - Integer value to replacepublic int replace(java.lang.String placeHolder,
double newValue)
Example
Workbook workbook = new Workbook();
//......
double newValue = 100.0;
workbook.replace("AnOldValue", newValue);
placeHolder - Cell placeholdernewValue - Double value to replacepublic int replace(java.lang.String placeHolder,
java.lang.String[] newValues,
boolean isVertical)
Example
Workbook workbook = new Workbook();
//......
String[] newValues = new String[]{"Tom", "Alice", "Jerry"};
workbook.replace("AnOldValue", newValues, true);
placeHolder - Cell placeholdernewValues - String array to replaceisVertical - True - Vertical, False - Horizontalpublic int replace(java.lang.String placeHolder,
int[] newValues,
boolean isVertical)
Example
Workbook workbook = new Workbook();
//......
int[] newValues = new int[]{1, 2, 3};
workbook.replace("AnOldValue", newValues, true);
placeHolder - Cell placeholdernewValues - Integer array to replaceisVertical - True - Vertical, False - Horizontalpublic int replace(java.lang.String placeHolder,
double[] newValues,
boolean isVertical)
Example
Workbook workbook = new Workbook();
//......
double[] newValues = new double[]{1.23, 2.56, 3.14159};
workbook.replace("AnOldValue", newValues, true);
placeHolder - Cell placeholdernewValues - Double array to replaceisVertical - True - Vertical, False - Horizontalpublic int replace(boolean boolValue,
java.lang.Object newValue)
boolValue - The boolean value to be replaced.newValue - New value. Can be string, integer, double or DateTime value.public int replace(int intValue,
java.lang.Object newValue)
intValue - The integer value to be replaced.newValue - New value. Can be string, integer, double or DateTime value.public int replace(java.lang.String placeHolder,
java.lang.String newValue,
ReplaceOptions options)
placeHolder - Cell placeholdernewValue - String value to replaceoptions - The replace optionspublic void copy(Workbook source, CopyOptions copyOptions)
Remarks
It's very simple to clone an Excel file.source - Source Workbook object.copyOptions - The options of copying other workbook.public void copy(Workbook source)
source - Source Workbook object.public void combine(Workbook secondWorkbook)
Remarks
Merge Excel, ODS , CSV and other files to one file.secondWorkbook - Another Workbook object.public Color[] getColors()
Remarks
The palette has 56 entries, each represented by an RGB value.public Style getStyleInPool(int index)
Remarks
If the returned style is changed, the style of all cells(which refers to this style) will be changed.index - The index.public int getCountOfStylesInPool()
public Font[] getFonts()
public Style getNamedStyle(java.lang.String name)
name - name of the stylepublic void mergeNamedStyles(Workbook source)
source - The other filepublic void changePalette(Color color, int index)
Remarks
The palette has 56 entries, each represented by an RGB value.
If you set a color which is not in the palette, it will not take effect.
So if you want to set a custom color, please change the palette at first.
The following is the standard color palette.
| Color | Red | Green | Blue |
|---|---|---|---|
| Black | 0 | 0 | 0 |
| White | 255 | 255 | 255 |
| Red | 255 | 0 | 0 |
| Lime | 0 | 255 | 0 |
| Blue | 0 | 0 | 255 |
| Yellow | 255 | 255 | 0 |
| Magenta | 255 | 0 | 255 |
| Cyan | 0 | 255 | 255 |
| Maroon | 128 | 0 | 0 |
| Green | 0 | 128 | 0 |
| Navy | 0 | 0 | 128 |
| Olive | 128 | 128 | 0 |
| Purple | 128 | 0 | 128 |
| Teal | 0 | 128 | 128 |
| Silver | 192 | 192 | 192 |
| Gray | 128 | 128 | 128 |
| Color17 | 153 | 153 | 255 |
| Color18 | 153 | 51 | 102 |
| Color19 | 255 | 255 | 204 |
| Color20 | 204 | 255 | 255 |
| Color21 | 102 | 0 | 102 |
| Color22 | 255 | 128 | 128 |
| Color23 | 0 | 102 | 204 |
| Color24 | 204 | 204 | 255 |
| Color25 | 0 | 0 | 128 |
| Color26 | 255 | 0 | 255 |
| Color27 | 255 | 255 | 0 |
| Color28 | 0 | 255 | 255 |
| Color29 | 128 | 0 | 128 |
| Color30 | 128 | 0 | 0 |
| Color31 | 0 | 128 | 128 |
| Color32 | 0 | 0 | 255 |
| Color33 | 0 | 204 | 255 |
| Color34 | 204 | 255 | 255 |
| Color35 | 204 | 255 | 204 |
| Color36 | 255 | 255 | 153 |
| Color37 | 153 | 204 | 255 |
| Color38 | 255 | 153 | 204 |
| Color39 | 204 | 153 | 255 |
| Color40 | 255 | 204 | 153 |
| Color41 | 51 | 102 | 255 |
| Color42 | 51 | 204 | 204 |
| Color43 | 153 | 204 | 0 |
| Color44 | 255 | 204 | 0 |
| Color45 | 255 | 153 | 0 |
| Color46 | 255 | 102 | 0 |
| Color47 | 102 | 102 | 153 |
| Color48 | 150 | 150 | 150 |
| Color49 | 0 | 51 | 102 |
| Color50 | 51 | 153 | 102 |
| Color51 | 0 | 51 | 0 |
| Color52 | 51 | 51 | 0 |
| Color53 | 153 | 51 | 0 |
| Color54 | 153 | 51 | 102 |
| Color55 | 51 | 51 | 153 |
| Color56 | 51 | 51 | 51 |
color - Color structure.index - Palette index, 0 - 55.public boolean isColorInPalette(Color color)
color - Color structure.public void calculateFormula()
Remarks
For all supported formulas, please see the list at https://docs.aspose.com/display/cellsnet/Supported+Formula+Functionspublic void calculateFormula(boolean ignoreError)
ignoreError - Indicates if hide the error in calculating formulas. The error may be unsupported function, external links, etc.public void calculateFormula(CalculationOptions options)
options - Options for calculationpublic void refreshDynamicArrayFormulas(boolean calculate)
calculate - Whether calculates and updates cell values for those dynamic array formulaspublic void refreshDynamicArrayFormulas(boolean calculate,
CalculationOptions copts)
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.calculateFormula(CalculationOptions)),
then using false vlaue for "calculate" flag may avoid the duplicated calculation for the benefit of performance.calculate - Whether calculates and updates cell values for those dynamic array formulascopts - The options for calculating formulaspublic Style getDefaultStyle()
Style object of the workbook.
Remarks
The DefaultStyle property is useful to implement a Style for the whole Workbook.Example
The following code creates and instantiates a new Workbook and sets a defaultStyle to it.
Workbook workbook = new Workbook();
Style defaultStyle = workbook.getDefaultStyle();
defaultStyle.getFont().setName("Tahoma");
workbook.setDefaultStyle(defaultStyle);
public void setDefaultStyle(Style value)
Style object of the workbook.
Remarks
The DefaultStyle property is useful to implement a Style for the whole Workbook.public Color getMatchingColor(Color rawColor)
Remarks
There are only 56 colors in the color palette in Excel 97-2003. If the color is not in the palette, the similar color will be set.rawColor - Raw color.public boolean isDigitallySigned()
public void setEncryptionOptions(int encryptionType,
int keyLength)
encryptionType - EncryptionType. The encryption type.keyLength - The key length.public void protect(int protectionType,
java.lang.String password)
protectionType - ProtectionType. Protection type.password - Password to protect the workbook.public void protectSharedWorkbook(java.lang.String password)
password - Password to protect the workbook.public void unprotect(java.lang.String password)
password - Password to unprotect the workbook.public void unprotectSharedWorkbook(java.lang.String password)
password - Password to unprotect the workbook.public boolean isWorkbookProtectedWithPassword()
public void removeMacro()
public VbaProject getVbaProject()
getVbaProject() in a spreadsheet.public void removeDigitalSignature()
public void acceptAllRevisions()
public boolean hasMacro()
public boolean hasRevisions()
public java.lang.String getFileName()
Remarks
If the file is opened by stream and there are some external formula references, please set the file name.public void setFileName(java.lang.String value)
Remarks
If the file is opened by stream and there are some external formula references, please set the file name.public CellsDataTableFactory getCellsDataTableFactory()
public DataSorter getDataSorter()
public void removeExternalLinks()
Remarks
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.public Color getThemeColor(int type)
type - ThemeColorType. The theme color type.public void setThemeColor(int type,
Color color)
type - ThemeColorType. The theme color type.color - the theme colorpublic java.lang.String getTheme()
public void customTheme(java.lang.String themeName,
Color[] colors)
Remarks
The length of colors should be 12.| Array index | Theme type |
|---|---|
| 0 | Backgournd1 |
| 1 | Text1 |
| 2 | Backgournd2 |
| 3 | Text2 |
| 4 | Accent1 |
| 5 | Accent2 |
| 6 | Accent3 |
| 7 | Accent4 |
| 8 | Accent5 |
| 9 | Accent6 |
| 10 | Hyperlink |
| 11 | Followed Hyperlink |
themeName - The theme namecolors - The theme colorspublic void copyTheme(Workbook source)
source - Source workbook.public boolean hasExernalLinks()
Remarks
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.public void updateCustomFunctionDefinition(CustomFunctionDefinition definition)
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 implementedCustomFunctionDefinition.getArrayModeParameters(String) for those functions.
After the data of formulas being updated, those specified parameters will be calculated in array mode automatically
when calculating corresponding custom functions.definition - Special definition of custom functions for user's special requirement.public void updateLinkedDataSource(Workbook[] externalWorkbooks)
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.externalWorkbooks - 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 getFileName()
and ExternalLink.getDataSource(). So please make sure getFileName() has
been specified with the proper value for every workbook so they can be linked to corresponding external link.public BuiltInDocumentPropertyCollection getBuiltInDocumentProperties()
DocumentProperty collection that represents all the built-in document properties of the spreadsheet.
Remarks
A new property cannot be added to built-in document properties list. You can only get a built-in property and change its value. The following is the built-in properties name list:Title
Subject
Author
Keywords
Comments
Template
Last Author
Revision Number
Application Name
Last Print Date
Creation Date
Last Save Time
Total Editing Time
Number of Pages
Number of Words
Number of Characters
Security
Category
Format
Manager
Company
Number of Bytes
Number of Lines
Number of Paragraphs
Number of Slides
Number of Notes
Number of Hidden Slides
Number of Multimedia Clips
Example
Workbook workbook = new Workbook();
DocumentProperty doc = workbook.getBuiltInDocumentProperties().get("Author");
doc.setValue("John Smith");
public CustomDocumentPropertyCollection getCustomDocumentProperties()
DocumentProperty collection that represents all the custom document properties of the spreadsheet.
Example
Workbook excel = new Workbook();
excel.getCustomDocumentProperties().add("Checked by", "Jane");
public int getFileFormat()
See FileFormatType.
public void setFileFormat(int value)
See FileFormatType.
public boolean hasCustomFunction()
public AbstractInterruptMonitor getInterruptMonitor()
public void setInterruptMonitor(AbstractInterruptMonitor value)
public ContentTypePropertyCollection getContentTypeProperties()
ContentTypeProperty objects in the workbook.public CustomXmlPartCollection getCustomXmlParts()
public DataMashup getDataMashup()
public java.lang.String getRibbonXml()
public void setRibbonXml(java.lang.String value)
public java.lang.String getAbsolutePath()
Remarks
Only used for external links.public void setAbsolutePath(java.lang.String value)
Remarks
Only used for external links.public ExternalConnectionCollection getDataConnections()
ExternalConnection collection.public void importXml(java.lang.String url,
java.lang.String sheetName,
int row,
int col)
Example
The following code imports xml data into worksheet 'Sheet 1' at Cell A1.
Workbook wb = new Workbook("Book1.xlsx");
wb.importXml("xml.xml", "Sheet1", 0, 0);
wb.save("output.xlsx");
url - the url/path of the xml file.sheetName - the destination sheet name.row - the destination rowcol - the destination columnpublic void importXml(java.io.InputStream stream,
java.lang.String sheetName,
int row,
int col)
stream - the xml file stream.sheetName - the destination sheet name.row - the destination row.col - the destination column.public void exportXml(java.lang.String mapName,
java.lang.String path)
Example
The following code exported the data linked by the first XmlMap.
Workbook wb = new Workbook("Book1.xlsx");
//Make sure that the source xlsx file contains a XmlMap.
XmlMap xmlMap = wb.getWorksheets().getXmlMaps().get(0);
wb.exportXml(xmlMap.getName(), "output.xml");
mapName - name of the XML map that need to be exportedpath - the export pathpublic void exportXml(java.lang.String mapName,
java.io.OutputStream stream)
mapName - name of the XML map that need to be exportedstream - the export streampublic void setDigitalSignature(DigitalSignatureCollection digitalSignatureCollection)
Remarks
Only support adding Xmldsig Digital SignaturedigitalSignatureCollection - public void addDigitalSignature(DigitalSignatureCollection digitalSignatureCollection)
Remarks
Only support adding Xmldsig Digital Signature to an OOXML spreadsheet filedigitalSignatureCollection - public DigitalSignatureCollection getDigitalSignature()
public void removePersonalInformation()
public DataModel getDataModel()
public void dispose()
See Also:
Aspose.Cells Documentation - the home page for the Aspose.Cells Product Documentation.
Aspose.Cells Support Forum - our preferred method of support.
We guarantee a prompt response to any inquiry!
© Aspose Pty Ltd 2003-2025. All Rights Reserved.