I am trying to generate an excel file on Django site so I searched for it and look at this example. I write simply a function that writes what I need into an Excel file;
def create_excel(personal_information):
output = StringIO.StringIO()
book = xlsxwriter.Workbook(output)
sheet = book.add_worksheet()
if personal_information['name']:
sheet.write(1, 1, personal_information['name'], text_format)
book.close()
output.seek(0)
return output
In my view.py;
def export(request):
personal_information = json.loads(request.POST.get('personal_data'))
output = create_excel(personal_information)
response = HttpResponse(output.read(), content_type="application/ms-excel")
response['Content-Disposition'] = 'attachment; filename=Excel.xls'
return response
However, that gave "None". Do you have any idea to solve my problem?
Thank you.