public class WorksheetCollection extends CollectionBase
Range.getWorksheet() objects.
Example
Workbook workbook = new Workbook();
WorksheetCollection sheets = workbook.getWorksheets();
//Add a worksheet
sheets.add();
//Change the name of a worksheet
sheets.get(0).setName("First Sheet");
//Set the active sheet to the second worksheet
sheets.setActiveSheetIndex(1);
| Modifier and Type | Method and Description |
|---|---|
int |
add()
Adds a worksheet to the collection.
|
int |
add(int type)
Adds a worksheet to the collection.
|
Worksheet |
add(java.lang.String sheetName)
Adds a worksheet to the collection.
|
int |
addCopy(int sheetIndex)
Adds a worksheet to the collection and copies data from an existed worksheet.
|
int |
addCopy(java.lang.String sheetName)
Adds a worksheet to the collection and copies data from an existed worksheet.
|
void |
addCopy(Worksheet[] source,
java.lang.String[] destSheetNames)
Copy a group of worksheets.
|
void |
clear()
Clear all worksheets.
|
void |
clearPivottables()
Clears pivot tables from the spreadsheet.
|
Range |
createRange(java.lang.String address,
int sheetIndex)
Creates a
Range object from an address of the range. |
UnionRange |
createUnionRange(java.lang.String address,
int sheetIndex)
Creates a
Range object from an address of the range. |
Worksheet |
get(int index)
Gets the
Range.getWorksheet() element at the specified index. |
Worksheet |
get(java.lang.String sheetName)
Gets the
Range.getWorksheet() element with the specified name. |
int |
getActiveSheetIndex()
Represents the index of active worksheet when the spreadsheet is opened.
|
java.lang.String |
getActiveSheetName()
Represents the name of active worksheet when the spreadsheet is opened.
|
BuiltInDocumentPropertyCollection |
getBuiltInDocumentProperties()
Returns a
DocumentProperty collection that represents all the built-in document properties of the spreadsheet. |
CustomDocumentPropertyCollection |
getCustomDocumentProperties()
Returns a
DocumentProperty collection that represents all the custom document properties of the spreadsheet. |
DxfCollection |
getDxfs()
Gets the master differential formatting records.
|
ExternalLinkCollection |
getExternalLinks()
Represents external links in a workbook.
|
Range[] |
getNamedRanges()
Gets all pre-defined named ranges in the spreadsheet.
|
Range[] |
getNamedRangesAndTables()
Gets all pre-defined named ranges in the spreadsheet.
|
NameCollection |
getNames()
Gets the collection of all the Name objects in the spreadsheet.
|
java.lang.Object |
getOleSize()
Gets displayed size when Workbook file is used as an Ole object.
|
Range |
getRangeByName(java.lang.String rangeName)
Gets Range object by pre-defined name.
|
Range |
getRangeByName(java.lang.String rangeName,
int currentSheetIndex,
boolean includeTable)
Gets
Range by pre-defined name or table's name |
RevisionLogCollection |
getRevisionLogs()
Represents revision logs.
|
SensitivityLabelCollection |
getSensitivityLabels()
Represents all sensitivity labels.
|
Worksheet |
getSheetByCodeName(java.lang.String codeName)
Gets the worksheet by the code name.
|
TableStyleCollection |
getTableStyles()
Gets
getTableStyles() object. |
ThreadedCommentAuthorCollection |
getThreadedCommentAuthors()
Gets the list of threaded comment authors.
|
WebExtensionCollection |
getWebExtensions()
Gets the list of task panes.
|
WebExtensionTaskPaneCollection |
getWebExtensionTaskPanes()
Gets the list of task panes.
|
XmlMapCollection |
getXmlMaps()
Gets the XML maps in the workbook.
|
Worksheet |
insert(int index,
int sheetType)
Insert a worksheet.
|
Worksheet |
insert(int index,
int sheetType,
java.lang.String sheetName)
Insert a worksheet.
|
boolean |
isRefreshAllConnections()
Indicates whether refresh all connections on opening file in MS Excel.
|
void |
refreshAll()
Refresh all pivot tables and charts with pivot source.
|
void |
refreshPivotTables()
Refreshes all the PivotTables in the Excel file.
|
boolean |
refreshPivotTables(PivotTableRefreshOption option)
Refreshes all the PivotTables in the Excel file.
|
java.lang.String |
registerAddInFunction(int id,
java.lang.String functionName)
Adds addin function into the workbook
|
int |
registerAddInFunction(java.lang.String addInFile,
java.lang.String functionName,
boolean lib)
Adds addin function into the workbook
|
void |
removeAt(int index)
Removes the element at a specified index.
|
void |
removeAt(java.lang.String name)
Removes the element at a specified name.
|
void |
setActiveSheetIndex(int value)
Represents the index of active worksheet when the spreadsheet is opened.
|
void |
setActiveSheetName(java.lang.String value)
Represents the name of active worksheet when the spreadsheet is opened.
|
void |
setOleSize(int startRow,
int endRow,
int startColumn,
int endColumn)
Sets displayed size when Workbook file is used as an Ole object.
|
void |
setOleSize(java.lang.Object value)
Sets displayed size when Workbook file is used as an Ole object.
|
void |
setRefreshAllConnections(boolean value)
Indicates whether refresh all connections on opening file in MS Excel.
|
void |
setXmlMaps(XmlMapCollection value)
Sets the XML maps in the workbook.
|
void |
sortNames()
Sorts the defined names.
|
void |
swapSheet(int sheetIndex1,
int sheetIndex2)
Swaps the two sheets.
|
public WebExtensionTaskPaneCollection getWebExtensionTaskPanes()
public WebExtensionCollection getWebExtensions()
public ThreadedCommentAuthorCollection getThreadedCommentAuthors()
public boolean isRefreshAllConnections()
public void setRefreshAllConnections(boolean value)
public Range createRange(java.lang.String address, int sheetIndex)
Range object from an address of the range.address - The address of the range.sheetIndex - The sheet index.Range objectpublic UnionRange createUnionRange(java.lang.String address, int sheetIndex)
Range object from an address of the range.address - The address of the range.sheetIndex - The sheet index.Range objectpublic NameCollection getNames()
public Worksheet get(int index)
Range.getWorksheet() element at the specified index.get in class CollectionBaseindex - The zero based index of the element.public Worksheet get(java.lang.String sheetName)
Range.getWorksheet() element with the specified name.sheetName - Worksheet namepublic Worksheet getSheetByCodeName(java.lang.String codeName)
codeName - Worksheet code name.public java.lang.String getActiveSheetName()
public void setActiveSheetName(java.lang.String value)
public int getActiveSheetIndex()
Remarks
Sheet index is zero based.public void setActiveSheetIndex(int value)
Remarks
Sheet index is zero based.public void sortNames()
Remarks
If you create a large amount of named ranges in the Excel file, please call this method after all named ranges are created and before savingpublic Worksheet insert(int index, int sheetType)
index - The sheet indexsheetType - SheetType. The sheet type.public Worksheet insert(int index, int sheetType, java.lang.String sheetName)
index - The sheet indexsheetType - SheetType. The sheet type.sheetName - The sheet name.public int add(int type)
Example
Workbook workbook = new Workbook();
workbook.getWorksheets().add(SheetType.CHART);
Cells cells = workbook.getWorksheets().get(0).getCells();
cells.get("c2").putValue(5000);
cells.get("c3").putValue(3000);
cells.get("c4").putValue(4000);
cells.get("c5").putValue(5000);
cells.get("c6").putValue(6000);
ChartCollection charts = workbook.getWorksheets().get(1).getCharts();
int chartIndex = charts.add(ChartType.COLUMN, 10,10,20,20);
Chart chart = charts.get(chartIndex);
chart.getNSeries().add("Sheet1!C2:C6", true);
type - SheetType. Worksheet type.Range.getWorksheet() object index.public void swapSheet(int sheetIndex1,
int sheetIndex2)
sheetIndex1 - The first worksheet.sheetIndex2 - The second worksheet.public int add()
Range.getWorksheet() object index.public Worksheet add(java.lang.String sheetName)
sheetName - Worksheet nameRange.getWorksheet() object.public int registerAddInFunction(java.lang.String addInFile,
java.lang.String functionName,
boolean lib)
addInFile - the file contains the addin functionsfunctionName - the addin function namelib - whether the given addin file is in the directory or sub-directory of Workbook Add-In library.
This flag takes effect and makes difference when given addInFile is of relative path:
true denotes the path is relative to Add-In library and false denotes the path is relative to this Workbook.public java.lang.String registerAddInFunction(int id,
java.lang.String functionName)
id - ID of the data which contains addin functions,
can be got by the first call of registerAddInFunction(String,String,boolean) for the same addin file.functionName - the addin function namepublic void removeAt(java.lang.String name)
name - The name of the element to remove.public void removeAt(int index)
removeAt in class CollectionBaseindex - The index value of the element to remove.public void clear()
Remarks
A workbook must contains a worksheet.clear in class CollectionBasepublic int addCopy(java.lang.String sheetName)
sheetName - Name of source worksheet.Range.getWorksheet() object index.public int addCopy(int sheetIndex)
sheetIndex - Index of source worksheet.Range.getWorksheet() object index.public void addCopy(Worksheet[] source, java.lang.String[] destSheetNames)
source - The source worksheets.destSheetNames - The names of the copied sheets.public DxfCollection getDxfs()
public Range getRangeByName(java.lang.String rangeName)
rangeName - Name of range.public Range getRangeByName(java.lang.String rangeName, int currentSheetIndex, boolean includeTable)
Range by pre-defined name or table's namerangeName - Name of range or table's name.currentSheetIndex - The sheet index. -1 represents global .includeTable - Indicates whether checking all tables.public Range[] getNamedRanges()
public Range[] getNamedRangesAndTables()
public XmlMapCollection getXmlMaps()
public void setXmlMaps(XmlMapCollection value)
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.getWorksheets().getBuiltInDocumentProperties().get("Author");
doc.setValue("John Smith");
public CustomDocumentPropertyCollection getCustomDocumentProperties()
DocumentProperty collection that represents all the custom document properties of the spreadsheet.
Example
Workbook workbook = new Workbook();
workbook.getWorksheets().getCustomDocumentProperties().add("Checked by", "Jane");
public java.lang.Object getOleSize()
Remarks
Null means no ole size setting.public void setOleSize(java.lang.Object value)
Remarks
Null means no ole size setting.public void setOleSize(int startRow,
int endRow,
int startColumn,
int endColumn)
Remarks
This method is generally used to adjust display size in ppt file or doc file.startRow - Start row index.endRow - End row index.startColumn - Start column index.endColumn - End column index.public ExternalLinkCollection getExternalLinks()
public TableStyleCollection getTableStyles()
getTableStyles() object.public void clearPivottables()
public RevisionLogCollection getRevisionLogs()
public void refreshAll()
public void refreshPivotTables()
public boolean refreshPivotTables(PivotTableRefreshOption option)
option - The option for refreshing data source of the pivot tables.public SensitivityLabelCollection getSensitivityLabels()
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.