com.aspose.cells
Class WorksheetCollection

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

public 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
intgetActiveSheetIndex()
voidsetActiveSheetIndex(int value)
           Represents the index of active worksheet when the spreadsheet is opened.
BuiltInDocumentPropertyCollectiongetBuiltInDocumentProperties()
           Returns a DocumentProperties collection that represents all the built-in document properties of the spreadsheet.
intgetCount()→ inherited from com.aspose.cells.CollectionBase
          
CustomDocumentPropertyCollectiongetCustomDocumentProperties()
           Returns a DocumentProperties collection that represents all the custom document properties of the spreadsheet.
booleangetEnableHTTPCompression()
voidsetEnableHTTPCompression(boolean value)
           Indicates if http compression is to be used in user's IIS.
ExternalLinkCollectiongetExternalLinks()
           Represents external links in a workbook.
booleangetHidePivotFieldList()
voidsetHidePivotFieldList(boolean value)
           Gets whether hide the field list for the PivotTable.
booleanisHidden()
voidsetHidden(boolean value)
           Indicates whether this workbook is hidden.
booleanisMinimized()
voidsetMinimized(boolean value)
           Represents whether the generated spreadsheet will be opened Minimized.
booleanisRefreshAllConnections()
voidsetRefreshAllConnections(boolean value)
           Indicates whether refresh all connections on opening file in MS Excel.
NameCollectiongetNames()
           Gets the collection of all the Name objects in the spreadsheet.
java.lang.ObjectgetOleSize()
voidsetOleSize(java.lang.Object value)
           Gets and Sets displayed size when Workbook file is used as an Ole object.
intgetSheetTabBarWidth()
voidsetSheetTabBarWidth(int value)
           Width of worksheet tab bar (in 1/1000 of window width).
TableStyleCollectiongetTableStyles()
           Gets TableStyles object.
doublegetWindowHeight()
voidsetWindowHeight(double value)
           The height of the window, in unit of point.
doublegetWindowHeightCM()
voidsetWindowHeightCM(double value)
           The height of the window,in unit of centimeter.
doublegetWindowHeightInch()
voidsetWindowHeightInch(double value)
           The height of the window,in unit of inch.
doublegetWindowLeft()
voidsetWindowLeft(double value)
           The distance from the left edge of the client area to the left edge of the window, in unit of point.
doublegetWindowLeftCM()
voidsetWindowLeftCM(double value)
           The distance from the left edge of the client area to the left edge of the window. In unit of centimeter.
doublegetWindowLeftInch()
voidsetWindowLeftInch(double value)
           The distance from the left edge of the client area to the left edge of the window. In unit of inch.
doublegetWindowTop()
voidsetWindowTop(double value)
           The distance from the top edge of the client area to the top edge of the window, in unit of point.
doublegetWindowTopCM()
voidsetWindowTopCM(double value)
           The distance from the top edge of the client area to the top edge of the window,in unit of centimeter.
doublegetWindowTopInch()
voidsetWindowTopInch(double value)
           The distance from the top edge of the client area to the top edge of the window,in unit of inch.
doublegetWindowWidth()
voidsetWindowWidth(double value)
           The width of the window, in unit of point.
doublegetWindowWidthCM()
voidsetWindowWidthCM(double value)
           The width of the window,in unit of centimeter.
doublegetWindowWidthInch()
voidsetWindowWidthInch(double value)
           The width of the window,in unit of inch.
XmlMapCollectiongetXmlMaps()
voidsetXmlMaps(XmlMapCollection value)
           gets and sets the xml maps in the workbook.
Worksheetget(int index)
           Gets the Worksheet element at the specified index.
Worksheetget(java.lang.String sheetName)
           Gets the Worksheet element with the specified name.
 
Method Summary
intadd()
           Adds a worksheet to the collection.
intadd(int type)
           Adds a worksheet to the collection.
intadd(java.lang.Object value)→ inherited from com.aspose.cells.CollectionBase
          Reserved for internal use.
Worksheetadd(java.lang.String sheetName)
           Adds a worksheet to the collection.
intaddCopy(int sheetIndex)
           Adds a worksheet to the collection and copies data from an existed worksheet.
intaddCopy(java.lang.String sheetName)
           Adds a worksheet to the collection and copies data from an existed worksheet.
voidclear()
           Clear all worksheets.
booleancontains(java.lang.Object value)→ inherited from com.aspose.cells.CollectionBase
          Reserved for internal use.
voiddeleteName(java.lang.String definedName)
           Deletes a defined name in the workbook.
