The Sheets manages all Table objects in spreadsheet-documents. (sheet is a synonym for table)
Warning
Don’t create instances of this class by yourself, every spreadsheet-document has a sheets attribute.
Get count of sheets.
Get sheet by key, key is either the numerical index of the sheet or the name of the sheet.
Replace sheet key by sheet, key is either the numerical index of the sheet or the name of the sheet.
Delete sheet by key, key is either the numerical index of the sheet or the name of the sheet.
Append sheet as last sheet of spreadsheet-document.
Get index of sheet.
Insert sheet at position index.
Get list of sheet names.
The Table object represents a fixed sized table with size[0] rows and size[1] columns. Every cell contains a Cell object, even empty cells (value and value_type of empty cells are None).
Reference cells by (row, col) tuples or by classic spreadsheet cell references like 'A1'. The letters represent the column ('A' = column(0), 'B' = column(1), ...), the numbers represent the row ('1' = row(0), '2' = row(1), ...).
Specifies the name of the table, should be unique, and can contain spaces.
References a table style.
Get cell by key as Cell object, key is either a (row, col) tuple or a classic spreadsheet reference like 'A1''.
Set cell referenced by key to cell, cell has to be a Cell object and key is either a (row, col) tuple or a classic spreadsheet reference like 'A1''.
Get count of table columns.
Get count of table rows.
Delete table content and set new table metrics.
Get column-info of column index as TableColumn object.
Append count empty rows.
Insert count empty rows at index. CAUTION: This operation breaks cell references in formulas
Delete count rows at index. CAUTION: This operation breaks cell references in formulas
Append count empty columns.
Insert count empty columns at index. CAUTION: This operation breaks cell references in formulas
Delete count columns at index. CAUTION: This operation breaks cell references in formulas
Set cell span for cell at position pos to size, pos can be a (row, column) tuple or a reference string, size has to be a (nrows, ncols) tuple, where nrows and ncols are >= 1. Spanning is not possible if the spanning area contains other spanning cells.
The cell span value is an attribute of the Cell class. To request the span value use:
if table['A1'].span == (3, 2):
print("cell 'A1' spans over three rows and two columns")
Removes spanning for cell at position pos, pos can be a (row, column) tuple or a reference string.
Creates a new cell object. If value_type is None, the type will be determined by the type of value. value and value_type of empty cells are None.
Value Type | Description |
---|---|
'string' | Text content (python strings) |
'float' | Floating point numbers (python float) |
'percentage' | Floating point numbers, where 1.0 = 100% (python float) |
'currency' | Floating point numbers (python float) |
'boolean' | True or False (python bool) |
'date' | date value as string, form: 'yyyy-mm-dd' or 'yyyy-mm-ddThh:mm:ss' |
'time' | time period as string, form: 'PThhHmmMss,ffffS‘ |
Automatic typing:
Python type of Value | value_type of cell |
---|---|
str | 'string' |
float/int | 'float' |
bool | 'boolean' |
examples for setting table values:
# create new cell as float
table['A1'] = Cell(100.)
# or modify existing cell (preserves existing properties)
table['A1'].set_value(100.)
# set as currency
table['B1'].set_value(100, currency='EUR')
# set as string
table['C1'].set_value("Text")
# append text to string-cells
table['C1'].append_text("\nLine 2")
# set as date
table['D1'].set_value("2011-02-05", 'date')
example for getting cell values:
cell = Cell(3.141592)
pi = cell.value
Get converted cell values, numerical values as float, boolean values as bool and all others as str.
Get currency as string, if Cell.value_type is 'currency' else None.
References a table-cell style.
Formulas allow calculations to be performed within table cells. Typically, the formula itself begins with an equal (=) sign and can include the following components:
Protects the table cell. Users can not edit the content of a cell that is marked as protected. This attribute is not related to the Table.protected attribute for table elements.
Get cell spanning as (row, col) tuple.
Specify the number of rows and columns that a cell spans. When a cell covers another cell because of a column or row span value greater than one, the covered attribute of the covered cell is True.
True if cell is covered by other cells.
Display form of cell as str, set by other programs like LibreOffice or OpenOffice. ezodf does not set the display form.
References a table-row style.
Specifies whether the row is 'visible', 'filtered', or 'collapsed'.
Filtered and collapsed rows are not visible. Filtered rows are invisible, because a filter is applied to the table that does not select the table row. Collapsed rows have been made invisible by user directly.
References the default table-cell style.
References a table-column style.
Specifies whether the row is 'visible', 'filtered', or 'collapsed'.
Filtered and collapsed columns are not visible. Filtered columns are invisible, because a filter is applied to the table that does not select the table column. Collapsed columns have been made invisible by user directly.
References the default table-cell style.