Sheet Class

Each Sheet object represents a single sheet in a Numbers document. Sheets are returned by the the Table property sheets and can be indexed using either list style or dict style indexes:

>>> from numbers_parser import Document
>>> doc = Document("mydoc.numbers")
>>> doc.sheets[0]
<numbers_parser.document.Sheet object at 0x105f12390>
>>> doc.sheets[0].name
'Sheet 1'
>>> doc.sheets["Sheet 1"].name
'Sheet 1'

Note

Do not instantiate directly. Sheets are created by Document.

class numbers_parser.Sheet[source]
add_table(table_name: str | None = None, x: float | None = None, y: float | None = None, num_rows: int | None = 12, num_cols: int | None = 8) Table[source]

Add a new table to the current sheet.

If no table name is provided, the next available numbered table will be generated in the series Table 1, Table 2, etc.

By default, new tables are positioned at a fixed offset below the last table vertically in a sheet and on the left side of the sheet. Large table headers and captions may result in new tables overlapping existing ones. The add_table method takes optional coordinates for positioning a table. A table’s height and coordinates can also be queried to help aligning new tables:

(x, y) = sheet.table[0].coordinates
y += sheet.table[0].height + 200.0
new_table = sheet.add_table("Offset Table", x, y)
Parameters:
  • table_name (str, optional) – The name of the new table.

  • x (float, optional) – The x offset for the table in points.

  • y (float, optional) – The y offset for the table in points.

  • num_rows (int, optional, default: 12) – The number of rows for the new table.

  • num_cols (int, optional, default: 10) – The number of columns for the new table.

Returns:

The newly created table.

Return type:

Table

Raises:

IndexError – If the table name already exists.:

property name: str

The name of the sheet.

Type:

str

property tables: List[Table]

A list of tables in the sheet.

Type:

List[Table]