Cell Classes

class numbers_parser.Cell[source]

Note

Do not instantiate directly. Cells are created by Document.

property border: CellBorder | None

The CellBorder associated with the cell or None.

Warns:
UnsupportedWarning: On assignment; use

numbers_parser.Table.set_cell_border() instead.

Type:

CellBorder| None

property bullets: List[str] | None

The bullets in a cell, or None

Cells that contain bulleted or numbered lists are identified by numbers_parser.Cell.is_bulleted. For these cells, numbers_parser.Cell.value returns the whole cell contents. Bullets can also be extracted into a list of paragraphs cell without the bullet or numbering character. Newlines are not included in the bullet list.

Example

doc = Document("bullets.numbers")
sheets = doc.sheets
tables = sheets[0].tables
table = tables[0]
if not table.cell(0, 1).is_bulleted:
    print(table.cell(0, 1).value)
else:
    bullets = ["* " + s for s in table.cell(0, 1).bullets]
    print("\n".join(bullets))
        return None
Type:

List[str] | None

property formatted_value: str

The formatted value of the cell as it appears in Numbers.

Interactive elements are converted into a suitable text format where supported, or as their number values where there is no suitable visual representation. Currently supported mappings are:

  • Checkboxes are U+2610 (Ballow Box) or U+2611 (Ballot Box with Check)

  • Ratings are their star value represented using (U+2605) (Black Star)

>>> table = doc.default_table
>>> table.cell(0,0).value
False
>>> table.cell(0,0).formatted_value
'☐'
>>> table.cell(0,1).value
True
>>> table.cell(0,1).formatted_value
'☑'
>>> table.cell(1,1).value
3.0
>>> table.cell(1,1).formatted_value
'★★★'
Type:

str

property is_bulleted: bool

True if the cell contains text bullets.

Type:

bool

property is_formula: bool

True if the cell contains a formula.

Type:

bool

property style: Style | None

The Style associated with the cell or None.

Warns:
UnsupportedWarning: On assignment; use

numbers_parser.Table.set_cell_style() instead.

Type:

Style | None

class numbers_parser.MergedCell[source]

Note

Do not instantiate directly. Cells are created by Document.

Cell.is_merged returns True for any cell that is the result of merging rows and/or columns. Cells eliminated from the table by the merge can still be indexed using Table.cell() and are of type MergedCell.

A1 B1
A2

The properties of merges are tested using the following properties:

Cell

Type

value

is_merged

size

rect

merge_range

A1

TextCell

A1

False

(1, 1)

None

None

A2

TextCell

A2

False

(1, 1)

None

None

B1

TextCell

B1

True

(2, 1)

None

None

B2

MergedCell

None

False

None

(1, 0, 2, 0)

"B1:B2"

The tuple values of the rect property of a MergedCell are also available using the properties row_start, col_start, row_end, and col_end.

class numbers_parser.RichTextCell[source]

Bases: Cell

Note

Do not instantiate directly. Cells are created by Document.

property bullets: List[str]

A list of the text bullets in the cell.

Type:

List[str]

property formatted_bullets: str

The bullets as a formatted multi-line string.

Type:

str

the hyperlinks in a cell or None

Numbers does not support hyperlinks to cells within a spreadsheet, but does allow embedding links in cells. When cells contain hyperlinks, numbers_parser returns the text version of the cell. The hyperlinks property of cells where numbers_parser.Cell.is_bulleted is True is a list of text and URL tuples.

Example

cell = table.cell(0, 0)
(text, url) = cell.hyperlinks[0]
Type:

List[Tuple] | None