java.lang.Objectget(int index)→ inherited from com.aspose.cells.CollectionBase
          Reserved for internal use.
com.aspose.cells.Range[]getNamedRanges()
           Gets all pre-defined named ranges in the spreadsheet.
com.aspose.cells.Range[]getNamedRangesAndTables()
           Gets all pre-defined named ranges in the spreadsheet.
RangegetRangeByName(java.lang.String rangeName)
           Gets Range object by pre-defined name.
WorksheetgetSheetByCodeName(java.lang.String codeName)
           Gets the worksheet by the code name.
intindexOf(java.lang.Object value)→ inherited from com.aspose.cells.CollectionBase
          Reserved for internal use.
Worksheetinsert(int index, int sheetType)
           Insert a worksheet.
Worksheetinsert(int index, int sheetType, java.lang.String sheetName)
           Insert a worksheet.
java.util.Iteratoriterator()→ inherited from com.aspose.cells.CollectionBase
          
voidremoveAt(int index)
           Removes the element at a specified index.
voidremoveAt(java.lang.String name)
           Removes the element at a specified name.
voidsetOleSize(int startRow, int endRow, int startColumn, int endColumn)
           Sets displayed size when Workbook file is used as an Ole object.
voidsortNames()
           Sorts defined names.
voidswapSheet(int sheetIndex1, int sheetIndex2)
           Swaps the two sheets.
 

Property Getters/Setters Detail

getHidePivotFieldList/setHidePivotFieldList

public boolean getHidePivotFieldList() / public void setHidePivotFieldList(boolean value)
Gets whether hide the field list for the PivotTable.

isRefreshAllConnections/setRefreshAllConnections

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

getNames

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

getEnableHTTPCompression/setEnableHTTPCompression

public boolean getEnableHTTPCompression() / public void setEnableHTTPCompression(boolean value)
Indicates if http compression is to be used in user's IIS. Please specify this property to true if http compression is used. NOTE: This property is now obsolete. Instead, please use SaveOptions.EnableHTTPCompression property. This property will be removed 12 months later since February 2012. Aspose apologizes for any inconvenience you may have experienced.

getActiveSheetIndex/setActiveSheetIndex

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

isMinimized/setMinimized

public boolean isMinimized() / public void setMinimized(boolean value)
Represents whether the generated spreadsheet will be opened Minimized. NOTE: This member is now obsolete. Instead, please use Workbook.Settings.IsMinimized property. This property will be removed 12 months later since APRIL 2012. Aspose apologizes for any inconvenience you may have experienced.

isHidden/setHidden

public boolean isHidden() / public void setHidden(boolean value)
Indicates whether this workbook is hidden. NOTE: This member is now obsolete. Instead, please use Workbook.Settings.IsHidden property. This property will be removed 12 months later since APRIL 2012. Aspose apologizes for any inconvenience you may have experienced.

getWindowLeft/setWindowLeft

public double getWindowLeft() / public void setWindowLeft(double value)
The distance from the left edge of the client area to the left edge of the window, in unit of point. NOTE: This member is now obsolete. Instead, please use Workbook.Settings.WindowLeft property. This property will be removed 12 months later since APRIL 2012. Aspose apologizes for any inconvenience you may have experienced.

getWindowLeftInch/setWindowLeftInch

public double getWindowLeftInch() / public void setWindowLeftInch(double value)
The distance from the left edge of the client area to the left edge of the window. In unit of inch. NOTE: This member is now obsolete. Instead, please use Workbook.Settings.WindowLeftInch property. This property will be removed 12 months later since APRIL 2012. Aspose apologizes for any inconvenience you may have experienced.

getWindowLeftCM/setWindowLeftCM

public double getWindowLeftCM() / public void setWindowLeftCM(double value)
The distance from the left edge of the client area to the left edge of the window. In unit of centimeter. NOTE: This member is now obsolete. Instead, please use Workbook.Settings.WindowLeftCM property. This property will be removed 12 months later since APRIL 2012. Aspose apologizes for any inconvenience you may have experienced.

getWindowTop/setWindowTop

public double getWindowTop() / public void setWindowTop(double value)
The distance from the top edge of the client area to the top edge of the window, in unit of point. NOTE: This member is now obsolete. Instead, please use Workbook.Settings.WindowTop property. This property will be removed 12 months later since APRIL 2012. Aspose apologizes for any inconvenience you may have experienced.

getWindowTopInch/setWindowTopInch

public double getWindowTopInch() / public void setWindowTopInch(double value)
The distance from the top edge of the client area to the top edge of the window,in unit of inch. NOTE: This member is now obsolete. Instead, please use Workbook.Settings.WindowTopInch property. This property will be removed 12 months later since APRIL 2012. Aspose apologizes for any inconvenience you may have experienced.

