Good morning,
inside my application I'm trying to download multiple - id's are stored inside a list - excel-sheets together with openpyxl. For a single file I'm using this way:
qs = Data.objects.get(id=pk)
df = read_frame(qs)
...
wb = Workbook()
...
ws = wb.get_sheet_by_name('Example')
for row in dataframe_to_rows(df, index=False, header=False):
ws.append(row)
...
response = HttpResponse(content=save_virtual_workbook(wb), content_type='application/ms-excel')
response['Content-Disposition'] = f'attachment; filename={file_text}.xlsx'
return response
Of course a return inside a for-loop would break it, but is there any other way to accomplish this?
Thank you and have a great day!