Two things:
First, Ms Excel sucks. From that attached screenshot it's obvious that it
thought it was a space separated file. When actually using MS Office, I
recommend that you add `quoting=csv.QUOTE_ALL` to all csv writers.
Second, the HttpResponse object is file-like. You don't need to jump
>
> this might come of use, it exports any query set to csv. I use it a lot:
>
>
def queryset_export_csv(qs):
import csv
#from django.db.models.loading import get_model
response = HttpResponse(mimetype='text/csv')
# force download.
response['Content-Disposition'] =
'attachmen
I am guessing that your csv writer is outputting something that your
spreadsheet is reading incorrectly. Try opening the csv with a text editer
(a good one, like Notepad++) so that you can really see what is going on.
Embedded commas or quotes inside a field are invitations for disaster, and
>From just a quick glance, I have probably missed complex here - but one
option to try is changing the delimiter from a comma to another character
(e.g. a semi-colon) - see:
http://docs.python.org/2/library/csv.html#dialects-and-formatting-parameters
(But its also possible that in all the encodin
views.py
@login_requireddef export_csv(request):
user = request.user
# heading columns
headerrow = ['Filename', 'Description','Notes other','Reporter Name']
allrows = []
today = datetime.datetime.today() # default to show today
reports = Report.objects.filter(user=user)
5 matches
Mail list logo