1

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?

table

out.to_excel(writer, sheet_name='Dist-Market',startrow = 3 , startcol = 3)
def frmt_tbl(ws,rng):
    ws.set_column(rng, 30)
1

1 Answer 1

1

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)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.