Snippet List
A function extends of Tarken's django-excel-response
django-excel-response
1、djangosnippets - http://djangosnippets.org/snippets/1151/
2、pypi - https://pypi.python.org/pypi/django-excel-response/1.0
When using Tarken's django-excel-response. We find that
Chinese is messed code when we open .xls in Mac OS.
As discussed in http://segmentfault.com/q/1010000000095546.
We realize django-excel-response2
Based on Tarken's django-excel-response to solve this problem
By adding a Param named font to set font.
- output
- httpresponse
- excel
- cvs
When you neeed to do redirect and request object is not available, you can do it with exception.
Put exception handler somewhere request is available, for example to middleware or ModelAdmin.
Raise exception, where request is not available.
- http
- request
- redirect
- reverse
- httpresponse
A subclass of `HttpResponse` which will transform a `QuerySet`, or sequence of sequences, into either an Excel spreadsheet or CSV file formatted for Excel, depending on the amount of data. All of this is done in-memory and on-the-fly, with no disk writes, thanks to the StringIO library.
**Requires:** [xlwt](http://pypi.python.org/pypi/xlwt/)
**Example:**
def excelview(request):
objs = SomeModel.objects.all()
return ExcelResponse(objs)
- csv
- output
- httpresponse
- excel
4 snippets posted so far.