penambahan xls response

1 parent b72604fd
......@@ -254,6 +254,21 @@ def csv_response(request, value, filename=None):
return response
def xls_response(request, value, filename=None):
if not filename:
filename = get_random_string(20)+".xls"
response = request.response
response.content_type = 'application/xls'
response.content_disposition = 'filename=' + filename
from pandas import DataFrame
df = DataFrame(value.get('rows', []), columns=value.get('header', []))
df.to_excel(filename, index=False)
with open(filename, 'rb') as f:
response.write(f.read())
return response
def terbilang(bil):
angka = ["", "Satu", "Dua", "Tiga", "Empat", "Lima", "Enam",
"Tujuh", "Delapan", "Sembilan", "Sepuluh", "Sebelas"]
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!