java.lang.Object
com.aspose.cells.Worksheet
public abstract class Worksheet
- extends java.lang.Object
Encapsulates the object that represents a single worksheet.
Example:
Workbook workbook = new Workbook();
Worksheet sheet = workbook.getWorksheets().get(0);
//Freeze panes at "AS40" with 10 rows and 10 columns
sheet.freezePanes("AS40", 10, 10);
//Add a hyperlink in Cell A1
sheet.getHyperlinks().add("A1", 1, 1, "http://www.aspose.com");
|
Method Summary |
abstract void | addPageBreaks(java.lang.String cellName) | |
|
Adds page break.
|
abstract void | autoFitColumn(int columnIndex) | |
|
Autofits the column width.
|
abstract void | autoFitColumn(int columnIndex, int firstRow, int lastRow) | |
|
Autofits the column width.
|
abstract void | autoFitColumns() | |
|
Autofits all columns in this worksheet.
|
abstract void | autoFitColumns(AutoFitterOptions options) | |
|
Autofits all columns in this worksheet.
|
abstract void | autoFitColumns(int firstColumn, int lastColumn) | |
|
Autofits the columns width.
|
abstract void | autoFitColumns(int firstColumn, int lastColumn, AutoFitterOptions options) | |
|
Autofits the columns width.
|
abstract void | autoFitColumns(int firstRow, int firstColumn, int lastRow, int lastColumn) | |
|
Autofits the columns width.
|
abstract void | autoFitColumns(int firstRow, int firstColumn, int lastRow, int lastColumn, AutoFitterOptions options) | |
|
Autofits the columns width.
|
abstract void | autoFitRow(int rowIndex) | |
|
Autofits the row height.
|
abstract void | autoFitRow(int rowIndex, int firstColumn, int lastColumn) | |
|
Autofits the row height.
|
abstract void | autoFitRow(int rowIndex, int firstColumn, int lastColumn, AutoFitterOptions options) | |
|
Autofits the row height.
|
abstract void | autoFitRow(int startRow, int endRow, int startColumn, int endColumn) | |
|
Autofits row height in a rectangle range.
|
abstract void | autoFitRows() | |
|
Autofits all rows in this worksheet.
|
abstract void | autoFitRows(boolean onlyAuto) | |
|
Autofits all rows in this worksheet.
|
abstract void | autoFitRows(AutoFitterOptions options) | |
|
Autofits all rows in this worksheet.
|
abstract void | autoFitRows(int startRow, int endRow) | |
|
Autofits row height in a range.
|
abstract void | autoFitRows(int startRow, int endRow, AutoFitterOptions options) | |
|
Autofits row height in a range.
|
abstract void | calculateFormula(boolean recursive, boolean ignoreError, ICustomFunction customFunction) | |
|
Calculates all formulas in this worksheet.
|
abstract void | calculateFormula(CalculationOptions options, boolean recursive) | |
|
Calculates all formulas in this worksheet.
|
abstract java.lang.Object | calculateFormula(java.lang.String formula) | |
|
Calculates a formula.
|
abstract java.lang.Object | calculateFormula(java.lang.String formula, CalculationOptions opts) | |
|
Calculates a formula.
|
abstract void | clearComments() | |
|
Clears all comments in designer spreadsheet.
|
abstract void | copy(Worksheet sourceSheet) | |
|
Copies contents and formats from another worksheet.
|
abstract void | copy(Worksheet sourceSheet, CopyOptions copyOptions) | |
|
Copies contents and formats from another worksheet.
|
abstract void | dispose() | |
| |
abstract void | freezePanes(int row, int column, int freezedRows, int freezedColumns) | |
|
Freezes panes at the specified cell in the worksheet.
|
abstract void | freezePanes(java.lang.String cellName, int freezedRows, int freezedColumns) | |
|
Freezes panes at the specified cell in the worksheet.
|
abstract int[] | getFreezedPanes() | |
|
Gets the freeze panes.
|
abstract PaneCollection | getPanes() | |
|
Gets the window panes.
|
abstract CellArea[] | getPrintingPageBreaks(ImageOrPrintOptions options) | |
|
Gets automatic page breaks.
|
abstract java.util.ArrayList | getSelectedRanges() | |
|
Gets selected ranges of cells in the designer spreadsheet.
|
abstract void | moveTo(int index) | |
|
Moves the sheet to another location in the spreadsheet.
|
abstract void | protect(int type) | |
|
Protects worksheet.
|
abstract void | protect(int type, java.lang.String password, java.lang.String oldPassword) | |
|
Protects worksheet.
|
abstract void | refreshPivotTables() | |
|
Refreshes all PivotTables in this Worksheet.
|
abstract void | removeAllDrawingObjects() | |
|
Removes all drawing objects in this worksheet.
|
abstract void | removeAutoFilter() | |
|
Removes the auto filter of the worksheet.
|
abstract void | removeSplit() | |
|
Removes splitted window.
|
abstract int | replace(java.lang.String oldString, java.lang.String newString) | |
|
Replaces all cells' text with a new string.
|
abstract void | selectRange(int startRow, int startColumn, int totalRows, int totalColumns, boolean removeOthers) | |
|
Selects a range.
|
abstract void | setBackground(byte[] pictureData) | |
|
Sets worksheet background image.
|
abstract void | setVisible(boolean isVisible, boolean ignoreError) | |
|
Sets the visible options.
|
abstract void | split() | |
|
Splits window.
|
abstract void | unFreezePanes() | |
|
Unfreezes panes in the worksheet.
|
abstract void | unprotect() | |
|
Unprotects worksheet.
|
abstract void | unprotect(java.lang.String password) | |
|
Unprotects worksheet.
|
|
Property Getters/Setters Detail |
getProtection | |
public abstract Protection getProtection()
|
-
Represents the various types of protection options available for a worksheet. Supports advanced protection options in ExcelXP and above version.
This property can protect worksheet in all versions of Excel file and support advanced protection options in ExcelXP and above version.
getWorkbook | |
public abstract Workbook getWorkbook()
|
-
Gets the workbook object which contains this sheet.
getCells | |
public abstract Cells getCells()
|
-
Gets the Cells collection.
-
Gets the queryTables in the worksheet.
-
Gets all pivot tables in this worksheet.
getType/setType | |
public abstract int getType() / public abstract void setType(int value)
|
-
Represents worksheet type.
The value of the property is SheetType integer constant.
getName/setName | |
public abstract java.lang.String getName() / public abstract void setName(java.lang.String value)
|
-
Gets or sets the name of the worksheet.
The max length of sheet name is 31. And you cannot assign same name(case insensitive) to two worksheets.
For example, you cannot set "SheetName1" to the first worksheet and set "SHEETNAME1" to the second worksheet.
getShowFormulas/setShowFormulas | |
public abstract boolean getShowFormulas() / public abstract void setShowFormulas(boolean value)
|
-
Indicates whether to show formulas or their results.
isGridlinesVisible/setGridlinesVisible | |
public abstract boolean isGridlinesVisible() / public abstract void setGridlinesVisible(boolean value)
|
-
Gets or sets a value indicating whether the gridelines are visible.Default is true.
isRowColumnHeadersVisible/setRowColumnHeadersVisible | |
public abstract boolean isRowColumnHeadersVisible() / public abstract void setRowColumnHeadersVisible(boolean value)
|
-
Gets or sets a value indicating whether the worksheet will display row and column headers.
Default is true.
getDisplayZeros/setDisplayZeros | |
public abstract boolean getDisplayZeros() / public abstract void setDisplayZeros(boolean value)
|
-
True if zero values are displayed.
getDisplayRightToLeft/setDisplayRightToLeft | |
public abstract boolean getDisplayRightToLeft() / public abstract void setDisplayRightToLeft(boolean value)
|
-
Indicates if the specified worksheet is displayed from right to left instead of from left to right.
Default is false.
isOutlineShown/setOutlineShown | |
public abstract boolean isOutlineShown() / public abstract void setOutlineShown(boolean value)
|
-
Indicates whether to show outline.
isSelected/setSelected | |
public abstract boolean isSelected() / public abstract void setSelected(boolean value)
|
-
Indicates whether this worksheet is selected when the workbook is opened.
-
Gets all ListObjects in this worksheet.
-
Gets the HorizontalPageBreakCollection collection.
-
Gets the VerticalPageBreakCollection collection.
-
Gets the HyperlinkCollection collection.
getPageSetup | |
public abstract PageSetup getPageSetup()
|
-
Represents the page setup description in this sheet.
getAutoFilter | |
public abstract AutoFilter getAutoFilter()
|
-
Represents auto filter for the specified worksheet.
hasAutofilter | |
public abstract boolean hasAutofilter()
|
-
Indicates whether this worksheet has auto filter.
getTransitionEvaluation/setTransitionEvaluation | |
public abstract boolean getTransitionEvaluation() / public abstract void setTransitionEvaluation(boolean value)
|
-
Indicates whether the Transition Formula Evaluation (Lotus compatibility) option is enabled.
getTransitionEntry/setTransitionEntry | |
public abstract boolean getTransitionEntry() / public abstract void setTransitionEntry(boolean value)
|
-
Indicates whether the Transition Formula Entry (Lotus compatibility) option is enabled.
getVisibilityType/setVisibilityType | |
public abstract int getVisibilityType() / public abstract void setVisibilityType(int value)
|
-
Indicates the visible state for this sheet.
The value of the property is VisibilityType integer constant.
isVisible/setVisible | |
public abstract boolean isVisible() / public abstract void setVisible(boolean value)
|
-
Represents if the worksheet is visible.
-
Gets the sparkline group collection in the worksheet.
-
Gets a Chart collection
-
Gets the Comment collection.
-
Gets a Picture collection.
-
Gets a #Error Cref: !:TextBoxe collection.
-
Gets a CheckBox collection.
-
Represents a collection of OleObject in a worksheet.
-
Returns all drawing shapes in this worksheet.
getIndex | |
public abstract int getIndex()
|
-
Gets the index of sheet in the worksheet collection.
isProtected | |
public abstract boolean isProtected()
|
-
Indicates if the worksheet is protected.
-
Gets the data validation setting collection in the worksheet.
-
Gets the allow edit range collection in the worksheet.
-
Gets error check setting applied on certain ranges.
getOutline | |
public abstract Outline getOutline()
|
-
Gets the outline on this worksheet.
getFirstVisibleRow/setFirstVisibleRow | |
public abstract int getFirstVisibleRow() / public abstract void setFirstVisibleRow(int value)
|
-
Represents first visible row index.
getFirstVisibleColumn/setFirstVisibleColumn | |
public abstract int getFirstVisibleColumn() / public abstract void setFirstVisibleColumn(int value)
|
-
Represents first visible column index.
getZoom/setZoom | |
public abstract int getZoom() / public abstract void setZoom(int value)
|
-
Represents the scaling factor in percentage. It should be between 10 and 400.
Please set the view type first.
getViewType/setViewType | |
public abstract int getViewType() / public abstract void setViewType(int value)
|
-
Gets and sets the view type.
The value of the property is ViewType integer constant.
isPageBreakPreview/setPageBreakPreview | |
public abstract boolean isPageBreakPreview() / public abstract void setPageBreakPreview(boolean value)
|
-
Indicates whether the specified worksheet is shown in normal view or page break preview.
isRulerVisible/setRulerVisible | |
public abstract boolean isRulerVisible() / public abstract void setRulerVisible(boolean value)
|
-
Indicates whether the ruler is visible. This property is only applied for page break preview.
getTabColor/setTabColor | |
public abstract Color getTabColor() / public abstract void setTabColor(Color value)
|
-
Represents worksheet tab color.
This feature is only supported in ExcelXP(Excel2002) and later versions.
If you save file as Excel97 or Excel2000 format, it will be omitted.
getCodeName | |
public abstract java.lang.String getCodeName()
|
-
Gets worksheet code name.
getBackgroundImage/setBackgroundImage | |
public abstract byte[] getBackgroundImage() / public abstract void setBackgroundImage(byte[] value)
|
-
Gets and sets worksheet background image.
-
Gets the ConditionalFormattings in the worksheet.
getActiveCell/setActiveCell | |
public abstract java.lang.String getActiveCell() / public abstract void setActiveCell(java.lang.String value)
|
-
Gets or sets the active cell in the worksheet.
-
Gets an object representing
the identifier information associated with a worksheet.
Worksheet.CustomProperties provide a preferred mechanism for storing arbitrary data.
It supports legacy third-party document components, as well as those situations that have a stringent need for binary parts.
-
Gets all SmartTagCollection objects of the worksheet.
-
Gets the collection of Scenario.
-
Gets the window panes.
If the window is not splitted or frozen.
freezePanes | |
public abstract void freezePanes(int row, int column, int freezedRows, int freezedColumns) |
-
Freezes panes at the specified cell in the worksheet.
Row index and column index cannot all be zero. Number of rows and number of columns
also cannot all be zero.
The first two parameters specify the freezed position and the last two parameters specify the area freezed on the left top pane.
- Parameters:
row - Row index.column - Column index.freezedRows - Number of visible rows in top pane, no more than row index.freezedColumns - Number of visible columns in left pane, no more than column index.
getFreezedPanes | |
public abstract int[] getFreezedPanes() |
-
Gets the freeze panes.
- Returns:
- Return null means the worksheet is not frozen
0:Row index;1:column;2:freezedRows;3:freezedRows
split | |
public abstract void split() |
-
Splits window.
freezePanes | |
public abstract void freezePanes(java.lang.String cellName, int freezedRows, int freezedColumns) |
-
Freezes panes at the specified cell in the worksheet.
Row index and column index cannot all be zero. Number of rows and number of columns
also cannot all be zero.
- Parameters:
cellName - Cell name.freezedRows - Number of visible rows in top pane, no more than row index.freezedColumns - Number of visible columns in left pane, no more than column index.
unFreezePanes | |
public abstract void unFreezePanes() |
-
Unfreezes panes in the worksheet.
removeSplit | |
public abstract void removeSplit() |
-
Removes splitted window.
addPageBreaks | |
public abstract void addPageBreaks(java.lang.String cellName) |
-
Adds page break.
- Parameters:
cellName -
copy | |
public abstract void copy(Worksheet sourceSheet)
throws java.lang.Exception |
-
Copies contents and formats from another worksheet.
- Parameters:
sourceSheet - Source worksheet.
copy | |
public abstract void copy(Worksheet sourceSheet, CopyOptions copyOptions)
throws java.lang.Exception |
-
Copies contents and formats from another worksheet.
You can copy data from another worksheet in the same file or another file. However, this method does not support to copy drawing objects, such as comments, images and charts.
- Parameters:
sourceSheet - Source worksheet.copyOptions -
autoFitColumn | |
public abstract void autoFitColumn(int columnIndex, int firstRow, int lastRow)
throws java.lang.Exception |
-
Autofits the column width.
This method autofits a row based on content in a range of cells within the row.
- Parameters:
columnIndex - Column index.firstRow - First row index.lastRow - Last row index.
autoFitColumns | |
public abstract void autoFitColumns()
throws java.lang.Exception |
-
Autofits all columns in this worksheet.
autoFitColumns | |
public abstract void autoFitColumns(AutoFitterOptions options)
throws java.lang.Exception |
-
Autofits all columns in this worksheet.
- Parameters:
options - The auto fitting options
autoFitColumn | |
public abstract void autoFitColumn(int columnIndex)
throws java.lang.Exception |
-
Autofits the column width.
AutoFitColumn is an imprecise function.
- Parameters:
columnIndex - Column index.
autoFitColumns | |
public abstract void autoFitColumns(int firstColumn, int lastColumn)
throws java.lang.Exception |
-
Autofits the columns width.
AutoFitColumn is an imprecise function.
- Parameters:
firstColumn - First column index.lastColumn - Last column index.
autoFitColumns | |
public abstract void autoFitColumns(int firstColumn, int lastColumn, AutoFitterOptions options)
throws java.lang.Exception |
-
Autofits the columns width.
AutoFitColumn is an imprecise function.
- Parameters:
firstColumn - First column index.lastColumn - Last column index.options - The auto fitting options
autoFitColumns | |
public abstract void autoFitColumns(int firstRow, int firstColumn, int lastRow, int lastColumn)
throws java.lang.Exception |
-
Autofits the columns width.
AutoFitColumn is an imprecise function.
- Parameters:
firstRow - First row index.firstColumn - First column index.lastRow - Last row index.lastColumn - Last column index.
autoFitColumns | |
public abstract void autoFitColumns(int firstRow, int firstColumn, int lastRow, int lastColumn, AutoFitterOptions options)
throws java.lang.Exception |
-
Autofits the columns width.
AutoFitColumn is an imprecise function.
- Parameters:
firstRow - First row index.firstColumn - First column index.lastRow - Last row index.lastColumn - Last column index.options - The auto fitting options
autoFitRow | |
public abstract void autoFitRow(int rowIndex, int firstColumn, int lastColumn)
throws java.lang.Exception |
-
Autofits the row height.
This method autofits a row based on content in a range of cells within the row.
- Parameters:
rowIndex - Row index.firstColumn - First column index.lastColumn - Last column index.
autoFitRow | |
public abstract void autoFitRow(int rowIndex, int firstColumn, int lastColumn, AutoFitterOptions options)
throws java.lang.Exception |
-
Autofits the row height.
This method autofits a row based on content in a range of cells within the row.
- Parameters:
rowIndex - Row index.firstColumn - First column index.lastColumn - Last column index.options - The auto fitter options
autoFitRows | |
public abstract void autoFitRows()
throws java.lang.Exception |
-
Autofits all rows in this worksheet.
autoFitRows | |
public abstract void autoFitRows(boolean onlyAuto)
throws java.lang.Exception |
-
Autofits all rows in this worksheet.
- Parameters:
onlyAuto -
True,only autofits the row height when row height is not customed.
autoFitRows | |
public abstract void autoFitRows(AutoFitterOptions options)
throws java.lang.Exception |
-
Autofits all rows in this worksheet.
- Parameters:
options - The auto fitter options
autoFitRows | |
public abstract void autoFitRows(int startRow, int endRow)
throws java.lang.Exception |
-
Autofits row height in a range.
- Parameters:
startRow - Start row index.endRow - End row index.
autoFitRows | |
public abstract void autoFitRows(int startRow, int endRow, AutoFitterOptions options)
throws java.lang.Exception |
-
Autofits row height in a range.
- Parameters:
startRow - Start row index.endRow - End row index.options - The options of auto fitter.
autoFitRow | |
public abstract void autoFitRow(int startRow, int endRow, int startColumn, int endColumn)
throws java.lang.Exception |
-
Autofits row height in a rectangle range.
- Parameters:
startRow - Start row index.endRow - End row index.startColumn - Start column index.endColumn - End column index.
autoFitRow | |
public abstract void autoFitRow(int rowIndex)
throws java.lang.Exception |
-
Autofits the row height.
AutoFitRow is an imprecise function.
- Parameters:
rowIndex - Row index.
removeAutoFilter | |
public abstract void removeAutoFilter() |
-
Removes the auto filter of the worksheet.
setVisible | |
public abstract void setVisible(boolean isVisible, boolean ignoreError) |
-
Sets the visible options.
- Parameters:
isVisible - Whether the worksheet is visibleignoreError - Whether to ignore error if this option is not valid.
selectRange | |
public abstract void selectRange(int startRow, int startColumn, int totalRows, int totalColumns, boolean removeOthers) |
-
Selects a range.
- Parameters:
startRow - The start row.
startColumn - The start columntotalRows - The number of rows.totalColumns - The number of columnsremoveOthers - True means removing other selected range and only select this range.
removeAllDrawingObjects | |
public abstract void removeAllDrawingObjects() |
-
Removes all drawing objects in this worksheet.
clearComments | |
public abstract void clearComments() |
-
Clears all comments in designer spreadsheet.
protect | |
public abstract void protect(int type) |
-
Protects worksheet.
This method protects worksheet without password. It can protect worksheet in all versions of Excel file.
- Parameters:
type - A ProtectionType value. Protection type.
protect | |
public abstract void protect(int type, java.lang.String password, java.lang.String oldPassword) |
-
Protects worksheet.
This method can protect worksheet in all versions of Excel file.
- Parameters:
type - A ProtectionType value. Protection type.password - Password.oldPassword - If the worksheet is already protected by a password, please supply the old password.
Otherwise, you can set a null value or blank string to this parameter.
Example:
//Instantiating a Workbook object
Workbook excel = new Workbook("C:\\book1.xls");
//Accessing the first worksheet in the Excel file
Worksheet worksheet = excel.getWorksheets().get(0);
//Protecting the worksheet with a password
worksheet.protect(ProtectionType.ALL, "aspose", null);
//Saving the modified Excel file in default (that is Excel 20003) format
excel.save("C:\\output.xls");
unprotect | |
public abstract void unprotect() |
-
Unprotects worksheet.
This method unprotects worksheet which is protected without password.
unprotect | |
public abstract void unprotect(java.lang.String password) |
-
Unprotects worksheet.
If the worksheet is protected without a password, you can set a null value or blank string to password parameter.
- Parameters:
password - Password
moveTo | |
public abstract void moveTo(int index) |
-
Moves the sheet to another location in the spreadsheet.
- Parameters:
index - Destination sheet index.
replace | |
public abstract int replace(java.lang.String oldString, java.lang.String newString) |
-
Replaces all cells' text with a new string.
- Parameters:
oldString - Old string value.newString - New string value.
getSelectedRanges | |
public abstract java.util.ArrayList getSelectedRanges() |
-
Gets selected ranges of cells in the designer spreadsheet.
- Returns:
- An java.util.ArrayList which contains selected ranges.
setBackground | |
public abstract void setBackground(byte[] pictureData) |
-
Sets worksheet background image.
NOTE: This member is now obsolete. Instead,
please use Worksheet.BackgroundImage property.
This property will be removed 12 months later since August 2016.
Aspose apologizes for any inconvenience you may have experienced.
- Parameters:
pictureData - Picture data.
-
Gets automatic page breaks.
Each cell area represents a paper.
- Parameters:
options - The print options
- Returns:
- The automatic page breaks areas.
calculateFormula | |
public abstract java.lang.Object calculateFormula(java.lang.String formula) |
-
Calculates a formula.
- Parameters:
formula - Formula to be calculated.
- Returns:
- Calculated formula result.
calculateFormula | |
public abstract java.lang.Object calculateFormula(java.lang.String formula, CalculationOptions opts) |
-
Calculates a formula.
- Parameters:
formula - Formula to be calculated.opts - Options for calculating formula
- Returns:
- Calculated formula result.
refreshPivotTables | |
public abstract void refreshPivotTables()
throws java.lang.Exception |
-
Refreshes all PivotTables in this Worksheet.
calculateFormula | |
public abstract void calculateFormula(boolean recursive, boolean ignoreError, ICustomFunction customFunction) |
-
Calculates all formulas in this worksheet.
- Parameters:
recursive - True means if the worksheet' cells depend on the cells of other worksheets,
the dependant cells in other worksheets will be calculated too.
False means all the formulas in the worksheet have been calculated and the values are right.ignoreError - Indicates if hide the error in calculating formulas.
The error may be unsupported function, external links, etc.customFunction - The custom formula calculation functions to extend the calculation engine.
calculateFormula | |
public abstract void calculateFormula(CalculationOptions options, boolean recursive) |
-
Calculates all formulas in this worksheet.
- Parameters:
options - Options for calculationrecursive - True means if the worksheet' cells depend on the cells of other worksheets,
the dependant cells in other worksheets will be calculated too.
False means all the formulas in the worksheet have been calculated and the values are right.
dispose | |
public abstract void dispose() |
-
See Also:
Aspose.Cells Documentation - the home page for the Aspose.Cellss Product Documentation.
Aspose.Cells Support Forum - our preferred method of support.