Hi,
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'))

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

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

[/code]
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
response.write(workbook)
but its not the correct way.

Thanks.

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.