com.aspose.cells
Class WorksheetCollection

java.lang.Object
  extended by CollectionBase
      extended by com.aspose.cells.WorksheetCollection
All Implemented Interfaces:
java.lang.Iterable

public abstract class WorksheetCollection 
extends CollectionBase

Encapsulates a collection of Worksheet 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.setActiveSheet(1);

Property Getters/Setters Summary
abstract intgetActiveSheetIndex()
abstract voidsetActiveSheetIndex(int value)
           Represents the index of active worksheet when the spreadsheet is opened.
abstract BuiltInDocumentPropertyCollectiongetBuiltInDocumentProperties()
           Returns a DocumentProperties collection that represents all the built-in document properties of the spreadsheet.
intgetCount()→ inherited from CollectionBase
          
abstract CustomDocumentPropertyCollectiongetCustomDocumentProperties()
           Returns a DocumentProperties collection that represents all the custom document properties of the spreadsheet.
abstract DxfCollectiongetDxfs()
           Gets the master differential formatting records.
abstract ExternalLinkCollectiongetExternalLinks()
           Represents external links in a workbook.
abstract booleanisRefreshAllConnections()
abstract voidsetRefreshAllConnections(boolean value)
           Indicates whether refresh all connections on opening file in MS Excel.
abstract NameCollectiongetNames()
           Gets the collection of all the Name objects in the spreadsheet.
abstract java.lang.ObjectgetOleSize()
abstract voidsetOleSize(java.lang.Object value)
           Gets and Sets displayed size when Workbook file is used as an Ole object.
abstract TableStyleCollectiongetTableStyles()
           Gets TableStyles object.
abstract XmlMapCollectiongetXmlMaps()
abstract voidsetXmlMaps(XmlMapCollection value)
           Gets and sets the XML maps in the workbook.
abstract Worksheetget(int index)
           Gets the Worksheet element at the specified index.
abstract Worksheetget(java.lang.String sheetName)
           Gets the Worksheet element with the specified name.
 
Method Summary
abstract intadd()
           Adds a worksheet to the collection.
abstract intadd(int type)
           Adds a worksheet to the collection.
intadd(java.lang.Object value)→ inherited from CollectionBase
          Reserved for internal use.
abstract Worksheetadd(java.lang.String sheetName)
           Adds a worksheet to the collection.
abstract intaddCopy(int sheetIndex)
           Adds a worksheet to the collection and copies data from an existed worksheet.
abstract intaddCopy(java.lang.String sheetName)
           Adds a worksheet to the collection and copies data from an existed worksheet.
abstract voidclear()
           Clear all worksheets.
abstract voidclearPivottables()
           Clears pivot tables from the spreadsheet.
booleancontains(java.lang.Object value)→ inherited from CollectionBase
          Reserved for internal use.
abstract RangecreateRange(java.lang.String address, int sheetIndex)
           Creates a Range object from an address of the range.
java.lang.Objectget(int index)→ inherited from CollectionBase
          Reserved for internal use.
abstract Range[]getNamedRanges()
           Gets all pre-defined named ranges in the spreadsheet.
abstract Range[]getNamedRangesAndTables()
           Gets all pre-defined named ranges in the spreadsheet.
abstract RangegetRangeByName(java.lang.String rangeName)
           Gets Range object by pre-defined name.
abstract WorksheetgetSheetByCodeName(java.lang.String codeName)
           Gets the worksheet by the code name.
intindexOf(java.lang.Object value)→ inherited from CollectionBase
          Reserved for internal use.
abstract Worksheetinsert(int index, int sheetType)
           Insert a worksheet.
abstract Worksheetinsert(int index, int sheetType, java.lang.String sheetName)
           Insert a worksheet.
java.util.Iteratoriterator()→ inherited from CollectionBase
          
abstract voidremoveAt(int index)
           Removes the element at a specified index.
abstract voidremoveAt(java.lang.String name)
           Removes the element at a specified name.
abstract voidsetOleSize(int startRow, int endRow, int startColumn, int endColumn)
           Sets displayed size when Workbook file is used as an Ole object.
abstract voidsortNames()
           Sorts defined names.
abstract voidswapSheet(int sheetIndex1, int sheetIndex2)
           Swaps the two sheets.
 

Property Getters/Setters Detail

isRefreshAllConnections/setRefreshAllConnections

public abstract boolean isRefreshAllConnections() / public abstract void setRefreshAllConnections(boolean value)
Indicates whether refresh all connections on opening file in MS Excel.

getNames

public abstract NameCollection getNames()
Gets the collection of all the Name objects in the spreadsheet.

getActiveSheetIndex/setActiveSheetIndex

public abstract int getActiveSheetIndex() / public abstract void setActiveSheetIndex(int value)
Represents the index of active worksheet when the spreadsheet is opened. Sheet index is zero based.

getDxfs

public abstract DxfCollection getDxfs()
Gets the master differential formatting records.

getXmlMaps/setXmlMaps

public abstract XmlMapCollection getXmlMaps() / public abstract void setXmlMaps(XmlMapCollection value)
Gets and sets the XML maps in the workbook.

getBuiltInDocumentProperties

public abstract 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.getWorksheets().getBuiltInDocumentProperties().get("Author");
doc.setValue("John Smith");

