Home  Products  Purchase  Downloads  Demos  Forums  Blogs  Ticket  Wiki  API  Corporate

com.aspose.cells
Class Worksheets

java.lang.Object
  extended by com.aspose.cells.Worksheets

public class Worksheets
extends java.lang.Object

Encapsulates a collection of Worksheet objects.


Method Summary
 int addCopy(int sheetIndex)
          Adds a worksheet to the collection and copys data from an existed worksheet.
 int addCopy(java.lang.String sheetName)
          Adds a worksheet to the collection and copys data from an existed worksheet.
 Worksheet addSheet()
          Adds a new worksheet in this workbook.
 Worksheet addSheet(int type)
          Adds a new worksheet in this workbook.
 Worksheet addSheet(int type, java.lang.String sheetName)
          Adds a new worksheet in this workbook with the specified sheet name.
 Worksheet addSheet(java.lang.String sheetName)
          Adds a new worksheet in this workbook with the specified sheet name.
 Worksheet getActiveSheet()
          Gets the active sheet.
 int getActiveSheetIndex()
          Gets the active sheet index.
 BuiltInDocumentProperties getBuiltInDocumentProperties()
          Returns a DocumentProperties collection that represents all the built-in document properties of the spreadsheet.
 CustomDocumentProperties getCustomDocumentProperties()
          Returns a DocumentProperties collection that represents all the custom document properties of the spreadsheet.
 NamedRange[] getNamedRanges()
          Gets all pre-defined named ranges in the spreadsheet.
 int getNumberOfSheets()
          Deprecated. Replaced by size().
 NamedRange getRangeByName(java.lang.String rangeName)
          Gets NamedRange object by pre-defined name.
 Worksheet getSheet(int index)
          Returns the sheet at the specified index.
 Worksheet getSheet(java.lang.String name)
          Gets the sheet with the specified name.
 int getSheetIndex(java.lang.String name)
          Gets the sheet's index according to its name.
 java.lang.String getSheetName(int index)
          Returns the name of the sheet at the specified index.
 void moveSheet(int origin, int dest)
          Moves a worksheet.
 void removeSheet(int index)
          Removes the sheet at the specified index.
 boolean removeSheet(java.lang.String sheetName)
          Removes the specified sheet from the workbook.
 boolean removeSheet(Worksheet sheet)
          Removes the specified worksheet.
 int size()
          Gets the number of sheets in the workbook.
 void swapSheet(int idx1, int idx2)
          Swaps the positions of two sheets.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

addSheet

public Worksheet addSheet()
Adds a new worksheet in this workbook. The sheet name is assigned automatically.

Returns:
the added worksheet.

addSheet

public Worksheet addSheet(int type)
Adds a new worksheet in this workbook. The sheet name is assigned automatically.

Parameters:
type - Worksheet type.It could be one of the following values:
SheetType.WORKSHEET
SheetType.CHART
Returns:
the added worksheet.
Throws:
java.lang.IllegalArgumentException - if sheet type is not Worksheet or Chart.

addSheet

public Worksheet addSheet(java.lang.String sheetName)
Adds a new worksheet in this workbook with the specified sheet name.

Parameters:
sheetName - name of the worksheet.
Returns:
the added worksheet.

addSheet

public Worksheet addSheet(int type,
                          java.lang.String sheetName)
Adds a new worksheet in this workbook with the specified sheet name.

Parameters:
sheetName - name of the worksheet.
type - Worksheet type.
Returns:
the added worksheet.
Throws:
java.lang.IllegalArgumentException - if sheet type is not Worksheet or Chart.
See Also:
addSheet(int)

getNumberOfSheets

@Deprecated
public int getNumberOfSheets()
Deprecated. Replaced by size().

Gets the number of sheets in the workbook.

Returns:
number of sheets.

size

public int size()
Gets the number of sheets in the workbook.

Returns:
number of sheets.

getSheet

public Worksheet getSheet(int index)
Returns the sheet at the specified index.

Parameters:
index - index of the sheet.
Returns:
the sheet at the specified index.
Throws:
java.lang.IllegalArgumentException - if the index is out of range.

getSheet

public Worksheet getSheet(java.lang.String name)
Gets the sheet with the specified name.

Parameters:
name - name of the sheet.
Returns:
the sheet that has the specified name. Returns null if the sheet name is invalid.

getSheetName

public java.lang.String getSheetName(int index)
Returns the name of the sheet at the specified index.

Parameters:
index - index of the sheet.
Returns:
sheet name.
Throws:
java.lang.IllegalArgumentException - if the index is out of range.

swapSheet

public void swapSheet(int idx1,
                      int idx2)
Swaps the positions of two sheets.

Parameters:
idx1 - index of the first sheet
idx2 - index of the second sheet
Throws:
java.lang.IllegalArgumentException - if any of the positions is out of range.

moveSheet

public void moveSheet(int origin,
                      int dest)
Moves a worksheet.

Parameters:
origin - the original index of the sheet.
dest - the new index of the sheet.
Throws:
java.lang.IllegalArgumentException - if any of the indexes is out of range.

removeSheet

public void removeSheet(int index)
Removes the sheet at the specified index. Once a sheet is removed, operations on it may cause an CellsException.

Parameters:
index - index of the sheet.
Throws:
java.lang.IllegalArgumentException - if index is out of range.

removeSheet

public boolean removeSheet(Worksheet sheet)
Removes the specified worksheet. Once a sheet is removed, operations on it may cause an CellsException.

Parameters:
sheet - the sheet to remove.
Returns:
true if the sheet exists and is removed successfully.

removeSheet

public boolean removeSheet(java.lang.String sheetName)
Removes the specified sheet from the workbook. Once a sheet is removed, operations on it may cause an CellsException.

Parameters:
sheetName - name of the sheet to remove
Returns:
true if the sheet exists and is removed successfully.

getActiveSheetIndex

public int getActiveSheetIndex()
Gets the active sheet index.

Returns:
the active sheet index.

getActiveSheet

public Worksheet getActiveSheet()
Gets the active sheet.

Returns:
the active sheet.

getSheetIndex

public int getSheetIndex(java.lang.String name)
Gets the sheet's index according to its name.

Parameters:
name - name of the sheet.
Returns:
index of the sheet. Returns -1 if the sheet name is invalid.

addCopy

public int addCopy(int sheetIndex)
Adds a worksheet to the collection and copys data from an existed worksheet.

Parameters:
sheetIndex - Index of source worksheet.
Returns:
Worksheet object index.

addCopy

public int addCopy(java.lang.String sheetName)
Adds a worksheet to the collection and copys data from an existed worksheet.

Parameters:
sheetName - name of source worksheet.
Returns:
Worksheet object index.

getRangeByName

public NamedRange getRangeByName(java.lang.String rangeName)
Gets NamedRange object by pre-defined name.

Parameters:
rangeName - range name
Returns:
NamedRange object.Returns null if the named range does not exist.

getNamedRanges

public NamedRange[] getNamedRanges()
Gets all pre-defined named ranges in the spreadsheet.

Returns:
An array of NamedRange objects. Returns null if the named range does not exist.

getBuiltInDocumentProperties

public BuiltInDocumentProperties getBuiltInDocumentProperties()
Returns a DocumentProperties collection that represents all the built-in document properties of the spreadsheet.

Returns:
a DocumentProperties collection.

getCustomDocumentProperties

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

Returns:
a DocumentProperties collection.