Border Class

numbers-parser supports reading and writing cell borders, though the interface for each differs. Individual cells can have each of their four borders tested, but when drawing new borders, these are set for the table to allow for drawing borders across multiple cells. Setting the border of merged cells is not possible unless the edge of the cells is at the end of the merged region.

Borders are represented using the Border class that can be initialized with line width, color and line style. The current state of a cell border is read using the Cell.border

property. The Table.set_cell_border sets the border for a cell edge or a range of cells.

class numbers_parser.Border(width: float = 0.35, color: RGB | None = None, style: BorderType | None = None, _order: int = 0)[source]

Create a cell border to use with the Table method set_cell_border().

border_style = Border(8.0, RGB(29, 177, 0)
table.set_cell_border("B6", "left", border_style, "solid"), 3)
table.set_cell_border(6, 1, "right", border_style, "dashes"))
Parameters:
  • width (float, optional, default: 0.35) – Number of rows in the first table of a new document.

  • color (RGB, optional, default: RGB(0, 0, 0)) – The line color for the border if present

  • style (BorderType, optional, default: None) –

    The type of border to create or None if there is no border defined. Valid border types are:

    • "solid": a solid line

    • "dashes": a dashed line

    • "dots": a dotted line

Raises:

TypeError: – If the width is not a float, or the border type is invalid.