1

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?

Community
  • 1
  • 1
user3776800
  • 57
  • 1
  • 7

1 Answers1

1

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)
MaxU - stand with Ukraine
  • 205,989
  • 36
  • 386
  • 419