WorksheetCollection class

WorksheetCollection class

Encapsulates a collection of Worksheet objects.

The WorksheetCollection type exposes the following members:

Properties

PropertyDescription
web_extension_task_panesGets the list of task panes.
web_extensionsGets the list of task panes.
threaded_comment_authorsGets the list of threaded comment authors.
is_refresh_all_connectionsIndicates whether refresh all connections on opening file in MS Excel.
namesGets the collection of all the Name objects in the spreadsheet.
active_sheet_nameRepresents the name of active worksheet when the spreadsheet is opened.
active_sheet_indexRepresents the index of active worksheet when the spreadsheet is opened.
dxfsGets the master differential formatting records.
xml_mapsGets and sets the XML maps in the workbook.
built_in_document_propertiesReturns a DocumentProperty collection that represents all the built-in document properties of the spreadsheet.
custom_document_propertiesReturns a DocumentProperty collection that represents all the custom document properties of the spreadsheet.
ole_sizeGets and Sets displayed size when Workbook file is used as an Ole object.
external_linksRepresents external links in a workbook.
table_stylesGets WorksheetCollection.table_styles object.
revision_logsRepresents revision logs.
capacityGets or sets the number of elements that the array list can contain.

Methods

MethodDescription
get(self, index)Add API for Python Via .Net.since this[int index] is unsupported
get(self, sheet_name)Add API for Python Via .Net.since this[string sheetName] is unsupported
add(self, type)Adds a worksheet to the collection.
add(self)Adds a worksheet to the collection.
add(self, sheet_name)Adds a worksheet to the collection.
register_add_in_function(self, add_in_file, function_name, lib)Adds addin function into the workbook
register_add_in_function(self, id, function_name)Adds addin function into the workbook
add_copy(self, sheet_name)Adds a worksheet to the collection and copies data from an existed worksheet.
add_copy(self, sheet_index)Adds a worksheet to the collection and copies data from an existed worksheet.
add_copy(self, source, dest_sheet_names)Copy a group of worksheets.
get_range_by_name(self, range_name)Gets Range object by pre-defined name.
get_range_by_name(self, range_name, current_sheet_index, include_table)Gets Range by pre-defined name or table’s name
refresh_pivot_tables(self)Refreshes all the PivotTables in the Excel file.
refresh_pivot_tables(self, option)Refreshes all the PivotTables in the Excel file.
copy_to(self, array)Copies the entire array list to a compatible one-dimensional array list, starting at the beginning of the target array list.
copy_to(self, index, array, array_index, count)Copies a range of elements from the array list to a compatible one-dimensional array list, starting at the specified index of the target array list.
index_of(self, item, index)Searches for the specified object and returns the zero-based index of the first occurrence within the range of elements in the array list that extends from the specified index to the last element.
index_of(self, item, index, count)Searches for the specified object and returns the zero-based index of the first occurrence within the range of elements in the array list that starts at the specified index and contains the specified number of elements.
last_index_of(self, item)Searches for the specified object and returns the zero-based index of the last occurrence within the entire array list.
last_index_of(self, item, index)Searches for the specified object and returns the zero-based index of the last occurrence within the range of elements in the array list that extends from the first element to the specified index.
last_index_of(self, item, index, count)Searches for the specified object and returns the zero-based index of the last occurrence within the range of elements in the array list that contains the specified number of elements and ends at the specified index.
create_range(self, address, sheet_index)Creates a Range object from an address of the range.
create_union_range(self, address, sheet_index)Creates a Range object from an address of the range.
get_sheet_by_code_name(self, code_name)Gets the worksheet by the code name.
sort_names(self)Sorts the defined names.
swap_sheet(self, sheet_index1, sheet_index2)Swaps the two sheets.
remove_by_name(self, name)Remove a sheet by sheet name.(CELLSPYTHONNET-192)
remove_by_index(self, index)Remove a sheet by sheet index
remove_at(self, name)Removes the element at a specified name.
get_named_ranges(self)Gets all pre-defined named ranges in the spreadsheet.
get_named_ranges_and_tables(self)Gets all pre-defined named ranges in the spreadsheet.
set_ole_size(self, start_row, end_row, start_column, end_column)Sets displayed size when Workbook file is used as an Ole object.
clear_pivottables(self)Clears pivot tables from the spreadsheet.
refresh_all(self)Refresh all pivot tables and charts with pivot source.
binary_search(self, item)Searches the entire sorted array list for an element using the default comparer and returns the zero-based index of the element.

Example

from aspose.cells import Workbook

workbook = Workbook()
sheets = workbook.worksheets
# Add a worksheet
sheets.add()
# Change the name of a worksheet
sheets[0].name = "First Sheet"
# Set the active sheet to the second worksheet
sheets.active_sheet_index = 1

See Also