ExcelReport.to_excel(self, filepath, data_sheet_name='__data__', overwrite=True)[source]

Generate the report Excel file.


Path of the report file for the dump.

data_sheet_namestr, optional

name of the Excel sheet where all data associated with items is dumped. Defaults to ‘__data__’.

overwritebool, optional

whether or not to overwrite an existing report file. Defaults to True.


>>> demo = load_example_data('demo')
>>> report = ExcelReport(EXAMPLE_EXCEL_TEMPLATES_DIR)
>>> report.template = 'Line_Marker'
>>> for c in
...     sheet_country = report.new_sheet(c)
...     sheet_country.add_graph(demo.pop[c], 'Population')
...     sheet_country.add_graph(demo.births[c], 'Births')
...     sheet_country.add_graph(demo.deaths[c], 'Deaths')

Basic usage

>>> report.to_excel('Demography_Report.xlsx')

Alternative data sheet name

>>> report.to_excel('Demography_Report.xlsx', data_sheet_name='Data Tables') # doctest: +SKIP

Check if ouput file already exists

>>> report.to_excel('Demography_Report.xlsx', overwrite=False) # doctest: +SKIP
Traceback (most recent call last):
ValueError: Sheet named 'Belgium' already present in workbook