Cell Classes¶
- class numbers_parser.Cell[source]¶
Represent a cell in a Numbers table.
Note
Do not instantiate directly. Cells are created by
Document.- property border: CellBorder¶
The
CellBorderassociated with the cell.- Warns:
UnsupportedWarning (On assignment; use) –
numbers_parser.Table.set_cell_border()instead.- Type:
CellBorder
- 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.valuereturns the whole cell contents. Bullets can also be extracted into a list of paragraphs without the bullet or numbering character. Newlines are not included in the bullet list.Example
doc = Document("mydoc.numbers") table = doc.sheets[0].tables["Examples"] 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))
- Type:
List[str] | None
- property comments: list[Comment]¶
Return a list of (comment, author) tuples for the cell.
- 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 (Ballot Box) or U+2611 (Ballot Box with Check)
Ratings are their star value represented using (U+2605) (Black Star)
>>> table = doc.sheets[0].tables["Examples"] >>> table.cell("B4").value False >>> table.cell("B4").formatted_value '☐' >>> table.cell("B5").value True >>> table.cell("B5").formatted_value '☑' >>> table.cell("B6").value 3.0 >>> table.cell("B6").formatted_value '★★★'
- Type:
str
- property formula: str | None¶
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 formula in a cell, or None if there is no formula present in a cell.
- Return type:
str
- Type:
str
- property image_data: bytes | None¶
Return the image data stored with the cell.
- property image_filename: str | None¶
Return the image filename stored with the cell.
- property is_bulleted: bool¶
Trueif the cell contains text bullets.- Type:
bool
- property is_formula: bool¶
Trueif the cell contains a formula.- Type:
bool
- property sheet_name: str¶
The name of the sheet the cell resides in.
- Type:
str
- property style: Style¶
The
Styleassociated with the cell.- Warns:
UnsupportedWarning (On assignment; use) –
numbers_parser.Table.set_cell_style()instead.- Type:
- property table_name: str¶
The name of the table the cell resides in.
- Type:
str
- property value: Any¶
Base class method.
- class numbers_parser.MergedCell[source]¶
Represent a cell covered by a merged range.
Note
Do not instantiate directly. Cells are created by
Document.Merged cells represent non-anchor positions in a merged range. Use
Cell.merge_rangeand the row/column boundary properties to inspect the range.- property value: None¶
Return or update the value represented by the cell.
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:
CellRepresent a rich-text 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: list[str]¶
The bullet paragraphs including their bullet markers.
- Type:
list[str]
- property hyperlinks: list[tuple[str, str]]¶
the hyperlinks in a cell.
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_bulletedisTrueis a list of text and URL tuples.Example
>>> table.cell(1, 2).value 'example.com' >>> table.cell(1, 2).hyperlinks [('example.com', 'http://example.com')]
- Type:
List[Tuple[str, str]]
- property value: str¶
Return or update the value represented by the cell.