public class 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");
Property Getters/Setters Summary | ||
---|---|---|
java.lang.String | getActiveCell() | |
void | setActiveCell(java.lang.Stringvalue) | |
Gets or sets the active cell in the worksheet. | ||
ProtectedRangeCollection | getAllowEditRanges() | |
Gets the allow edit range collection in the worksheet.
|
||
AutoFilter | getAutoFilter() | |
Represents auto filter for the specified worksheet.
|
||
byte[] | getBackgroundImage() | |
void | setBackgroundImage(byte[]value) | |
Gets and sets worksheet background image. | ||
Cells | getCells() | |
Gets the |
||
CellWatchCollection | getCellWatches() | |
Gets collection of cells on this worksheet being watched in the 'watch window'.
|
||
ChartCollection | getCharts() | |
Gets a |
||
CheckBoxCollection | getCheckBoxes() | |
Gets a |
||
java.lang.String | getCodeName() | |
void | setCodeName(java.lang.Stringvalue) | |
Gets worksheet code name. | ||
CommentCollection | getComments() | |
Gets the |
||
ConditionalFormattingCollection | getConditionalFormattings() | |
Gets the ConditionalFormattings in the worksheet.
|
||
CustomPropertyCollection | getCustomProperties() | |
Gets an object representing
the identifier information associated with a worksheet.
|
||
boolean | getDisplayRightToLeft() | |
void | setDisplayRightToLeft(booleanvalue) | |
Indicates if the specified worksheet is displayed from right to left instead of from left to right. Default is false. | ||
boolean | getDisplayZeros() | |
void | setDisplayZeros(booleanvalue) | |
True if zero values are displayed. | ||
ErrorCheckOptionCollection | getErrorCheckOptions() | |
Gets error check setting applied on certain ranges.
|
||
int | getFirstVisibleColumn() | |
void | setFirstVisibleColumn(intvalue) | |
Represents first visible column index. | ||
int | getFirstVisibleRow() | |
void | setFirstVisibleRow(intvalue) | |
Represents first visible row index. | ||
boolean | hasAutofilter() | |
Indicates whether this worksheet has auto filter.
|
||
HorizontalPageBreakCollection | getHorizontalPageBreaks() | |
Gets the |
||
HyperlinkCollection | getHyperlinks() | |
Gets the |
||
int | getIndex() | |
Gets the index of sheet in the worksheet collection.
|
||
boolean | isGridlinesVisible() | |
void | setGridlinesVisible(booleanvalue) | |
Gets or sets a value indicating whether the gridelines are visible.Default is true. | ||
boolean | isOutlineShown() | |
void | setOutlineShown(booleanvalue) | |
Indicates whether to show outline. | ||
boolean | isPageBreakPreview() | |
void | setPageBreakPreview(booleanvalue) | |
Indicates whether the specified worksheet is shown in normal view or page break preview. | ||
boolean | isProtected() | |
Indicates if the worksheet is protected.
|
||
boolean | isRowColumnHeadersVisible() | |
void | setRowColumnHeadersVisible(booleanvalue) | |
Gets or sets a value indicating whether the worksheet will display row and column headers. Default is true. | ||
boolean | isRulerVisible() | |
void | setRulerVisible(booleanvalue) | |
Indicates whether the ruler is visible. This property is only applied for page break preview. | ||
boolean | isSelected() | |
void | setSelected(booleanvalue) | |
Indicates whether this worksheet is selected when the workbook is opened. | ||
boolean | isVisible() | |
void | setVisible(booleanvalue) | |
Represents if the worksheet is visible. | ||
ListObjectCollection | getListObjects() | |
Gets all ListObjects in this worksheet.
|
||
java.lang.String | getName() | |
void | setName(java.lang.Stringvalue) | |
Gets or sets the name of the worksheet. | ||
OleObjectCollection | getOleObjects() | |
Represents a collection of |
||
Outline | getOutline() | |
Gets the outline on this worksheet.
|
||
PageSetup | getPageSetup() | |
Represents the page setup description in this sheet.
|
||
PictureCollection | getPictures() | |
Gets a |
||
PivotTableCollection | getPivotTables() | |
Gets all pivot tables in this worksheet.
|
||
Protection | getProtection() | |
Represents the various types of protection options available for a worksheet. Supports advanced protection options in ExcelXP and above version.
|
||
QueryTableCollection | getQueryTables() | |
Gets the queryTables in the worksheet.
|
||
ScenarioCollection | getScenarios() | |
Gets the collection of |
||
ShapeCollection | getShapes() | |
Returns all drawing shapes in this worksheet.
|
||
boolean | getShowFormulas() | |
void | setShowFormulas(booleanvalue) | |
Indicates whether to show formulas or their results. | ||
SlicerCollection | getSlicers() | |
Get the Slicer collection in the worksheet
|
||
SmartTagSetting | getSmartTagSetting() | |
Gets all |
||
SparklineGroupCollection | getSparklineGroupCollection() | |
Gets the sparkline group collection in the worksheet.
|
||
com.aspose.cells.Color | getTabColor() | |
void | setTabColor(com.aspose.cells.Colorvalue) | |
Represents worksheet tab color. | ||
int | getTabId() | |
void | setTabId(intvalue) | |
Specifies the internal identifier for the sheet. | ||
TextBoxCollection | getTextBoxes() | |
Gets a |
||
boolean | getTransitionEntry() | |
void | setTransitionEntry(booleanvalue) | |
Indicates whether the Transition Formula Entry (Lotus compatibility) option is enabled. | ||
boolean | getTransitionEvaluation() | |
void | setTransitionEvaluation(booleanvalue) | |
Indicates whether the Transition Formula Evaluation (Lotus compatibility) option is enabled. | ||
int | getType() | |
void | setType(intvalue) | |
Represents worksheet type. The value of the property is SheetType integer constant. | ||
java.lang.String | getUniqueId() | |
void | setUniqueId(java.lang.Stringvalue) | |
Gets and sets the unique id, it is same as {15DB5C3C-A5A1-48AF-8F25-3D86AC232D4F}. | ||
ValidationCollection | getValidations() | |
Gets the data validation setting collection in the worksheet.
|
||
VerticalPageBreakCollection | getVerticalPageBreaks() | |
Gets the |
||
int | getViewType() | |
void | setViewType(intvalue) | |
Gets and sets the view type. The value of the property is ViewType integer constant. | ||
int | getVisibilityType() | |
void | setVisibilityType(intvalue) | |
Indicates the visible state for this sheet. The value of the property is VisibilityType integer constant. | ||
Workbook | getWorkbook() | |
Gets the workbook object which contains this sheet.
|
||
int | getZoom() | |
void | setZoom(intvalue) | |
Represents the scaling factor in percentage. It should be between 10 and 400. |
Method Summary | ||
---|---|---|
void | addPageBreaks(java.lang.String cellName) | |
Adds page break.
|
||
void | advancedFilter(boolean isFilter, java.lang.String listRange, java.lang.String criteriaRange, java.lang.String copyTo, boolean uniqueRecordOnly) | |
Filters data using complex criteria.
|
||
void | autoFitColumn(int columnIndex) | |
Autofits the column width.
|
||
void | autoFitColumn(int columnIndex, int firstRow, int lastRow) | |
Autofits the column width.
|
||
void | autoFitColumns() | |
Autofits all columns in this worksheet.
|
||
void | autoFitColumns(AutoFitterOptions options) | |
Autofits all columns in this worksheet.
|
||
void | autoFitColumns(int firstColumn, int lastColumn) | |
Autofits the columns width.
|
||
void | autoFitColumns(int firstColumn, int lastColumn, AutoFitterOptions options) | |
Autofits the columns width.
|
||
void | autoFitColumns(int firstRow, int firstColumn, int lastRow, int lastColumn) | |
Autofits the columns width.
|
||
void | autoFitColumns(int firstRow, int firstColumn, int lastRow, int lastColumn, AutoFitterOptions options) | |
Autofits the columns width.
|
||
void | autoFitRow(int rowIndex) | |
Autofits the row height.
|
||
void | autoFitRow(int rowIndex, int firstColumn, int lastColumn) | |
Autofits the row height.
|
||
void | autoFitRow(int rowIndex, int firstColumn, int lastColumn, AutoFitterOptions options) | |
Autofits the row height.
|
||
void | autoFitRow(int startRow, int endRow, int startColumn, int endColumn) | |
Autofits row height in a rectangle range.
|
||
void | autoFitRows() | |
Autofits all rows in this worksheet.
|
||
void | autoFitRows(boolean onlyAuto) | |
Autofits all rows in this worksheet.
|
||
void | autoFitRows(AutoFitterOptions options) | |
Autofits all rows in this worksheet.
|
||
void | autoFitRows(int startRow, int endRow) | |
Autofits row height in a range.
|
||
void | autoFitRows(int startRow, int endRow, AutoFitterOptions options) | |
Autofits row height in a range.
|
||
void | calculateFormula(boolean recursive, boolean ignoreError, ICustomFunction customFunction) | |
Calculates all formulas in this worksheet.
|
||
void | calculateFormula(CalculationOptions options, boolean recursive) | |
Calculates all formulas in this worksheet.
|
||
java.lang.Object | calculateFormula(java.lang.String formula) | |
Calculates a formula.
|
||
java.lang.Object | calculateFormula(java.lang.String formula, CalculationOptions opts) | |
Calculates a formula.
|
||
void | clearComments() | |
Clears all comments in designer spreadsheet.
|
||
void | copy(Worksheet sourceSheet) | |
Copies contents and formats from another worksheet.
|
||
void | copy(Worksheet sourceSheet, CopyOptions copyOptions) | |
Copies contents and formats from another worksheet.
|
||
void | dispose() | |
Performs application-defined tasks associated with freeing, releasing, or
resetting unmanaged resources.
|
||
void | freezePanes(int row, int column, int freezedRows, int freezedColumns) | |
Freezes panes at the specified cell in the worksheet.
|
||
void | freezePanes(java.lang.String cellName, int freezedRows, int freezedColumns) | |
Freezes panes at the specified cell in the worksheet.
|
||
int[] | getFreezedPanes() | |
Gets the freeze panes.
|
||
PaneCollection | getPanes() | |
Gets the window panes.
|
||
com.aspose.cells.CellArea[] | getPrintingPageBreaks(ImageOrPrintOptions options) | |
Gets automatic page breaks.
|
||
java.util.ArrayList | getSelectedRanges() | |
Gets selected ranges of cells in the designer spreadsheet.
|
||
void | moveTo(int index) | |
Moves the sheet to another location in the spreadsheet.
|
||
void | protect(int type) | |
Protects worksheet.
|
||
void | protect(int type, java.lang.String password, java.lang.String oldPassword) | |
Protects worksheet.
|
||
void | refreshPivotTables() | |
Refreshes all the PivotTables in this Worksheet.
|
||
void | removeAllDrawingObjects() | |
Removes all drawing objects in this worksheet.
|
||
void | removeAutoFilter() | |
Removes the auto filter of the worksheet.
|
||
void | removeSplit() | |
Removes splitted window.
|
||
int | replace(java.lang.String oldString, java.lang.String newString) | |
Replaces all cells' text with a new string.
|
||
void | selectRange(int startRow, int startColumn, int totalRows, int totalColumns, boolean removeOthers) | |
Selects a range.
|
||
void | setBackground(byte[] pictureData) | |
Sets worksheet background image.
|
||
void | setVisible(boolean isVisible, boolean ignoreError) | |
Sets the visible options.
|
||
void | split() | |
Splits window.
|
||
java.lang.String | toString() | |
Returns a string represents the current Worksheet object.
|
||
void | unFreezePanes() | |
Unfreezes panes in the worksheet.
|
||
void | unprotect() | |
Unprotects worksheet.
|
||
void | unprotect(java.lang.String password) | |
Unprotects worksheet.
|
||
java.util.ArrayList | xmlMapQuery(java.lang.String path, XmlMap xmlMap) | |
Query cell areas that mapped/linked to the specific path of xml map.
|
public Protection getProtection()
public java.lang.String getUniqueId() / public void setUniqueId(java.lang.String value)
public Workbook getWorkbook()
public Cells getCells()
public QueryTableCollection getQueryTables()
public PivotTableCollection getPivotTables()
public int getType() / public void setType(int value)
public java.lang.String getName() / public void setName(java.lang.String value)
public boolean getShowFormulas() / public void setShowFormulas(boolean value)
public boolean isGridlinesVisible() / public void setGridlinesVisible(boolean value)
public boolean isRowColumnHeadersVisible() / public void setRowColumnHeadersVisible(boolean value)
public boolean getDisplayZeros() / public void setDisplayZeros(boolean value)
public boolean getDisplayRightToLeft() / public void setDisplayRightToLeft(boolean value)
public boolean isOutlineShown() / public void setOutlineShown(boolean value)
public boolean isSelected() / public void setSelected(boolean value)
public ListObjectCollection getListObjects()
public int getTabId() / public void setTabId(int value)
public HorizontalPageBreakCollection getHorizontalPageBreaks()
public VerticalPageBreakCollection getVerticalPageBreaks()
public HyperlinkCollection getHyperlinks()
public PageSetup getPageSetup()
public AutoFilter getAutoFilter()
public boolean hasAutofilter()
public boolean getTransitionEvaluation() / public void setTransitionEvaluation(boolean value)
public boolean getTransitionEntry() / public void setTransitionEntry(boolean value)
public int getVisibilityType() / public void setVisibilityType(int value)
public boolean isVisible() / public void setVisible(boolean value)
public SparklineGroupCollection getSparklineGroupCollection()
public ChartCollection getCharts()
public CommentCollection getComments()
public PictureCollection getPictures()
public TextBoxCollection getTextBoxes()
public CheckBoxCollection getCheckBoxes()
public OleObjectCollection getOleObjects()
public ShapeCollection getShapes()
public SlicerCollection getSlicers()
public int getIndex()
public boolean isProtected()
public ValidationCollection getValidations()
public ProtectedRangeCollection getAllowEditRanges()
public ErrorCheckOptionCollection getErrorCheckOptions()
public Outline getOutline()
public int getFirstVisibleRow() / public void setFirstVisibleRow(int value)
public int getFirstVisibleColumn() / public void setFirstVisibleColumn(int value)
public int getZoom() / public void setZoom(int value)
public int getViewType() / public void setViewType(int value)
public boolean isPageBreakPreview() / public void setPageBreakPreview(boolean value)
public boolean isRulerVisible() / public void setRulerVisible(boolean value)
public com.aspose.cells.Color getTabColor() / public void setTabColor(com.aspose.cells.Color value)
public java.lang.String getCodeName() / public void setCodeName(java.lang.String value)
public byte[] getBackgroundImage() / public void setBackgroundImage(byte[] value)
public ConditionalFormattingCollection getConditionalFormattings()
public java.lang.String getActiveCell() / public void setActiveCell(java.lang.String value)
public CustomPropertyCollection getCustomProperties()
public SmartTagSetting getSmartTagSetting()
public ScenarioCollection getScenarios()
public CellWatchCollection getCellWatches()
public int replace(java.lang.String oldString, java.lang.String newString)
oldString
- Old string value.newString
- New string value.public java.util.ArrayList getSelectedRanges()
public void setBackground(byte[] pictureData)
pictureData
- Picture data.public com.aspose.cells.CellArea[] getPrintingPageBreaks(ImageOrPrintOptions options) throws java.lang.Exception
options
- The print optionspublic java.lang.String toString()
public java.lang.Object calculateFormula(java.lang.String formula)
formula
- Formula to be calculated.public java.lang.Object calculateFormula(java.lang.String formula, CalculationOptions opts)
formula
- Formula to be calculated.opts
- Options for calculating formulapublic void calculateFormula(boolean recursive, boolean ignoreError, ICustomFunction customFunction)
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.public void calculateFormula(CalculationOptions options, boolean recursive)
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.public java.util.ArrayList xmlMapQuery(java.lang.String path, XmlMap xmlMap) throws java.lang.Exception
path
- xml element pathxmlMap
- Specify an xml map if you want to query for the specific path within a specific mappublic void refreshPivotTables() throws java.lang.Exception
public void dispose()
public PaneCollection getPanes()
public void freezePanes(int row, int column, int freezedRows, int freezedColumns)
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.
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.public int[] getFreezedPanes()
public void split()
public void freezePanes(java.lang.String cellName, int freezedRows, int freezedColumns)
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.public void unFreezePanes()
public void removeSplit()
public void addPageBreaks(java.lang.String cellName)
cellName
- public void copy(Worksheet sourceSheet) throws java.lang.Exception
sourceSheet
- Source worksheet.public void copy(Worksheet sourceSheet, CopyOptions copyOptions) throws java.lang.Exception
sourceSheet
- Source worksheet.copyOptions
- public void autoFitColumn(int columnIndex, int firstRow, int lastRow) throws java.lang.Exception
columnIndex
- Column index.firstRow
- First row index.lastRow
- Last row index.public void autoFitColumns() throws java.lang.Exception
public void autoFitColumns(AutoFitterOptions options) throws java.lang.Exception
options
- The auto fitting options
public void autoFitColumn(int columnIndex) throws java.lang.Exception
columnIndex
- Column index.public void autoFitColumns(int firstColumn, int lastColumn) throws java.lang.Exception
firstColumn
- First column index.lastColumn
- Last column index.public void autoFitColumns(int firstColumn, int lastColumn, AutoFitterOptions options) throws java.lang.Exception
firstColumn
- First column index.lastColumn
- Last column index.options
- The auto fitting optionspublic void autoFitColumns(int firstRow, int firstColumn, int lastRow, int lastColumn) throws java.lang.Exception
firstRow
- First row index.firstColumn
- First column index.lastRow
- Last row index.lastColumn
- Last column index.public void autoFitColumns(int firstRow, int firstColumn, int lastRow, int lastColumn, AutoFitterOptions options) throws java.lang.Exception
firstRow
- First row index.firstColumn
- First column index.lastRow
- Last row index.lastColumn
- Last column index.options
- The auto fitting optionspublic void autoFitRow(int rowIndex, int firstColumn, int lastColumn) throws java.lang.Exception
rowIndex
- Row index.firstColumn
- First column index.lastColumn
- Last column index.public void autoFitRow(int rowIndex, int firstColumn, int lastColumn, AutoFitterOptions options) throws java.lang.Exception
rowIndex
- Row index.firstColumn
- First column index.lastColumn
- Last column index.options
- The auto fitter optionspublic void autoFitRows() throws java.lang.Exception
public void autoFitRows(boolean onlyAuto) throws java.lang.Exception
onlyAuto
-
True,only autofits the row height when row height is not customed.
public void autoFitRows(AutoFitterOptions options) throws java.lang.Exception
options
- The auto fitter optionspublic void autoFitRows(int startRow, int endRow) throws java.lang.Exception
startRow
- Start row index.endRow
- End row index.public void autoFitRows(int startRow, int endRow, AutoFitterOptions options) throws java.lang.Exception
startRow
- Start row index.endRow
- End row index.options
- The options of auto fitter.public void autoFitRow(int startRow, int endRow, int startColumn, int endColumn) throws java.lang.Exception
startRow
- Start row index.endRow
- End row index.startColumn
- Start column index.endColumn
- End column index.public void autoFitRow(int rowIndex) throws java.lang.Exception
rowIndex
- Row index.public void advancedFilter(boolean isFilter, java.lang.String listRange, java.lang.String criteriaRange, java.lang.String copyTo, boolean uniqueRecordOnly)
isFilter
- Inidicates whether filtering the list in place.listRange
- The list range.criteriaRange
- The criteria range.copyTo
- The range where copying data to. uniqueRecordOnly
- Only displaying or copying unique rows.public void removeAutoFilter()
public void setVisible(boolean isVisible, boolean ignoreError)
isVisible
- Whether the worksheet is visibleignoreError
- Whether to ignore error if this option is not valid.public void selectRange(int startRow, int startColumn, int totalRows, int totalColumns, boolean removeOthers)
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.
public void removeAllDrawingObjects()
public void clearComments()
public void protect(int type)
type
- A public void protect(int type, java.lang.String password, java.lang.String oldPassword)
type
- A 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");
public void unprotect()
public void unprotect(java.lang.String password)
password
- Passwordpublic void moveTo(int index)
index
- Destination sheet index.