class documentation
class XlsxDocument(_GenericDocumentOutput): (source)
Constructor: XlsxDocument(file_path)
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 |
Convert table element into an excel table. |
Method | save |
Start converting all report elements to an Excel file. |
Method | string |
Add heading string into an excel file. |
Instance Variable | _current |
The current active heading level. |
Instance Variable | _xlsx |
Undocumented |
Inherited from _GenericDocumentOutput
:
Method | show |
Open the generated document with the file type associated application. |
Instance Variable | file |
Path to the file. |
Instance Variable | tags |
List of tags for elements that are allowed. |
Instance Variable | tags |
List of tags for elements that are excluded. |
Method | _not |
Handler for not implemented elements. |
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.DataFrame | The table as pandas.DataFrame . |
caption:str | Caption string currently ignored. |
note:str | (Not implemented yet). |
autofit:bool | Currently ignored. |
decimalint | Currently ignored. |
Start converting all report elements to an Excel file.
The pandas.ExcelWriter
with engine openpyxl
is used.
Returns | |
_GenericDocumentOutput | Itself. |