You now have until September 15th to submit your use case or success story to the 2022 Dataiku Frontrunner Awards!ENTER YOUR SUBMISSION

Creating an excel output with multiple sheet

Scobbyy2k3
Level 3
Level 3
Creating an excel output with multiple sheet

I am trying to create and excel output with multiple sheet. This is what i've come up with so far.

 

with output.get_writer("Summary_File"+current_day+".xlsx") as writer:
        report_df.to_excel(writer, sheet_name='summary')
       cleaned_inbound_prepared_distinct_prepared_joined_df.to_excel(writer, sheet_name='Duplicates')
       distinct_biomakers_df.to_excel(writer, sheet_name='Biomakers')
      distinct_subjid_df.to_excel(writer, sheet_name='SubjectIDS')
      distinct_visits_df.to_excel(writer, sheet_name='Vists')
      all_df.to_excel(writer, sheet_name='numeric')
      less_than_df.to_excel(writer, sheet_name='non_numeric')


Operating system used: windows

0 Kudos
1 Reply
zeno_11
Level 3
sheet_names = ['1''2']
# First, save the data as excel format into a bytes string
stream = BytesIO()
excel_writer = pd.ExcelWriter(r"C:\Users\XXXX\Downloads\pythonCode\Multiple_Merged.xlsx"engine='xlsxwriter')
for i, df inenumerate (dataframes):
    df.to_excel(excel_writer, sheet_name=sheet_names[i],index=False)
    workbook  = excel_writer.book
    worksheet = excel_writer.sheets[sheet_names[i]]

more formatting

excel_writer.save()

# Rewind to the beginning of the bytes string
stream.seek(0)
0 Kudos