0

I have a function that fetches data from a server and I have taken it in dictionary format. Now I want run that function in django shell and generate that file in my local drive. Here is my program to generate excel, it has HttpResponse which I don't need so what changes do I need to make?

def to_excel(excelStr, filename):  

""" To Generate Excel Sheets """

response = HttpResponse(excelStr, mimetype='application/vnd.ms-excel')
response['Content-Disposition'] = 'attachment; filename=%s.xls' \
    % str(filename)
return response

1 Answer 1

3
with open('%s.xls' % (filename,)) as f:
    f.write(excelStr)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.