2

Using xlwt I have created an Excel sheet that with Django I would like to email as an attachment.

response = HttpResponse(mimetype='application/ms-excel')
response['Content-Disposition'] = 'attachment; filename='Report.xls'

book = xlwt.Workbook()
sheet = book.add_sheet("Core Listings")

book.save(response)
return response

I am using Django EmailMessage to send out emails.

pnuts
  • 58,317
  • 11
  • 87
  • 139
NAGARJUNA PALURU
  • 109
  • 1
  • 1
  • 7

1 Answers1

0

You should be able to create a MimeBase object in memory from the spreadsheet data and attach that object in the attach method. The attach method takes the file triplet or a MimeBase object. See pydoc description about MimeBase and an example.