Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def write_status_to_excel(self, request, queryset):
- from openpyxl import Workbook
- #create workbook
- #.....
- module_dir=os.path.dirname(__file__)
- dname=r'testfile.xlsx'
- file_path=os.path.join(module_dir,dname)
- workbook.save(filename = file_path)
- f = open(file_path, 'r')
- response = HttpResponse(f, content_type='application/vnd.ms-excel')
- #response = HttpResponse(f, content_type='text/csv') #tried this too
- response['Content-Disposition'] = 'attachment; filename=%s' % os.path.split(file_path)[-1]
- return response
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement