Snippet List
Hyperlinks to views requiring authentication in Microsoft Office (Word, Excel, Powerpoint) can fail based on how Office handles rendering. This middleware sends a refresh return to the client, which will allow the page to be opened as normal, instead of the "Unable to open ... Cannot download the information you requested."
This is a port from the ruby middleware project [fix microsoft links](https://github.com/spilliton/fix_microsoft_links).
To enable, add to your [middleware stack](https://docs.djangoproject.com/en/dev/topics/http/middleware/) in the django project settings.
- middleware
- office
- word
- excel
- powerpoint
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
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
Exporting unicode data to Excel in a CSV file is surprisingly difficult. After much experimentation, it turns out the magic combination is UTF-16, a byte order mark and tab-delimiters. This snippet provides two classes - UnicodeWriter and UnicodeDictWriter - which can be used to output Excel-compatible CSV.
6 snippets posted so far.