getWindowTopCM/setWindowTopCM

public double getWindowTopCM() / public void setWindowTopCM(double value)
The distance from the top edge of the client area to the top edge of the window,in unit of centimeter. NOTE: This member is now obsolete. Instead, please use Workbook.Settings.WindowTopCM property. This property will be removed 12 months later since APRIL 2012. Aspose apologizes for any inconvenience you may have experienced.

getWindowWidth/setWindowWidth

public double getWindowWidth() / public void setWindowWidth(double value)
The width of the window, in unit of point. NOTE: This member is now obsolete. Instead, please use Workbook.Settings.WindowWidth property. This property will be removed 12 months later since APRIL 2012. Aspose apologizes for any inconvenience you may have experienced.

getWindowWidthInch/setWindowWidthInch

public double getWindowWidthInch() / public void setWindowWidthInch(double value)
The width of the window,in unit of inch. NOTE: This member is now obsolete. Instead, please use Workbook.Settings.WindowWidthInch property. This property will be removed 12 months later since APRIL 2012. Aspose apologizes for any inconvenience you may have experienced.

getWindowWidthCM/setWindowWidthCM

public double getWindowWidthCM() / public void setWindowWidthCM(double value)
The width of the window,in unit of centimeter. NOTE: This member is now obsolete. Instead, please use Workbook.Settings.WindowWidthCM property. This property will be removed 12 months later since APRIL 2012. Aspose apologizes for any inconvenience you may have experienced.

getWindowHeight/setWindowHeight

public double getWindowHeight() / public void setWindowHeight(double value)
The height of the window, in unit of point. NOTE: This member is now obsolete. Instead, please use Workbook.Settings.WindowHeight property. This property will be removed 12 months later since APRIL 2012. Aspose apologizes for any inconvenience you may have experienced.

getWindowHeightInch/setWindowHeightInch

public double getWindowHeightInch() / public void setWindowHeightInch(double value)
The height of the window,in unit of inch. NOTE: This member is now obsolete. Instead, please use Workbook.Settings.WindowHeightInch property. This property will be removed 12 months later since APRIL 2012. Aspose apologizes for any inconvenience you may have experienced.

getWindowHeightCM/setWindowHeightCM

public double getWindowHeightCM() / public void setWindowHeightCM(double value)
The height of the window,in unit of centimeter. NOTE: This member is now obsolete. Instead, please use Workbook.Settings.WindowHeightCM property. This property will be removed 12 months later since APRIL 2012. Aspose apologizes for any inconvenience you may have experienced.

getSheetTabBarWidth/setSheetTabBarWidth

public int getSheetTabBarWidth() / public void setSheetTabBarWidth(int value)
Width of worksheet tab bar (in 1/1000 of window width). NOTE: This member is now obsolete. Instead, please use Workbook.Settings.SheetTabBarWidth property. This property will be removed 12 months later since APRIL 2012. Aspose apologizes for any inconvenience you may have experienced.

getXmlMaps/setXmlMaps

public XmlMapCollection getXmlMaps() / public void setXmlMaps(XmlMapCollection value)
gets and sets the xml maps in the workbook.

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.getWorksheets().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.getWorksheets().getCustomDocumentProperties().add("Checked by", "Jane");

getOleSize/setOleSize

public java.lang.Object getOleSize() / public 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 ExternalLinkCollection getExternalLinks()
Represents external links in a workbook.

getTableStyles

public TableStyleCollection getTableStyles()
Gets TableStyles object.

getCount

→ inherited from com.aspose.cells.CollectionBase
public int getCount()

get

public 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 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

getRangeByName

public 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 com.aspose.cells.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 com.aspose.cells.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 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.

deleteName

public void deleteName(java.lang.String definedName)
Deletes a defined name in the workbook. NOTE: This member is now obsolete. Instead, please use Names.Remove() method. This property will be removed 12 months later since June 2010. Aspose apologizes for any inconvenience you may have experienced.
Parameters:
definedName - Defined name.

getSheetByCodeName

public 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 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 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 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 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 void swapSheet(int sheetIndex1, int sheetIndex2)
Swaps the two sheets.
Parameters:
sheetIndex1 - The first worksheet.
sheetIndex2 - The second worksheet.

add

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

add

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

removeAt

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

removeAt

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

clear

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

addCopy

public 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 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.

iterator

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

get

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

contains

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

add

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

indexOf

→ inherited from com.aspose.cells.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.