gridient package
Submodules
gridient.layout module
- class gridient.layout.ExcelLayout(workbook: ExcelWorkbook)[source]
Bases:
objectTop-level layout manager for the workbook. Orchestrates writing.
- add_sheet(sheet: ExcelSheetLayout) None[source]
Add a sheet layout to the workbook.
- class gridient.layout.ExcelSheetLayout(name: str, auto_width: bool = True)[source]
Bases:
objectManages component layout for a single worksheet.
- add(component: Any, row: int, col: int, direction: str | None = 'down') None[source]
Add a component at a specific position with optional direction.
- get_components() List[PlacedComponent][source]
gridient.stacks module
- class gridient.stacks.ExcelStack(orientation: str, children: ~typing.List[~typing.Any] = <factory>, padding: int = 0, spacing: int = 1, name: str | None = None)[source]
Bases:
objectA container for arranging layout components vertically or horizontally.
- add(component: Any)[source]
Add a component (ExcelValue, ExcelTable, ExcelSeries, ExcelStack) to the stack.
- children: List[Any]
- get_size() Tuple[int, int][source]
Calculate and return the total size (rows, columns) of the stack including padding.
- name: str | None = None
- orientation: str
- padding: int = 0
- spacing: int = 1
- write(worksheet: xlsxwriter.worksheet.Worksheet, start_row: int, start_col: int, workbook_wrapper: ExcelWorkbook, ref_map: dict, column_widths: dict)[source]
Write the stack’s children to the worksheet.
gridient.styling module
- class gridient.styling.ExcelStyle(bold: bool = False, italic: bool = False, font_color: str | None = None, bg_color: str | None = None)[source]
Bases:
objectDefines visual styling for Excel elements.
- bg_color: str | None = None
- bold: bool = False
- font_color: str | None = None
- italic: bool = False
gridient.tables module
- class gridient.tables.ExcelParameterTable(title: str | None = None, parameters: List[ExcelValue] | None = None)[source]
Bases:
objectSpecialized table for displaying named parameters (Name, Value, Unit).
- add(value: ExcelValue) None[source]
Add a parameter to the table.
- write(worksheet: Any, row: int, col: int, workbook_wrapper: ExcelWorkbook, ref_map: dict, column_widths: Dict[int, float] | None = None)[source]
Writes the parameter table to Excel.
- class gridient.tables.ExcelTable(title: str | None = None, columns: List[ExcelTableColumn | ExcelSeries] | None = None)[source]
Bases:
objectRepresents a table of values with columns and an optional title.
- add_column(column: ExcelTableColumn | ExcelSeries) None[source]
Add a column to the table.
- write(worksheet: Any, row: int, col: int, workbook_wrapper: ExcelWorkbook, ref_map: dict, column_widths: Dict[int, float] | None = None)[source]
Writes the table to Excel.
- class gridient.tables.ExcelTableColumn(series: ExcelSeries)[source]
Bases:
objectRepresents a single column within an ExcelTable.
- series: ExcelSeries
gridient.values module
- class gridient.values.ExcelFormula(operator_or_function: str, arguments: ~typing.List[~typing.Any] = <factory>)[source]
Bases:
objectRepresents an Excel formula or function call.
- arguments: List[Any]
- operator_or_function: str
- operator_precedence = {'*': 3, '+': 2, '-': 2, '/': 3, '<': 1, '<=': 1, '<>': 1, '=': 1, '>': 1, '>=': 1, '^': 4}
- class gridient.values.ExcelSeries(name: str | None = None, format: str | None = None, style: ExcelStyle | None = None, index: list | None = None, data: dict | list | None = None)[source]
Bases:
objectRepresents a series of Excel values, potentially indexed.
- classmethod from_pandas(series: Series, name: str | None = None, format: str | None = None, style: ExcelStyle | None = None)[source]
Create an ExcelSeries from a pandas Series.
- class gridient.values.ExcelValue(value: Any, name: str | None = None, format: str | None = None, unit: str | None = None, style: ExcelStyle | None = None, _id: int | None = None, is_parameter: bool = False)[source]
Bases:
objectBase class for any value that can be written to Excel.
- property excel_ref: str
Returns the Excel cell reference (e.g., ‘A1’) for this value once placed.
- property value
gridient.workbook module
- class gridient.workbook.ExcelWorkbook(filename: str)[source]
Bases:
objectWrapper for xlsxwriter.Workbook with format caching.
- add_worksheet(name: str | None = None)[source]
Add a new worksheet to the workbook with name validation.
- get_combined_format(style: ExcelStyle | None, num_format: str | None)[source]
Get or create a cached xlsxwriter format object combining style and number format.
- validate_worksheet_name(name: str | None) None[source]
Validate worksheet name according to Excel rules.
Rules: - Names cannot be blank - Names cannot contain more than 31 characters - Names cannot contain any of these characters: / ? * : [ ] - Names cannot begin or end with an apostrophe (‘) - Names cannot be the reserved word “History”
Raises ValueError if the name is invalid.
Module contents
ExcelAlchemy: Write Python calculations to Excel with live formulas.
- class gridient.ExcelFormula(operator_or_function: str, arguments: ~typing.List[~typing.Any] = <factory>)[source]
Bases:
objectRepresents an Excel formula or function call.
- arguments: List[Any]
- operator_or_function: str
- operator_precedence = {'*': 3, '+': 2, '-': 2, '/': 3, '<': 1, '<=': 1, '<>': 1, '=': 1, '>': 1, '>=': 1, '^': 4}
- class gridient.ExcelLayout(workbook: ExcelWorkbook)[source]
Bases:
objectTop-level layout manager for the workbook. Orchestrates writing.
- add_sheet(sheet: ExcelSheetLayout) None[source]
Add a sheet layout to the workbook.
- class gridient.ExcelParameterTable(title: str | None = None, parameters: List[ExcelValue] | None = None)[source]
Bases:
objectSpecialized table for displaying named parameters (Name, Value, Unit).
- add(value: ExcelValue) None[source]
Add a parameter to the table.
- write(worksheet: Any, row: int, col: int, workbook_wrapper: ExcelWorkbook, ref_map: dict, column_widths: Dict[int, float] | None = None)[source]
Writes the parameter table to Excel.
- class gridient.ExcelSeries(name: str | None = None, format: str | None = None, style: ExcelStyle | None = None, index: list | None = None, data: dict | list | None = None)[source]
Bases:
objectRepresents a series of Excel values, potentially indexed.
- classmethod from_pandas(series: Series, name: str | None = None, format: str | None = None, style: ExcelStyle | None = None)[source]
Create an ExcelSeries from a pandas Series.
- class gridient.ExcelSheetLayout(name: str, auto_width: bool = True)[source]
Bases:
objectManages component layout for a single worksheet.
- add(component: Any, row: int, col: int, direction: str | None = 'down') None[source]
Add a component at a specific position with optional direction.
- get_components() List[PlacedComponent][source]
- class gridient.ExcelStack(orientation: str, children: ~typing.List[~typing.Any] = <factory>, padding: int = 0, spacing: int = 1, name: str | None = None)[source]
Bases:
objectA container for arranging layout components vertically or horizontally.
- add(component: Any)[source]
Add a component (ExcelValue, ExcelTable, ExcelSeries, ExcelStack) to the stack.
- children: List[Any]
- get_size() Tuple[int, int][source]
Calculate and return the total size (rows, columns) of the stack including padding.
- name: str | None = None
- orientation: str
- padding: int = 0
- spacing: int = 1
- write(worksheet: xlsxwriter.worksheet.Worksheet, start_row: int, start_col: int, workbook_wrapper: ExcelWorkbook, ref_map: dict, column_widths: dict)[source]
Write the stack’s children to the worksheet.
- class gridient.ExcelStyle(bold: bool = False, italic: bool = False, font_color: str | None = None, bg_color: str | None = None)[source]
Bases:
objectDefines visual styling for Excel elements.
- bg_color: str | None = None
- bold: bool = False
- font_color: str | None = None
- italic: bool = False
- class gridient.ExcelTable(title: str | None = None, columns: List[ExcelTableColumn | ExcelSeries] | None = None)[source]
Bases:
objectRepresents a table of values with columns and an optional title.
- add_column(column: ExcelTableColumn | ExcelSeries) None[source]
Add a column to the table.
- write(worksheet: Any, row: int, col: int, workbook_wrapper: ExcelWorkbook, ref_map: dict, column_widths: Dict[int, float] | None = None)[source]
Writes the table to Excel.
- class gridient.ExcelTableColumn(series: ExcelSeries)[source]
Bases:
objectRepresents a single column within an ExcelTable.
- series: ExcelSeries
- class gridient.ExcelValue(value: Any, name: str | None = None, format: str | None = None, unit: str | None = None, style: ExcelStyle | None = None, _id: int | None = None, is_parameter: bool = False)[source]
Bases:
objectBase class for any value that can be written to Excel.
- property excel_ref: str
Returns the Excel cell reference (e.g., ‘A1’) for this value once placed.
- property value
- class gridient.ExcelWorkbook(filename: str)[source]
Bases:
objectWrapper for xlsxwriter.Workbook with format caching.
- add_worksheet(name: str | None = None)[source]
Add a new worksheet to the workbook with name validation.
- get_combined_format(style: ExcelStyle | None, num_format: str | None)[source]
Get or create a cached xlsxwriter format object combining style and number format.
- validate_worksheet_name(name: str | None) None[source]
Validate worksheet name according to Excel rules.
Rules: - Names cannot be blank - Names cannot contain more than 31 characters - Names cannot contain any of these characters: / ? * : [ ] - Names cannot begin or end with an apostrophe (‘) - Names cannot be the reserved word “History”
Raises ValueError if the name is invalid.