问题描述
我们编写了代码将文件从 json 转换为 excel 格式,并返回 excel 文件,就好像我试图打开它损坏的文件一样。
我们已经尝试过 pandas 和 openpyxl 来转换 json。 以下是尝试检查一切是否正常的示例代码。
from flask import request,send_from_directory
df1 = pd.DataFrame([['a','b'],['c','d']],index=['row 1','row 2'],columns=['col 1','col 2'])
df1.to_excel('/tmp/output.xlsx')
return send_from_directory('/tmp/','output' + '.xlsx',as_attachment=True)```
Notes: The code has been deployed using kubernetes,we have copied the generated file from the volume and its looking good,while transferring its getting corrupted. And we have tried different content types as well.
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)