Worksheet

Overview

Worksheet is a class in Aspose.Cells for Python.

Represents a single worksheet in an Excel workbook.

Properties

NameTypeAccessDescription
name``Read/WriteIs the worksheet’s name
cells``ReadProvides access to the worksheet’s cell collection
visible``Read/WriteIndicates whether the worksheet is visible
tab_color``Read/WriteHolds the tab color hex string or None
auto_filter``ReadRepresents the worksheet’s auto‑filter settings
conditional_formats``ReadContains the worksheet’s conditional formatting rules
data_validations``ReadStores data validation objects for the worksheet
hyperlinks``ReadLists hyperlinks defined in the worksheet
charts``ReadHolds chart objects placed on the worksheet
shapes``ReadContains shape objects on the worksheet
tables``ReadProvides access to ListObject tables in the worksheet
sparkline_groups``ReadStores sparkline group definitions
pictures``ReadContains picture objects embedded in the worksheet
protection``ReadGives access to worksheet protection settings
page_setup``ReadContains page setup options for printing
page_margins``ReadProvides the worksheet’s page margin settings
properties``ReadHolds custom document properties for the worksheet
horizontal_page_breaks``ReadLists horizontal page breaks
vertical_page_breaks``ReadLists vertical page breaks
merged_cells``ReadEnumerates merged cell ranges
print_area``Read/WriteDefines the current print area range

Methods

SignatureDescription
__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.