I found this link and tried the example: how-to-save-a-new-sheet-in-an-existing-excel-file-using-pandas
It does not keep the previous sheets. Is there any way to keep the original sheets?
I found this link and tried the example: how-to-save-a-new-sheet-in-an-existing-excel-file-using-pandas
It does not keep the previous sheets. Is there any way to keep the original sheets?
You can use the append_df_to_excel()
helper function, which is defined in this answer.
NOTE: this function requires openpyxl
module
Usage examples:
append_df_to_excel('d:/temp/test.xlsx', df)
append_df_to_excel('d:/temp/test.xlsx', df, header=None, index=False)
append_df_to_excel('d:/temp/test.xlsx', df, sheet_name='Sheet2', index=False)
append_df_to_excel('d:/temp/test.xlsx', df, sheet_name='Sheet2', index=False, startrow=25)