Skip to content

Commit

Permalink
Fix for csv generation encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
AMongeMoreno committed Mar 3, 2016
1 parent 82927d7 commit 5f29f46
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions report_utils/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
ReverseManyRelatedObjectsDescriptor as ManyToManyDescriptor
)
from django.db.models import Avg, Count, Sum, Max, Min
from django.utils.encoding import smart_str
from openpyxl.workbook import Workbook
from openpyxl.writer.excel import save_virtual_workbook
from openpyxl.cell import get_column_letter
Expand Down Expand Up @@ -95,7 +96,7 @@ def build_csv_response(self, wb, title="report"):
sh = wb.get_active_sheet()
c = csv.writer(myfile)
for r in sh.rows:
c.writerow([cell.value for cell in r])
c.writerow([smart_str(cell.value) for cell in r])
response = HttpResponse(
myfile.getvalue(),
content_type='text/csv')
Expand Down Expand Up @@ -145,7 +146,7 @@ def list_to_csv_file(self, data, title='report', header=None, widths=None):
sh = wb.get_active_sheet()
c = csv.writer(myfile)
for r in sh.rows:
c.writerow([cell.value for cell in r])
c.writerow([smart_str(cell.value) for cell in r])
return myfile

def list_to_xlsx_response(self, data, title='report', header=None,
Expand Down

0 comments on commit 5f29f46

Please sign in to comment.