SOS, need help!
i have this button:
html.A(
html.Button('Š”ŠŗŠ°ŃŠ°ŃŃ'),
id='excel-download',
download="data.xlsx",
href='',
target="_blank"
)
and a callback:
@app.callback(Output('excel-download', 'href'),
[Input('start_revise', 'n_clicks')],
[State('loading-states-table', 'data'), State('offer', 'value'),
State('goal', 'value'), State('subid-col', 'value'), State('tid-col', 'value'),
State('select_id', 'value')])
def download_some_excel(click, df, offer_id, goal_id, subid_col, tid_col, id_for_load):
return file_download(df, subid_col, offer_id, goal_id, id_for_load)
and a file download function:
def file_download(df, id_col, offer_id, goal_id, id_for_load):
adv_data = pd.DataFrame(df)
...some other genius code...
xlsx_io = io.BytesIO()
excel_writer = pd.ExcelWriter(xlsx_io, engine='xlsxwriter')
if some statement:
some_df.to_excel(excel_writer, sheet_name="ŠŃŠ±Š»Šø Š² ŃŃŠ°ŃŠµ Š»ŠøŠ“Š³ŠøŠ“Š°", index=False)
if another statement:
some_df.to_excel(excel_writer, sheet_name="other_sheet_name", index=False)
excel_writer.save()
xlsx_io.seek(0)
# https://en.wikipedia.org/wiki/Data_URI_scheme
media_type = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
data = base64.b64encode(xlsx_io.read()).decode("utf-8")
href_data_downloadable = f'data:{media_type};base64,{data}'
return href_data_downloadable
and everything worked fine, until it has become necessary to download a big file, around 40k rows with 3-4 sheets. In results it gave me just an empty file (0 bytes):
Does anyone knows, what to do? I need this ādownload fileā option.