python - Python,openpyxl:下载多个 excel 表
问题描述
早上好,
在我的应用程序中,我试图下载多个 - id 存储在一个列表中 - excel-sheets 与 openpyxl 一起。对于我使用这种方式的单个文件:
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
当然,for 循环中的return会破坏它,但是还有其他方法可以实现这一点吗?
谢谢你,祝你有美好的一天!
解决方案
推荐阅读
- swift - 在 Swift 中比较日期忽略当前时区
- java - org.apache.http.ContentTooLongException:实体内容太长 [105539255] 对于配置的缓冲区限制 [104857600]
- javascript - 如何删除从数组中选择的元素
- php - 如何显示我的 html 邮件?
- ios - 找到不支持的类型 - AVMetadataObject
- oracle - 从 query.getResultList 检索类时出现 Hibernate ClassCastException
- javascript - 通过 AJAX 将复选框 id 发布到 php
- ios - 在表视图之外传递和访问对象数据
- asp.net - 我想在 asp.net webforms 项目中进行时间同步
- java - 如何在 Java 中将 LocalDate 列表添加到 myList