Worksheet
Overview
Worksheet is a class in Aspose.Cells for Python.
Represents a single worksheet in an Excel workbook.
Properties
| Name | Type | Access | Description |
|---|---|---|---|
name | `` | Read/Write | Is the worksheet’s name |
cells | `` | Read | Provides access to the worksheet’s cell collection |
visible | `` | Read/Write | Indicates whether the worksheet is visible |
tab_color | `` | Read/Write | Holds the tab color hex string or None |
auto_filter | `` | Read | Represents the worksheet’s auto‑filter settings |
conditional_formats | `` | Read | Contains the worksheet’s conditional formatting rules |
data_validations | `` | Read | Stores data validation objects for the worksheet |
hyperlinks | `` | Read | Lists hyperlinks defined in the worksheet |
charts | `` | Read | Holds chart objects placed on the worksheet |
shapes | `` | Read | Contains shape objects on the worksheet |
tables | `` | Read | Provides access to ListObject tables in the worksheet |
sparkline_groups | `` | Read | Stores sparkline group definitions |
pictures | `` | Read | Contains picture objects embedded in the worksheet |
protection | `` | Read | Gives access to worksheet protection settings |
page_setup | `` | Read | Contains page setup options for printing |
page_margins | `` | Read | Provides the worksheet’s page margin settings |
properties | `` | Read | Holds custom document properties for the worksheet |
horizontal_page_breaks | `` | Read | Lists horizontal page breaks |
vertical_page_breaks | `` | Read | Lists vertical page breaks |
merged_cells | `` | Read | Enumerates merged cell ranges |
print_area | `` | Read/Write | Defines the current print area range |
Methods
| Signature | Description |
|---|---|
__init__(name) | Initializes a new instance of the Worksheet class. |
rename(new_name) | Renames the worksheet. |
set_visibility(value) | Set worksheet visibility. |
get_visibility() | Return current worksheet visibility (True, False, or ‘veryHidden’). |
set_tab_color(color) | Set the worksheet tab color. |
get_tab_color() | Return the worksheet tab color (8-char AARRGGBB hex) or None. |
clear_tab_color() | Clear the worksheet tab color. |
set_page_orientation(orientation) | Set page orientation. |
get_page_orientation() | Return the page orientation (‘portrait’, ’landscape’, or None). |
set_paper_size(paper_size) | Set the paper size (integer code, e.g. |
get_paper_size() | Return the paper size integer code. |
set_page_margins(left, right, top, bottom, header, footer) | Set page margins (in inches). |
get_page_margins() | Return a copy of the page margins dict. |
set_fit_to_pages(width, height) | Set fit-to-pages: width and height are page counts (0 = auto). |
set_print_scale(scale) | Set print scale percentage (10–400). |
set_print_area(print_area) | Sets the worksheet print area. |
clear_print_area() | Clears the worksheet print area. |
SetPrintArea(print_area) | Defines the worksheet’s print area (case‑variant alias) |
ClearPrintArea() | Removes any defined print area (case‑variant alias) |
is_protected() | Checks if the worksheet is protected. |
protect(password, format_cells, format_columns, format_rows, insert_columns, insert_rows, delete_columns, delete_rows, sort, auto_filter, insert_hyperlinks, pivot_tables, select_locked_cells, select_unlocked_cells, objects, scenarios) | Protects the worksheet with optional password and protection options. |
unprotect(password) | Unprotects the worksheet. |
set_view(zoom, show_grid_lines, show_row_col_headers) | Sets view options for the worksheet. |
copy(name) | Creates a copy of the worksheet. |
delete() | Deletes the worksheet from the workbook. |
move(index) | Moves the worksheet to the specified position in the workbook. |
select() | Selects the worksheet. |
activate() | Activates the worksheet (makes it the active worksheet). |
calculate_formula() | Calculates formulas in the worksheet. |
get_range(start_cell, end_cell) | Gets a range of cells. |