I am trying to write multiple sheets into one workbook and I'm using pyexcelerate to utilize it's optimized writing time.
Here's my current code to write to a workbook:
def df_to_excel(df, path, sheet_name='Sheet 1'):
data = [df.columns.tolist(), ] + df.values.tolist()
wb = Workbook()
wb.new_sheet(sheet_name, data=data)
wb.save(path)
now this works perfectly fine if i only need one sheet; however, if i write in multiple sheet, only the last sheet will be kept (all sheets generated before will be replaced).
I want to keep all the sheets (with diff names ofc), and I looked into their github page, but I cannot find info on such capability: https://github.com/kz26/PyExcelerate
I also looked into a few other stackoverflow posts but they are using different packages:
- Writing resutls into 2 different sheets in the same Excel file
- xlwt create dynamic number of worksheets based on input
- creating multiple excel worksheets using data in a pandas dataframe
any help is appreciated!