gpt4 book ai didi

python - “HttpResponse”对象没有属性 'seek'

转载 作者:行者123 更新时间:2023-12-01 00:48:06 29 4
gpt4 key购买 nike

我想从Excel中导出数据

我尝试下面的代码

def exel_all_attendance(request,course_id):
all_submit_attendance = SubmitedAttendance.objects.filter(course_id=course_id)

response = HttpResponse(content_type='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
response['Content-Disposition'] = 'attachment; filename=course.xlsx'
attendance_workbook = Workbook()
attendance_worksheet = attendance_workbook.active
attendance_worksheet.title = 'list_hozor_qiab'
columns = [att.submit_time for att in all_submit_attendance.all()]
row_num = 1
for col_num, column_title in enumerate(columns, 1):
cell = attendance_worksheet.cell(row=row_num, column=col_num)
cell.value = column_title
attendance_workbook.save(response)
return response

但我收到此错误

AttributeError: 'HttpResponse' object has no attribute 'seek'

我检查了错误在哪里?

attendance_workbook.save(response)

有什么解决办法吗?

最佳答案

好的

我解决了

替换

attendance_workbook.save(response)

response.content = save_virtual_workbook(attendance_workbook)

关于python - “HttpResponse”对象没有属性 'seek',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56786989/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com