11👍
✅
pyExcelerator is unmaintained, but it has a fork, xlwt, which is maintained and has more features, including allowing you to save to any file-like object. This includes saving straight to a Django HttpResponse
:
from django.http import HttpResponse
import xlwt
def my_view(request):
response = HttpResponse(mimetype="application/ms-excel")
response['Content-Disposition'] = 'attachment; filename="foo.xls"'
wb = xlwt.Workbook()
wb.save(response)
return response
3👍
Why can you not use the tempfile
module?
How about:
import tempfile
fd, filename = tempfile.mkstemp()
fd.close()
workbook.save(filename)
- [Django]-Using Twisted for asynchronous file uploads from Django app
- [Django]-Editing models and extending database structure in Saleor
- [Django]-Subversion doesn't see my updates via python script
Source:stackexchange.com