Reputation: 81
All, I have produced some summary statistic from a raw csv file. I have also saved this a summary in to a excel. I now need to make this report look pretty by formatting. I am aware of applying CSS style to data frame , but unable to export these formatting to excel. Alternatively , i have tried to use formatting feature in xlsxwriter to varying degree of success. Is there a way to format this dataframe once i have exported?
out.to_excel(writer, sheet_name='Dist-Market',startrow = 3 , startcol = 3)
def frmt_tbl(ws,rng):
ws.set_column(rng, 30)
Upvotes: 1
Views: 84
Reputation: 81
The below helped me , i think others might find it useful too .
https://xlsxwriter.readthedocs.io/working_with_pandas.html
# Add some cell formats.
format1 = workbook.add_format({'num_format': '#,##0.00'})
format2 = workbook.add_format({'num_format': '0%'})
# Set the column width and format.
worksheet.set_column('B:B', 18, format1)
# Set the format but not the column width.
worksheet.set_column('C:C', None, format2)
Upvotes: 1