I am using xlsxwriter engine to push some dataframes into excel sheet with pandas.to_excel(), but I need a caption above each table.
Here is an example of what result I would like to achieve:
I did not see any way to use ExcelWriter object of pandas to simply manipulate content of each cell and when I try to do it, I get:
Exception: Sheetname 'sample', with case ignored, is already in use.
I guess xlsxwriter locks it for itself. Here is an example:
xlsx_writer = pd.ExcelWriter(
get_target_filepath(xlsx_name),
engine='xlsxwriter'
)
workbook = xlsx_writer.book
worksheet = workbook.add_worksheet(sheet_name)
worksheet.write(1, 1, 'ABC')
_, sample_table = dataframe_tuples[0]
sample_table.to_excel(xlsx_writer, startrow=3, startcol=2, sheet_name=sheet_name)
I could save dataframes and go over it again with openpyxl, but I seriously dislike the way they do formatting, which I have to do next, and if I format it in xlsxwriter and then reopen it with openpyxl, it cannot save the formatting back properly, openpyxl ruins it.
I can not put excel itself onto server to use VBA macros for styling.
Is there any way around this or am I just doing something horribly wrong?