title: downloading excelize xlsx file is corrupt
body: <p>I'm using <a href="http://github.com/360EntSecGroup-Skylar/excelize" rel="nofollow noreferrer" title="Excelize">Excelize</a> library for generating xlsx documents. When I use It's <code>Write(io.writer)</code> func for saving xlsx to file, it works perfectly. But I need to generate and serve this file at web-server. I was trying this solution </p>
  
  <pre><code>func GetConsolidatedReport(w http.ResponseWriter, r *http.Request) {
      var reportFile *excelize.File
  
      ...
  
      var b bytes.Buffer
      writr := bufio.NewWriter(&amp;b)
      reportFile.SaveAs("/tmp/testfile.xlsx")
      reportFile.Write(writr)
      writr.Flush()
  
      fileContents := b.Bytes()
      fileSize := strconv.Itoa(len(fileContents))
  
      w.Header().Set("Content-Disposition", "attachment; filename=report.xlsx")
      w.Header().Set("Content-Type", "application/octet-stream")
      w.Header().Set("Content-Length", fileSize)
  
      t := bytes.NewReader(b.Bytes())
      io.Copy(w, t)
  }
  </code></pre>
  
  <p>and after that i've got corrupted zip-file from web-server, but normal file saved in "/tmp/testfile.xlsx"</p>
  
  <p>I've tried content-type as <code>application/zip</code>, <code>application/octet-stream</code>, <code>application/vnd.*</code> but no luck.</p>
  
  <p>Can you help me? Thank you in advance.</p>
  
  <p>PS: By serving i mean on-the-fly generation of file, sorry for any misunderstanding.</p>
  
  <p>PS2: It seems I get an overhead of downloaded file (8085 bytes of original and 13000+ of downloaded) and I can't figure it out where this overhead is come in.</p>