dpmcore.services.layout_exporter

Export annotated DPM table layouts to Excel workbooks (hierarchical headers, data-point cells, dimensional annotations, and categorisation tooltips).

Note

Requires the export extra: pip install dpmcore[export].

LayoutExporterService

class dpmcore.services.layout_exporter.service.LayoutExporterService(session)[source]

Bases: object

Export annotated table layouts to Excel workbooks.

Parameters:

session (Session) – An open SQLAlchemy session.

__init__(session)[source]

Bind the service to an open SQLAlchemy session.

Parameters:

session (Session)

Return type:

None

export_module(module_code, release_code=None, output_path=None, config=None)[source]

Export all tables in a module to a single workbook.

Parameters:
  • module_code (str) – Module version code (e.g., ‘FINREP9’).

  • release_code (Optional[str]) – Optional release code filter.

  • output_path (Optional[str]) – Output file path. Defaults to ‘{module_code}.xlsx’.

  • config (Optional[ExportConfig]) – Export configuration flags.

Return type:

Path

Returns:

Path to the written file.

export_tables(table_codes, release_code=None, output_path=None, config=None)[source]

Export specific tables to a workbook.

Parameters:
  • table_codes (list[str]) – List of table codes (e.g., [‘F_01.01’, ‘F_01.02’]).

  • release_code (Optional[str]) – Optional release code filter.

  • output_path (Optional[str]) – Output file path.

  • config (Optional[ExportConfig]) – Export configuration flags.

Return type:

Path

Returns:

Path to the written file.

build_layout(table_code, release_code=None)[source]

Build the intermediate layout for a single table.

Useful for programmatic access without Excel generation.

Return type:

TableLayout

Parameters:
  • table_code (str)

  • release_code (str | None)

Configuration and models

class dpmcore.services.layout_exporter.models.ExportConfig(annotate=True, add_header_comments=True, add_cell_comments=True, show_code_row=True, show_code_column=True, show_abstract_header_codes=False)[source]

Configuration flags for the export.

Parameters:
  • annotate (bool)

  • add_header_comments (bool)

  • add_cell_comments (bool)

  • show_code_row (bool)

  • show_code_column (bool)

  • show_abstract_header_codes (bool)

annotate: bool = True
add_header_comments: bool = True
add_cell_comments: bool = True
show_code_row: bool = True
show_code_column: bool = True
show_abstract_header_codes: bool = False
class dpmcore.services.layout_exporter.models.TableLayout(table_vid, table_code, table_name, rows=<factory>, columns=<factory>, sheets=<factory>, cells=<factory>, max_col_depth=0, max_row_depth=0, dimension_ids=<factory>, is_open_row=False)[source]

Complete processed layout for one DPM table.

Parameters:
table_vid: int
table_code: str
table_name: str
rows: list[LayoutHeader]
columns: list[LayoutHeader]
sheets: list[LayoutHeader]
cells: dict[tuple[Optional[int], int, Optional[int]], CellData]
max_col_depth: int = 0
max_row_depth: int = 0
dimension_ids: list[tuple[int, str]]
is_open_row: bool = False