openpyxlを使用してExcelファイルを作成していますが、これはファイルのダウンロードとして戻したいので(ローカルには保存しません)。フラスコで作成したExcelファイルを返す
私は、Excelファイルをきれいに作成してディスクに保存できます。しかし、私はこのファイルをダウンロードすることができません。
試み1: WB = create_excel_sheet(データ)#戻りopenpyxlブック
output = excel.make_response(wb)
output.headers["Content-Disposition"] = "attachment; filename=" + \
'sheet.xlsx'
output.headers["Content-type"] = "application/vnd.openxmlformats-\
officedocument.spreadsheetml.sheet"
return output
:
import flask_excel as excel
...
create_excel_sheet(data) # internally save the sheet with name sheet.xlsx
output = excel.make_response()
output.headers["Content-Disposition"] = "attachment; filename=" + \
'sheet.xlsx'
output.headers["Content-type"] = "application/vnd.openxmlformats-\
officedocument.spreadsheetml.sheet"
return output
これは名前sheet.xlsx
試み2と空のテキストファイルを返します私は、空白のExcelシートを作成するためにopenpyxlが必要なので、データにpyexcelを使用したくありません。明らかにpyexcelとopenpyxlが通信していればそれは問題ありません。
どのような考えですか?
乾杯、私は同じ問題に直面したとき、私が何をしたかマイク
openpyxlは ' –
)あなたは(save_virtual_workbook'を持つオブジェクトのようなファイルに保存することができない
!おかげで – Mike