Creating an excel output with multiple sheet

Scobbyy2k3 Partner, Registered Posts: 26 Partner

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

Best Answer


  • zeno_11
    zeno_11 Registered Posts: 15 ✭✭✭✭
    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 =
    worksheet = excel_writer.sheets[sheet_names[i]]

    more formatting

    # Rewind to the beginning of the bytes string
Setup Info
      Help me…