I have a program which outputs a certain amount of dataframes to excel, one dataframe per one sheet in the excel workbook. I want to use header formatting for this, especially for the wrap text = true, because it is really annoying to expand like 30 cells on 15 sheets just to see the names.
For some reason, my header formatting seems to work, but it only works on cells that do not have any text/data in them. This, of course, is useless. Here is a screenshot of the output I get: screenshot
Here is the code I am using for this:
pandas.io.formats.excel.header_style = None
writer = pd.ExcelWriter('avad7.xlsx', engine='xlsxwriter')
workbook = writer.book
header_format = workbook.add_format({
'bold': True,
'text_wrap': True,
'valign': 'top',
'fg_color': '#D7E4BC',
'border': 1})
i = 0
for qw, x in ewm_pivot.groupby(ewm_pivot.isnull().dot(ewm_pivot.columns)):
# print(x.dropna(1))
x = x.dropna(1)
x.to_excel(writer, sheet_name='sheet' + str(i))
worksheet = writer.sheets['sheet' + str(i)]
worksheet.set_column('A:A', None, header_format)
worksheet.set_row(1, None, header_format)
i += 1
writer.save()
Any solutions would be appreciated :)