getCustomDocumentProperties

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

Example:

excel.getWorksheets().getCustomDocumentProperties().add("Checked by", "Jane");

getOleSize/setOleSize

public abstract java.lang.Object getOleSize() / public abstract void setOleSize(java.lang.Object value)
Gets and Sets displayed size when Workbook file is used as an Ole object. Null means no ole size setting.

getExternalLinks

public abstract ExternalLinkCollection getExternalLinks()
Represents external links in a workbook.

getTableStyles

public abstract TableStyleCollection getTableStyles()
Gets TableStyles object.

getCount

→ inherited from CollectionBase
public int getCount()

get

public abstract Worksheet get(int index)
Gets the Worksheet element at the specified index.
Parameters:
index - The zero based index of the element.
Returns:
The element at the specified index.

get

public abstract Worksheet get(java.lang.String sheetName)
Gets the Worksheet element with the specified name.
Parameters:
sheetName - Worksheet name
Returns:
The element with the specified name.

Method Detail

createRange

public abstract Range createRange(java.lang.String address, int sheetIndex)
Creates a Range object from an address of the range.
Parameters:
address - The address of the range.
sheetIndex - The sheet index.
Returns:
A Range object

getSheetByCodeName

public abstract Worksheet getSheetByCodeName(java.lang.String codeName)
Gets the worksheet by the code name.
Parameters:
codeName - Worksheet code name.
Returns:
The element with the specified code name.

sortNames

public abstract void sortNames()
Sorts defined names. 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 saving

insert

public abstract Worksheet insert(int index, int sheetType)
Insert a worksheet.
Parameters:
index - The sheet index
sheetType - A SheetType value. The sheet type.
Returns:
Returns an inserted worksheet.

insert

public abstract Worksheet insert(int index, int sheetType, java.lang.String sheetName)
Insert a worksheet.
Parameters:
index - The sheet index
sheetType - A SheetType value. The sheet type.
sheetName - The sheet name.
Returns:
Returns an inserted worksheet.

add

public abstract int add(int type)
Adds a worksheet to the collection.
Parameters:
type - A SheetType value. Worksheet type.
Returns:
Worksheet object index.

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);

swapSheet

public abstract void swapSheet(int sheetIndex1, int sheetIndex2)
Swaps the two sheets.
Parameters:
sheetIndex1 - The first worksheet.
sheetIndex2 - The second worksheet.

add

public abstract int add()
Adds a worksheet to the collection.
Returns:
Worksheet object index.

add

public abstract Worksheet add(java.lang.String sheetName)
Adds a worksheet to the collection.
Parameters:
sheetName - Worksheet name
Returns:
Worksheet object.

removeAt

public abstract void removeAt(java.lang.String name)
Removes the element at a specified name.
Parameters:
name - The name of the element to remove.

removeAt

public abstract void removeAt(int index)
Removes the element at a specified index.
Parameters:
index - The index value of the element to remove.

clear

public abstract void clear()
Clear all worksheets. A workbook must contains a worksheet.

addCopy

public abstract int addCopy(java.lang.String sheetName)
                         throws java.lang.Exception
Adds a worksheet to the collection and copies data from an existed worksheet.
Parameters:
sheetName - Name of source worksheet.
Returns:
Worksheet object index.

addCopy

public abstract int addCopy(int sheetIndex)
                         throws java.lang.Exception
Adds a worksheet to the collection and copies data from an existed worksheet.
Parameters:
sheetIndex - Index of source worksheet.
Returns:
Worksheet object index.

getRangeByName

public abstract Range getRangeByName(java.lang.String rangeName)
Gets Range object by pre-defined name.
Parameters:
rangeName - Name of range.
Returns:
Range object.

Returns null if the named range does not exist.


getNamedRanges

public abstract Range[] getNamedRanges()
Gets all pre-defined named ranges in the spreadsheet.
Returns:
An array of Range objects.

Returns null if the named range does not exist.


getNamedRangesAndTables

public abstract Range[] getNamedRangesAndTables()
Gets all pre-defined named ranges in the spreadsheet.
Returns:
An array of Range objects.

Returns null if the named range does not exist.


setOleSize

public abstract void setOleSize(int startRow, int endRow, int startColumn, int endColumn)
Sets displayed size when Workbook file is used as an Ole object. This method is generally used to adjust display size in ppt file or doc file.
Parameters:
startRow - Start row index.
endRow - End row index.
startColumn - Start column index.
endColumn - End column index.

clearPivottables

public abstract void clearPivottables()
Clears pivot tables from the spreadsheet.

iterator

→ inherited from CollectionBase
public java.util.Iterator iterator()

get

→ inherited from CollectionBase
public java.lang.Object get(int index)
Reserved for internal use.

contains

→ inherited from CollectionBase
public boolean contains(java.lang.Object value)
Reserved for internal use.

add

→ inherited from CollectionBase
public int add(java.lang.Object value)
Reserved for internal use.

indexOf

→ inherited from CollectionBase
public int indexOf(java.lang.Object value)
Reserved for internal use.

See Also:
          Aspose.Cells Documentation - the home page for the Aspose.Cellss Product Documentation.
          Aspose.Cells Support Forum - our preferred method of support.