Dash允许下载Excel Linux ubuntu

问题描述 投票:0回答:1

我正在python上构建一个Dash应用程序,我希望用户在该应用程序中下载选定的数据以表现出色。我找到了一个代码示例来执行此操作,并且在Windows上运行良好。但是,当我在运行ubuntu 18.04的个人计算机上克隆该应用程序并运行该应用程序时,下载的文档不是xlsx而是压缩文件。我怎么能同时使用这两个代码?

        # Export to Excel the data filtered
        df_pivot = executive_filtered.pivot(index='period', columns='field', values=fluids)
        str_io = io.BytesIO()
        writer = pd.ExcelWriter(str_io,engine = 'openpyxl')
        df_pivot.to_excel(writer, sheet_name=f"data_{period}")
        writer.save()
        str_io.seek(0)
        media_type = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
        data = base64.b64encode(str_io.read()).decode("utf-8")
        href_data_downloadable = f'data:{media_type};base64,{data}'
python excel linux ubuntu hyphen
1个回答
0
投票

xlsxxlsm文件基本上是一个zip文件,其中包含一堆XML(和其他)文件。

© www.soinside.com 2019 - 2024. All rights reserved.