mpl_bsic.style_excel_file#
- mpl_bsic.style_excel_file(path_to_excel, sheet_name, title, offset=(1, 1))[source]#
Format an already existing Excel file.
The function will create a new file, with the same name as the source file and the suffix “_fmt”, in the same directory. It retrieves data and format it according to the BSIC Styling standards.
The function will also add a title (optional) at the very top of the table and a row containing “Source: BSIC” at the very bottom, leaving a blank row (with reduced height) in between for better aesthetics.
- Parameters:
- path_to_excel
str
The path to the Excel file.
- sheet_name
str
The name of the worksheet containing the data to be formatted.
- title
Optional
[str
] The title to be given to the data. It will be displayed above the table, in the same style as the BSIC Headings.
- offset
tuple
[int
,int
], optional The offset to use in the formatted output, by default
(1, 1)
. For example, if offset is set to(1,2)
, the formatter will leave 2 empty rows and 1 empty column for better visualization.
- path_to_excel
Warning
The source Excel file must only contain the headings, the index and the data, with no blank columns or rows in between them. The table has to start at row 0, col 0.
See also
mpl_bsic.df_to_excel
Exports a pandas DataFrame to an Excel file. Use if your data is in a DataFrame rather than on a spreadsheet.
Examples
from mpl_bsic import style_excel_file style_excel_file( "excel_file_path", "worksheet_name", "Title of the Table", (2,2) # if you want the table to have an offset )