Want to Stop Rebuilding "Expensive" Parts of your Flow? Explicit Builds are the Answer!READ MORE

Creating an excel output with multiple sheet

Solved!
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 Solution
AshleyW
Dataiker
Dataiker

Hi @Scobbyy2k3 ,

You might want to try the the Multisheet Excel export plugin which lets you take several different datasets and export them onto different tabs of a single Excel file.

Cheers,

Ashley W.

View solution in original post

0 Kudos
2 Replies
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
AshleyW
Dataiker
Dataiker

Hi @Scobbyy2k3 ,

You might want to try the the Multisheet Excel export plugin which lets you take several different datasets and export them onto different tabs of a single Excel file.

Cheers,

Ashley W.

0 Kudos