Worksheet
ImageRenderOptions
Worksheet vertegenwoordigt een enkel blad binnen een Workbook. Het biedt toegang tot de celverzameling, grafiekverzameling, afbeeldingsverzameling, vormverzameling en de autofilter voor dat blad. Werkbladen worden benaderd via index of naam vanuit workbook.worksheets.
from aspose.cells_foss import Workbook
workbook = Workbook()
worksheet = workbook.worksheets[0]
worksheet.cells["A1"].value = "Hello"
worksheet.cells["A2"].formula = "=A1"
workbook.save("output.xlsx")ImageRenderOptions
| Name | Type | Access | Description |
|---|---|---|---|
name | `` | Read/Write | Gets or sets the name of the worksheet. |
cells | `` | Read | Gets the Cells collection for this worksheet. |
visible | `` | Read/Write | Gets or sets the visibility state of the worksheet. |
tab_color | `` | Read/Write | Gets or sets the tab color of the worksheet. |
auto_filter | `` | Read | Gets the AutoFilter object for this worksheet. |
conditional_formats | `` | Read | Gets the collection of conditional formats for this worksheet. |
data_validations | `` | Read | Gets the collection of data validations for this worksheet. |
hyperlinks | `` | Read | Gets the collection of hyperlinks for this worksheet. |
charts | `` | Read | Gets the collection of charts for this worksheet. |
shapes | `` | Read | Gets the collection of drawing shapes for this worksheet. |
tables | `` | Read | Gets the collection of structured tables (ListObjects) for this worksheet. |
sparkline_groups | `` | Read | Gets the collection of sparkline groups for this worksheet. |
pictures | `` | Read | Gets the collection of pictures for this worksheet. |
protection | `` | Read | Gets the protection settings for this worksheet. |
page_setup | `` | Read | Gets the page setup settings for this worksheet. |
page_margins | `` | Read | Gets the page margins for this worksheet. |
properties | `` | Read | Gets the worksheet properties. |
horizontal_page_breaks | `` | Read | Gets manual horizontal page break collection. |
vertical_page_breaks | `` | Read | Gets manual vertical page break collection. |
merged_cells | `` | Read | Gets merged cell ranges in A1 notation. |
print_area | `` | Read/Write | Gets or sets print area in A1 notation. |
ImageRenderOptions
| 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) | |
ClearPrintArea() | |
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. |
ImageRenderOptions
Het volgende voorbeeld maakt een werkblad aan, stelt waarden en een formule in, past een stijl toe op een kopcel en slaat de werkmap op.
from aspose.cells_foss import Workbook
workbook = Workbook()
ws = workbook.worksheets[0]
ws.name = "Sales"
# Set header and data values
ws.cells["A1"].value = "Month"
ws.cells["B1"].value = "Revenue"
ws.cells["A2"].value = "January"
ws.cells["B2"].value = 12500
ws.cells["A3"].value = "February"
ws.cells["B3"].value = 14800
# Add a SUM formula
ws.cells["B4"].formula = "=SUM(B2:B3)"
# Apply bold styling to the header row
style = ws.cells["A1"].get_style()
style.font.bold = True
ws.cells["A1"].apply_style(style)
style2 = ws.cells["B1"].get_style()
style2.font.bold = True
ws.cells["B1"].apply_style(style2)
workbook.save("sales_report.xlsx")