Guest User

Untitled

a guest
Jul 16th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. def exportexcel(request):
  2. from xlwt import Workbook
  3.  
  4. wb = Workbook()
  5. ws = wb.add_sheet('Sheetname')
  6. ws.write(0, 0, 'Firstname')
  7. ws.write(0, 1, 'Surname')
  8. ws.write(1, 0, 'Hans')
  9. ws.write(1, 1, 'Muster')
  10.  
  11. fname = 'testfile.xls'
  12. response = HttpResponse(mimetype="application/ms-excel")
  13. response['Content-Disposition'] = 'attachment; filename=%s' % fname
  14.  
  15. wb.save(response)
  16.  
  17. return response
Add Comment
Please, Sign In to add comment