Example:
workbook = Workbook() 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 | ||
---|---|---|
method | getActiveCell() | |
method | setActiveCell(value) | |
Gets or sets the active cell in the worksheet. | ||
method | getAllowEditRanges() | |
Gets the allow edit range collection in the worksheet.
|
||
method | getAutoFilter() | |
Represents auto filter for the specified worksheet.
|
||
method | getBackgroundImage() | |
method | setBackgroundImage(value) | |
Gets and sets worksheet background image. | ||
method | getCells() | |
Gets the |
||
method | getCellWatches() | |
Gets collection of cells on this worksheet being watched in the 'watch window'.
|
||
method | getCharts() | |
Gets a |
||
method | getCheckBoxes() | |
Gets a |
||
method | getCodeName() | |
method | setCodeName(value) | |
Gets worksheet code name. | ||
method | getComments() | |
Gets the |
||
method | getConditionalFormattings() | |
Gets the ConditionalFormattings in the worksheet.
|
||
method | getCustomProperties() | |
Gets an object representing
the identifier information associated with a worksheet.
|
||
method | getDisplayRightToLeft() | |
method | setDisplayRightToLeft(value) | |
Indicates if the specified worksheet is displayed from right to left instead of from left to right. Default is false. | ||
method | getDisplayZeros() | |
method | setDisplayZeros(value) | |
True if zero values are displayed. | ||
method | getErrorCheckOptions() | |
Gets error check setting applied on certain ranges.
|
||
method | getFirstVisibleColumn() | |
method | setFirstVisibleColumn(value) | |
Represents first visible column index. | ||
method | getFirstVisibleRow() | |
method | setFirstVisibleRow(value) | |
Represents first visible row index. | ||
method | hasAutofilter() | |
Indicates whether this worksheet has auto filter.
|
||
method | getHorizontalPageBreaks() | |
Gets the |
||
method | getHyperlinks() | |
Gets the |
||
method | getIndex() | |
Gets the index of sheet in the worksheet collection.
|
||
method | isGridlinesVisible() | |
method | setGridlinesVisible(value) | |
Gets or sets a value indicating whether the gridlines are visible.Default is true. | ||
method | isOutlineShown() | |
method | setOutlineShown(value) | |
Indicates whether to show outline. | ||
method | isPageBreakPreview() | |
method | setPageBreakPreview(value) | |
Indicates whether the specified worksheet is shown in normal view or page break preview. | ||
method | isProtected() | |
Indicates if the worksheet is protected.
|
||
method | isRowColumnHeadersVisible() | |
method | setRowColumnHeadersVisible(value) | |
Gets or sets a value indicating whether the worksheet will display row and column headers. Default is true. | ||
method | isRulerVisible() | |
method | setRulerVisible(value) | |
Indicates whether the ruler is visible. This property is only applied for page break preview. | ||
method | isSelected() | |
method | setSelected(value) | |
Indicates whether this worksheet is selected when the workbook is opened. | ||
method | isVisible() | |
method | setVisible(value) | |
Represents if the worksheet is visible. | ||
method | getListObjects() | |
Gets all ListObjects in this worksheet.
|
||
method | getName() | |
method | setName(value) | |
Gets or sets the name of the worksheet. | ||
method | getOleObjects() | |
Represents a collection of |
||
method | getOutline() | |
Gets the outline on this worksheet.
|
||
method | getPageSetup() | |
Represents the page setup description in this sheet.
|
||
method | getPaneState() | |
Indicates whether the pane has horizontal or vertical splits, and whether those splits are frozen.
The value of the property is PaneStateType integer constant. |
||
method | getPictures() | |
Gets a |
||
method | getPivotTables() | |
Gets all pivot tables in this worksheet.
|
||
method | getProtection() | |
Represents the various types of protection options available for a worksheet. Supports advanced protection options in ExcelXP and above version.
|
||
method | getQueryTables() | |
Gets |
||
method | getScenarios() | |
Gets the collection of |
||
method | getShapes() | |
Returns all drawing shapes in this worksheet.
|
||
method | getShowFormulas() | |
method | setShowFormulas(value) | |
Indicates whether to show formulas or their results. | ||
method | getSlicers() | |
Get the Slicer collection in the worksheet
|
||
method | getSmartTagSetting() | |
Gets all |
||
method | getSparklineGroups() | |
Gets the sparkline groups in the worksheet.
|
||
method | getTabColor() | |
method | setTabColor(value) | |
Represents worksheet tab color. | ||
method | getTabId() | |
method | setTabId(value) | |
Specifies the internal identifier for the sheet. | ||
method | getTextBoxes() | |
Gets a |
||
method | getTimelines() | |
Get the Timeline collection in the worksheet
|
||
method | getTransitionEntry() | |
method | setTransitionEntry(value) | |
Indicates whether the Transition Formula Entry (Lotus compatibility) option is enabled. | ||
method | getTransitionEvaluation() | |
method | setTransitionEvaluation(value) | |
Indicates whether the Transition Formula Evaluation (Lotus compatibility) option is enabled. | ||
method | getType() | |
method | setType(value) | |
Represents worksheet type. The value of the property is SheetType integer constant. | ||
method | getUniqueId() | |
method | setUniqueId(value) | |
Gets and sets the unique id, it is same as {15DB5C3C-A5A1-48AF-8F25-3D86AC232D4F}. | ||
method | getValidations() | |
Gets the data validation setting collection in the worksheet.
|
||
method | getVerticalPageBreaks() | |
Gets the |
||
method | getViewType() | |
method | setViewType(value) | |
Gets and sets the view type. The value of the property is ViewType integer constant. | ||
method | getVisibilityType() | |
method | setVisibilityType(value) | |
Indicates the visible state for this sheet. The value of the property is VisibilityType integer constant. | ||
method | getWorkbook() | |
Gets the workbook object which contains this sheet.
|
||
method | getZoom() | |
method | setZoom(value) | |
Represents the scaling factor in percentage. It should be between 10 and 400. |
Method Summary | ||
---|---|---|
method | addPageBreaks(cellName) | |
Adds page break.
|
||
method | advancedFilter(isFilter, listRange, criteriaRange, copyTo, uniqueRecordOnly) | |
Filters data using complex criteria.
|
||
method | autoFitColumn(columnIndex) | |
Autofits the column width.
|
||
method | autoFitColumn(columnIndex, firstRow, lastRow) | |
Autofits the column width.
|
||
method | autoFitColumns() | |
Autofits all columns in this worksheet.
|
||
method | autoFitColumns(options) | |
Autofits all columns in this worksheet.
|
||
method | autoFitColumns(firstColumn, lastColumn) | |
Autofits the columns width.
|
||
method | autoFitColumns(firstColumn, lastColumn, options) | |
Autofits the columns width.
|
||
method | autoFitColumns(firstRow, firstColumn, lastRow, lastColumn) | |
Autofits the columns width.
|
||
method | autoFitColumns(firstRow, firstColumn, lastRow, lastColumn, options) | |
Autofits the columns width.
|
||
method | autoFitRow(rowIndex) | |
Autofits the row height.
|
||
method | autoFitRow(rowIndex, firstColumn, lastColumn) | |
Autofits the row height.
|
||
method | autoFitRow(rowIndex, firstColumn, lastColumn, options) | |
Autofits the row height.
|
||
method | autoFitRow(startRow, endRow, startColumn, endColumn) | |
Autofits row height in a rectangle range.
|
||
method | autoFitRows() | |
Autofits all rows in this worksheet.
|
||
method | autoFitRows(onlyAuto) | |
Autofits all rows in this worksheet.
|
||
method | autoFitRows(options) | |
Autofits all rows in this worksheet.
|
||
method | autoFitRows(startRow, endRow) | |
Autofits row height in a range.
|
||
method | autoFitRows(startRow, endRow, options) | |
Autofits row height in a range.
|
||
method | calculateArrayFormula(formula, opts) | |
Calculates a formula as array formula.
|
||
method | calculateArrayFormula(formula, opts, maxRowCount, maxColumnCount) | |
Calculates a formula as array formula.
|
||
method | calculateArrayFormula(formula, pOpts, cOpts, baseCellRow, baseCellColumn, maxRowCount, maxColumnCount, calculationData) | |
Calculates a formula as array formula.
|
||
method | calculateFormula(options, recursive) | |
Calculates all formulas in this worksheet.
|
||
method | calculateFormula(formula) | |
Calculates a formula.
|
||
method | calculateFormula(formula, opts) | |
Calculates a formula expression directly.
|
||
method | calculateFormula(formula, pOpts, cOpts, baseCellRow, baseCellColumn, calculationData) | |
Calculates a formula expression directly.
|
||
method | clearComments() | |
Clears all comments in designer spreadsheet.
|
||
method | closeAccessCache(opts) | |
Closes the session that uses caches to access the data in this worksheet.
|
||
method | convertFormulaReferenceStyle(formula, toR1C1, baseCellRow, baseCellColumn) | |
Converts the formula reference style.
|
||
method | copy(sourceSheet) | |
Copies contents and formats from another worksheet.
|
||
method | copy(sourceSheet, copyOptions) | |
Copies contents and formats from another worksheet.
|
||
method | dispose() | |
Performs application-defined tasks associated with freeing, releasing, or
resetting unmanaged resources.
|
||
method | freezePanes(row, column, freezedRows, freezedColumns) | |
Freezes panes at the specified cell in the worksheet.
|
||
method | freezePanes(cellName, freezedRows, freezedColumns) | |
Freezes panes at the specified cell in the worksheet.
|
||
method | getAdvancedFilter() | |
Gets the settings of advanced filter.
|
||
method | getFreezedPanes() | |
Gets the freeze panes.
|
||
method | getPanes() | |
Gets the window panes.
|
||
method | getPrintingPageBreaks(options) | |
Gets automatic page breaks.
|
||
method | getSelectedRanges() | |
Gets selected ranges of cells in the designer spreadsheet.
|
||
method | moveTo(index) | |
Moves the sheet to another location in the spreadsheet.
|
||
method | protect(type) | |
Protects worksheet.
|
||
method | protect(type, password, oldPassword) | |
Protects worksheet.
|
||
method | refreshPivotTables() | |
Refreshes all the PivotTables in this Worksheet.
|
||
method | refreshPivotTables(option) | |
Refreshes all the PivotTables in this Worksheet.
|
||
method | removeAllDrawingObjects() | |
Removes all drawing objects in this worksheet.
|
||
method | removeAutoFilter() | |
Removes the auto filter of the worksheet.
|
||
method | removeSplit() | |
Removes split window.
|
||
method | replace(oldString, newString) | |
Replaces all cells' text with a new string.
|
||
method | selectRange(startRow, startColumn, totalRows, totalColumns, removeOthers) | |
Selects a range.
|
||
method | setVisible(isVisible, ignoreError) | |
Sets the visible options.
|
||
method | split() | |
Splits window.
|
||
method | startAccessCache(opts) | |
Starts the session that uses caches to access the data in this worksheet.
|
||
method | toString() | |
Returns a string represents the current Worksheet object.
|
||
method | unFreezePanes() | |
Unfreezes panes in the worksheet.
|
||
method | unprotect() | |
Unprotects worksheet.
|
||
method | unprotect(password) | |
Unprotects worksheet.
|
||
method | xmlMapQuery(path, xmlMap) | |
Query cell areas that mapped/linked to the specific path of xml map.
|
Protection getProtection()
String getUniqueId() / setUniqueId(value)
QueryTableCollection getQueryTables()
PivotTableCollection getPivotTables()
int getType() / setType(value)
String getName() / setName(value)
boolean getShowFormulas() / setShowFormulas(value)
boolean isGridlinesVisible() / setGridlinesVisible(value)
boolean isRowColumnHeadersVisible() / setRowColumnHeadersVisible(value)
int getPaneState()
boolean getDisplayZeros() / setDisplayZeros(value)
boolean getDisplayRightToLeft() / setDisplayRightToLeft(value)
boolean isOutlineShown() / setOutlineShown(value)
boolean isSelected() / setSelected(value)
ListObjectCollection getListObjects()
int getTabId() / setTabId(value)
HorizontalPageBreakCollection getHorizontalPageBreaks()
VerticalPageBreakCollection getVerticalPageBreaks()
HyperlinkCollection getHyperlinks()
PageSetup getPageSetup()
AutoFilter getAutoFilter()
boolean hasAutofilter()
boolean getTransitionEvaluation() / setTransitionEvaluation(value)
boolean getTransitionEntry() / setTransitionEntry(value)
int getVisibilityType() / setVisibilityType(value)
boolean isVisible() / setVisible(value)
SparklineGroupCollection getSparklineGroups()
ChartCollection getCharts()
CommentCollection getComments()
PictureCollection getPictures()
TextBoxCollection getTextBoxes()
CheckBoxCollection getCheckBoxes()
OleObjectCollection getOleObjects()
ShapeCollection getShapes()
SlicerCollection getSlicers()
TimelineCollection getTimelines()
int getIndex()
boolean isProtected()
ValidationCollection getValidations()
ProtectedRangeCollection getAllowEditRanges()
ErrorCheckOptionCollection getErrorCheckOptions()
int getFirstVisibleRow() / setFirstVisibleRow(value)
int getFirstVisibleColumn() / setFirstVisibleColumn(value)
int getZoom() / setZoom(value)
int getViewType() / setViewType(value)
boolean isPageBreakPreview() / setPageBreakPreview(value)
boolean isRulerVisible() / setRulerVisible(value)
Color getTabColor() / setTabColor(value)
String getCodeName() / setCodeName(value)
byte[] getBackgroundImage() / setBackgroundImage(value)
ConditionalFormattingCollection getConditionalFormattings()
String getActiveCell() / setActiveCell(value)
CustomPropertyCollection getCustomProperties()
SmartTagSetting getSmartTagSetting()
ScenarioCollection getScenarios()
CellWatchCollection getCellWatches()
int replace(oldString, newString)
oldString: String
- Old string value.newString: String
- New string value.ArrayList getSelectedRanges()
CellArea[] getPrintingPageBreaks(options)
options: ImageOrPrintOptions
- The print optionsString toString()
startAccessCache(opts)
opts: int
- A closeAccessCache(opts)
opts: int
- A String convertFormulaReferenceStyle(formula, toR1C1, baseCellRow, baseCellColumn)
formula: String
- The formula to be converted.toR1C1: boolean
- Which reference style to convert the formula to.
If the original formula is of A1 reference style,
then this value should be true so the formula will be converted from A1 to R1C1 reference style;
If the original formula is of R1C1 reference style,
then this value should be false so the formula will be converted from R1C1 to A1 reference style;
baseCellRow: int
- The row index of the base cell.baseCellColumn: int
- The column index of the base cell.Object calculateFormula(formula)
formula: String
- Formula to be calculated.Object calculateFormula(formula, opts)
formula: String
- Formula to be calculated.opts: CalculationOptions
- Options for calculating formulaObject calculateFormula(formula, pOpts, cOpts, baseCellRow, baseCellColumn, calculationData)
formula: String
- Formula to be calculated.pOpts: FormulaParseOptions
- Options for parsing formula.cOpts: CalculationOptions
- Options for calculating formula.baseCellRow: int
- The row index of the base cell.baseCellColumn: int
- The column index of the base cell.calculationData: CalculationData
- The calculation data. It is used for the situation
that user needs to calculate some static formulas when implementing custom calculation engine.
For such kind of situation, user needs to specify it with the calculation data provided
for Object[][] calculateArrayFormula(formula, opts)
formula: String
- Formula to be calculated.opts: CalculationOptions
- Options for calculating formulaObject[][] calculateArrayFormula(formula, opts, maxRowCount, maxColumnCount)
formula: String
- Formula to be calculated.opts: CalculationOptions
- Options for calculating formulamaxRowCount: int
- the maximum row count of resultant data.
If it is non-positive or greater than the actual row count, then actual row count will be used.
maxColumnCount: int
- the maximum column count of resultant data.
If it is non-positive or greater than the actual row count, then actual column count will be used.
Object[][] calculateArrayFormula(formula, pOpts, cOpts, baseCellRow, baseCellColumn, maxRowCount, maxColumnCount, calculationData)
formula: String
- Formula to be calculated.pOpts: FormulaParseOptions
- Options for parsing formulacOpts: CalculationOptions
- Options for calculating formulabaseCellRow: int
- The row index of the base cell.baseCellColumn: int
- The column index of the base cell.maxRowCount: int
- The maximum row count of resultant data.
If it is non-positive or greater than the actual row count, then actual row count will be used.
maxColumnCount: int
- The maximum column count of resultant data.
If it is non-positive or greater than the actual row count, then actual column count will be used.
calculationData: CalculationData
- The calculation data. It is used for the situation
that user needs to calculate some static formulas when implementing custom calculation engine.
For such kind of situation, user needs to specify it with the calculation data provided
for calculateFormula(options, recursive)
options: CalculationOptions
- Options for calculationrecursive: boolean
- True means if the worksheet' cells depend on the cells of other worksheets,
the dependent cells in other worksheets will be calculated too.
False means all the formulas in the worksheet have been calculated and the values are right.ArrayList xmlMapQuery(path, xmlMap)
path: String
- xml element pathxmlMap: XmlMap
- Specify an xml map if you want to query for the specific path within a specific maprefreshPivotTables()
refreshPivotTables(option)
option: PivotTableRefreshOption
-
The option for refreshing data source of pivot table.
dispose()
PaneCollection getPanes()
freezePanes(row, column, freezedRows, 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 froze position and the last two parameters specify the area frozen on the left top pane.
row: int
- Row index.column: int
- Column index.freezedRows: int
- Number of visible rows in top pane, no more than row index.freezedColumns: int
- Number of visible columns in left pane, no more than column index.int[] getFreezedPanes()
split()
freezePanes(cellName, freezedRows, freezedColumns)
cellName: String
- Cell name.freezedRows: int
- Number of visible rows in top pane, no more than row index.freezedColumns: int
- Number of visible columns in left pane, no more than column index.unFreezePanes()
removeSplit()
addPageBreaks(cellName)
cellName: String
- copy(sourceSheet)
sourceSheet: Worksheet
- Source worksheet.copy(sourceSheet, copyOptions)
sourceSheet: Worksheet
- Source worksheet.copyOptions: CopyOptions
- autoFitColumn(columnIndex, firstRow, lastRow)
columnIndex: int
- Column index.firstRow: int
- First row index.lastRow: int
- Last row index.autoFitColumns()
autoFitColumns(options)
options: AutoFitterOptions
- The auto fitting options
autoFitColumn(columnIndex)
columnIndex: int
- Column index.autoFitColumns(firstColumn, lastColumn)
firstColumn: int
- First column index.lastColumn: int
- Last column index.autoFitColumns(firstColumn, lastColumn, options)
firstColumn: int
- First column index.lastColumn: int
- Last column index.options: AutoFitterOptions
- The auto fitting optionsautoFitColumns(firstRow, firstColumn, lastRow, lastColumn)
firstRow: int
- First row index.firstColumn: int
- First column index.lastRow: int
- Last row index.lastColumn: int
- Last column index.autoFitColumns(firstRow, firstColumn, lastRow, lastColumn, options)
firstRow: int
- First row index.firstColumn: int
- First column index.lastRow: int
- Last row index.lastColumn: int
- Last column index.options: AutoFitterOptions
- The auto fitting optionsautoFitRow(rowIndex, firstColumn, lastColumn)
rowIndex: int
- Row index.firstColumn: int
- First column index.lastColumn: int
- Last column index.autoFitRow(rowIndex, firstColumn, lastColumn, options)
rowIndex: int
- Row index.firstColumn: int
- First column index.lastColumn: int
- Last column index.options: AutoFitterOptions
- The auto fitter optionsautoFitRows()
autoFitRows(onlyAuto)
onlyAuto: boolean
-
True,only autofits the row height when row height is not customed.
autoFitRows(options)
options: AutoFitterOptions
- The auto fitter optionsautoFitRows(startRow, endRow)
startRow: int
- Start row index.endRow: int
- End row index.autoFitRows(startRow, endRow, options)
startRow: int
- Start row index.endRow: int
- End row index.options: AutoFitterOptions
- The options of auto fitter.autoFitRow(startRow, endRow, startColumn, endColumn)
startRow: int
- Start row index.endRow: int
- End row index.startColumn: int
- Start column index.endColumn: int
- End column index.autoFitRow(rowIndex)
rowIndex: int
- Row index.AdvancedFilter getAdvancedFilter()
advancedFilter(isFilter, listRange, criteriaRange, copyTo, uniqueRecordOnly)
isFilter: boolean
- Indicates whether filtering the list in place.listRange: String
- The list range.criteriaRange: String
- The criteria range.copyTo: String
- The range where copying data to. uniqueRecordOnly: boolean
- Only displaying or copying unique rows.removeAutoFilter()
setVisible(isVisible, ignoreError)
isVisible: boolean
- Whether the worksheet is visibleignoreError: boolean
- Whether to ignore error if this option is not valid.selectRange(startRow, startColumn, totalRows, totalColumns, removeOthers)
startRow: int
- The start row.
startColumn: int
- The start columntotalRows: int
- The number of rows.totalColumns: int
- The number of columnsremoveOthers: boolean
- True means removing other selected range and only select this range.
removeAllDrawingObjects()
clearComments()
protect(type)
type: int
- A protect(type, password, oldPassword)
type: int
- A password: String
- Password.oldPassword: String
- 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 excel = Workbook("Book2.xlsx") # Accessing the first worksheet in the Excel file worksheet = excel.getWorksheets().get(0) # Protecting the worksheet with a password worksheet.protect(ProtectionType.ALL, "aspose", None) # Saving the modified Excel file in default (that is Excel 20003) format excel.save("Book1.xls")
unprotect()
unprotect(password)
password: String
- PasswordmoveTo(index)
index: int
- Destination sheet index.