提交 e0166ae2 编写于 作者: T tomtao 提交者: Gitee

使用with方式

上级 048520f6
......@@ -67,11 +67,13 @@ class DownloadFile(Resource):
"""
try:
bytes_io = io.BytesIO()
writer = pd.ExcelWriter( # pylint: disable=abstract-class-instantiated
bytes_io, engine='xlsxwrite')
data_frame.to_excel(writer, sheet_name='Summary', index=False)
writer.save()
writer.close()
with pd.ExcelWriter(bytes_io, engine='xlsxwriter') as writer:
data_frame.to_excel(writer, sheet_name='Summary', index=False)
# writer = pd.ExcelWriter( # pylint: disable=abstract-class-instantiated
# bytes_io, engine='xlsxwrite')
# data_frame.to_excel(writer, sheet_name='Summary', index=False)
# writer.save()
# writer.close()
bytes_io.seek(0)
_response = make_response(bytes_io.getvalue())
bytes_io.close()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册