1

I have an excel file with 2 sheets, one is a dashboard kind with styles the other is a sheet with data. I've tried to load both like this


xls = pd.ExcelFile('template.xlsx')
dash = pd.read_excel(xls, 'Dashboard')
db = pd.read_excel(xls, 'db')

writer = pd.ExcelWriter('report.xlsx', engine="xlsxwriter")
dash.to_excel(witer, sheet_name='Dashboard', index=False)
df.to_excel(writer, sheet_name='db', index=False) # previous constructed dataframe
writer.save()

It works in the sense that formulas are preserved and such, but the styling vanishes. Is there a way to do this and preserve the styling?

EDIT:

D Stanley suggested that this [1][https://stackoverflow.com/questions/55229090/why-pandas-dataframe-style-lost-when-saved-with-to-excel] could answer but I'm trying to use a template as there are way to many formatting and styling to be done

waaat
  • 95
  • 2
  • 6
  • 1
    Does this answer your question? [why pandas dataframe style lost when saved with "to\_excel"?](https://stackoverflow.com/questions/55229090/why-pandas-dataframe-style-lost-when-saved-with-to-excel) – D Stanley Aug 05 '20 at 21:01
  • Not exactly , I'm using a template because there are a lot of styling and formatting – waaat Aug 05 '20 at 21:27

0 Answers0