I\'m building OpenPyXL into an application that expects a string containing the content of the excel file, for it to write via file stream.
From my investigation into th
from openpyxl import Workbook
from io import BytesIO
rows = [[1,2], [3,4]]
book = Workbook()
sheet = book.active
for row in rows:
sheet.append(row)
io = BytesIO
book.save(io)
content = io.getValue()
return Response(
content,
mimetype=magic.from_buffer(content, mime=True),
headers={
'Content-Disposition': 'attachment;filename=' + 'test.xlsx'}
)