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 orNone
.- 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 formula: str¶
The formula in a cell.
Formula evaluation relies on Numbers storing current values which should usually be the case. In cells containing a formula,
numbers_parser.Cell.value()
returns computed value of the formula.- Returns:
The text of the foruma in a cell, or None if there is no formula present in a cell.
- Return type:
str
- 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
- 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 |
|
|
|
|
|
---|---|---|---|---|---|---|
A1 |
TextCell |
|
|
(1, 1) |
|
|
A2 |
TextCell |
|
|
(1, 1) |
|
|
B1 |
TextCell |
|
|
(2, 1) |
|
|
B2 |
MergedCell |
|
|
|
(1, 0, 2, 0) |
|
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
- property hyperlinks: list[tuple] | None¶
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
isTrue
is a list of text and URL tuples.Example
cell = table.cell(0, 0) (text, url) = cell.hyperlinks[0]
- Type:
List[Tuple] | None