larray.ExcelReport.to_excel¶
-
ExcelReport.
to_excel
(self, filepath, data_sheet_name='__data__', overwrite=True)[source]¶ Generate the report Excel file.
- Parameters
- filepathstr
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.
Examples
>>> demo = load_example_data('demography_eurostat') >>> report = ExcelReport(EXAMPLE_EXCEL_TEMPLATES_DIR) >>> report.template = 'Line_Marker'
>>> for c in demo.country: ... 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')
Check if ouput file already exists
>>> report.to_excel('Demography_Report.xlsx', overwrite=False) Traceback (most recent call last): ... ValueError: Sheet named 'Belgium' already present in workbook