title: Email xlsx attachment Django
body: <pre><code>def email_page(request):
      t = get_template('email.html')
      email = EmailMessage('Hello', 'Test&lt;br&gt;break', 'email@hotmail.com',['email@hotmail.com'])
      email.content_subtype = "html"
  
      workbook = xl.Workbook('ex.xlsx')
      worksheet = workbook.add_worksheet()
      worksheet.write(0, 0, 'Total')
      workbook.close()
      email.attach("ex.xlsx", workbook, 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
      email.send()
      return HttpResponse(t.render(Context({})), status=200)
  </code></pre>
  
  <blockquote>
    <p>I tried the following changes on the email.attach line:</p>
  </blockquote>
  
  <ul>
  <li><p>workbook.read() - read is not an attribute of workbook workbook.getvalue() </p></li>
  <li><p>workbook.getvalue() - getvalue is not an attribute of workbook</p></li>
  <li><p>workbook - TypeError: 'File' object does not support indexing</p></li>
  </ul>