class documentation

Export a Report into an xlsx (MS Excel) file.

It use pandas.ExcelWriter with openpyxl as engine.

Development notes: Improve it based on Moffitt, Chris (2015): Improving Pandas Excel Output. Hg. v. Practical Business Python. Online available at https://pbpython.com/improve-pandas-excel-output.html

Method __init__ Initiate the document.
Method dataframe_to_table Convert table element into an excel table.
Method save Start converting all report elements to an Excel file.
Method string_to_heading Add heading string into an excel file.
Instance Variable _current_heading_level The current active heading level.
Instance Variable _xlsx_writer Undocumented

Inherited from _GenericDocumentOutput:

Method show Open the generated document with the file type associated application.
Instance Variable file_path Path to the file.
Instance Variable tags_allowed List of tags for elements that are allowed.
Instance Variable tags_excluded List of tags for elements that are excluded.
Method _not_implemented Handler for not implemented elements.
def __init__(self, file_path: pathlib.Path): (source)

Initiate the document.

Parameters
file_path:pathlib.PathThe output file path.
def dataframe_to_table(self, df: pandas.DataFrame, caption: str, note: str, autofit: bool, decimal_places: int = 2): (source)

Convert table element into an excel table.

The currently active sheet is used. If there is no active sheet the default name Sheet 1 is used. The table is indented by one column per heading level.

Parameters
df:pandas.DataFrameThe table as pandas.DataFrame.
caption:strCaption string currently ignored.
note:str(Not implemented yet).
autofit:boolCurrently ignored.
decimal_places:intCurrently ignored.
def save(self, report: Report) -> _GenericDocumentOutput: (source)

Start converting all report elements to an Excel file.

The pandas.ExcelWriter with engine openpyxl is used.

Returns
_GenericDocumentOutputItself.
def string_to_heading(self, text: str, level: int): (source)

Add heading string into an excel file.

_current_heading_level = (source)

The current active heading level.

_xlsx_writer = (source)

Undocumented