I am trying to create xl file using pyExcelerator in django.

response = HttpResponse( mimetype='application/vnd.ms-excel')
response = 'attachment; filename=output.xls'
workbook = Workbook()
worksheet = workbook.add_sheet('My Test Sheet')

worksheet.write(0,0, 'Company', font_style('left', 1, 'red'))
worksheet.write(1,1, 'Hello World!', font_style('left', 1, 'black'))

return response
The problem here is I am not able to attach workbook to response.
Can someone help me out

Recommended Answers

All 2 Replies

When you post code please wrap it in code tags.
[code=python] # Your code here

If you want to attach another sheet to response you need to open response as the workbook. You're simply opening an arbitrary workbook here without reference to anything.

So how can I fix it?
Right now I am trying to do
but its not the correct way.


Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.