So, I used XLSXWriter in the past to export an excel file containing one tab filled with two pandas frames. Previously, I only exported the file to a local path on the user computer, but I am making the transition to the web interface.
My desired result should have the same excel file as the code below, but created in memory and sent to the user to download it via the web interface. I saw a lot of Django and StringIO, but I am looking for something that can work with Flask, and I could not find anything that really worked.
Is anyone familiar with this problem?
Thanks in advance!
xlsx_path = "C:\test.xlsx" writer = pd.ExcelWriter(xlsx_path, engine='xlsxwriter') df_1.to_excel(writer,startrow = 0, merge_cells = False, sheet_name = "Sheet_1") df_2.to_excel(writer,startrow = len(df_1) + 4, merge_cells = False , sheet_name = "Sheet_1") workbook = writer.book worksheet = writer.sheets["Sheet_1"] format = workbook.add_format() format.set_bg_color('#eeeeee') worksheet.set_column(0,9,28) writer.close()
source share