You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

12 lines
538 B

# -*- coding: utf-8 -*-
from django.http import HttpResponse
def xls_to_response(content, filename=None, filename_encode='windows-1251'):
"""Выводит content в django.http.HttpResponse, который и возвращает."""
response = HttpResponse(content, mimetype='application/ms-excel')
if filename:
if filename_encode:
filename = filename.encode(filename_encode)
response['Content-Disposition'] = ('attachment; filename="%s"' % filename.replace('"', "''"))
return response