openafpm_cad_core.spreadsheet

Package exposing members for defining FreeCAD spreadsheets.

class Alignment(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

Enumeration of cell alignment.

See also, FreeCAD source code.

BOTTOM = 'bottom'
HORIZONTAL_CENTER = 'center'
LEFT = 'left'
RIGHT = 'right'
TOP = 'top'
VERTICAL_CENTER = 'vcenter'
classmethod encode(alignments: Tuple[Alignment, Alignment]) str

Encode horizontal and vertical alignment as a string.

See also, FreeCAD source code.

class Cell(content: str = '', alias: str = '', styles: List[Style] = [], horizontal_alignment: Alignment = Alignment.LEFT, vertical_alignment: Alignment = Alignment.VERTICAL_CENTER, background: Tuple[float, float, float, float] = (1.0, 1.0, 1.0, 1.0), foreground: Tuple[float, float, float, float] = (0.0, 0.0, 0.0, 1.0))

Bases: object

Represents a cell in a FreeCAD spreadsheet.

property alignment: str
property style: str
class Color(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

Enumeration of default background and foreground colors in the form (r, g, b, a).

Where (r, g, b, a) are float values in the range 0 to 1 inclusive:

  • r = red

  • g = green

  • b = blue

  • a = alpha (opacity)

BLACK = (0.0, 0.0, 0.0, 1.0)
LIGHT_GRAY = (0.752941, 0.752941, 0.752941, 1.0)
WHITE = (1.0, 1.0, 1.0, 1.0)
class Style(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

Enumeration of cell styles.

See also, FreeCAD source code.

BOLD = 'bold'
ITALIC = 'italic'
UNDERLINE = 'underline'
classmethod encode(styles: List[Style]) str

Encode a set of styles as a string.

See also, FreeCAD source code.

populate_spreadsheet(spreadsheet: object, cells: List[List[Cell]], cancel_event=None) None

Populates a spreadsheet object with the given cells.

spreadsheet = document.addObject('Spreadsheet::Sheet', name)
populate_spreadsheet(spreadsheet, cells)

cell

class Alignment(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

Enumeration of cell alignment.

See also, FreeCAD source code.

BOTTOM = 'bottom'
HORIZONTAL_CENTER = 'center'
LEFT = 'left'
RIGHT = 'right'
TOP = 'top'
VERTICAL_CENTER = 'vcenter'
classmethod encode(alignments: Tuple[Alignment, Alignment]) str

Encode horizontal and vertical alignment as a string.

See also, FreeCAD source code.

class Cell(content: str = '', alias: str = '', styles: List[Style] = [], horizontal_alignment: Alignment = Alignment.LEFT, vertical_alignment: Alignment = Alignment.VERTICAL_CENTER, background: Tuple[float, float, float, float] = (1.0, 1.0, 1.0, 1.0), foreground: Tuple[float, float, float, float] = (0.0, 0.0, 0.0, 1.0))

Bases: object

Represents a cell in a FreeCAD spreadsheet.

property alignment: str
property style: str
class Color(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

Enumeration of default background and foreground colors in the form (r, g, b, a).

Where (r, g, b, a) are float values in the range 0 to 1 inclusive:

  • r = red

  • g = green

  • b = blue

  • a = alpha (opacity)

BLACK = (0.0, 0.0, 0.0, 1.0)
LIGHT_GRAY = (0.752941, 0.752941, 0.752941, 1.0)
WHITE = (1.0, 1.0, 1.0, 1.0)
class Style(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

Enumeration of cell styles.

See also, FreeCAD source code.

BOLD = 'bold'
ITALIC = 'italic'
UNDERLINE = 'underline'
classmethod encode(styles: List[Style]) str

Encode a set of styles as a string.

See also, FreeCAD source code.

column_number_mappers

Module containing functions to map a number to a column and vise-versa.

map_column_to_number(column: str) int

Maps a letter representing a column to a number.

>>> map_column_to_number('A')
1
>>> map_column_to_number('B')
2
>>> map_column_to_number('Z')
26
>>> map_column_to_number('AA')
27
>>> map_column_to_number('AB')
28
>>> map_column_to_number('AZ')
52
>>> map_column_to_number('ZZ')
702
map_number_to_column(number: int) str

Maps a number representing a column to a number.

The first column corresponds to 1, instead of 0.

>>> map_number_to_column(1)
'A'
>>> map_number_to_column(2)
'B'
>>> map_number_to_column(26)
'Z'
>>> map_number_to_column(27)
'AA'
>>> map_number_to_column(28)
'AB'
>>> map_number_to_column(52)
'AZ'
>>> map_number_to_column(702)
'ZZ'

populate_spreadsheet

populate_spreadsheet(spreadsheet: object, cells: List[List[Cell]], cancel_event=None) None

Populates a spreadsheet object with the given cells.

spreadsheet = document.addObject('Spreadsheet::Sheet', name)
populate_spreadsheet(spreadsheet, cells)