title: EPPlus - saved file corrupted when using template
body: <p>I'm evaluating EPPlus as a replacement for GemBox, but can't even save a valid Excel file. I have this minimal C# code:</p>
  
  <p>In library:</p>
  
  <pre><code>public Stream GenerateReport(string templateFilePath)
  {
      using (var xls = new OfficeOpenXml.ExcelPackage(new FileInfo(templateFilePath), true))
      {
        var stream = new MemoryStream();
        xls.SaveAs(stream);
        stream.Position = 0;
        return stream;
      }
  }
  </code></pre>
  
  <p>In controller:</p>
  
  <pre><code>return File(GenerateReport("filename.xltx"), "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "filename.xlsx");
  </code></pre>
  
  <p>The file is created and saved succesfully but when I open it with Excel I get the error:</p>
  
  <blockquote>
    <p>"We found a problem with some content in 'filename.xlsx'. Do you want
    to try to recover as much as we can?".</p>
  </blockquote>
  
  <p>I answer Yes and get: </p>
  
  <blockquote>
    <p>"The workbook cannot be opened or repaired by Microsoft Excel because
    it is corrupt".</p>
  </blockquote>
  
  <p>I have verified that the template file is in the correct format and none of the other suggested solutions here on stackoverflow fixes the problem.</p>
  
  <p>Any suggestions?</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>I also tried without using a template and that works without problem:</p>
  
  <pre><code>using (var xls = new OfficeOpenXml.ExcelPackage())
  {
     xls.Workbook.Worksheets.Add("New");
     var stream = new MemoryStream();
     xls.SaveAs(stream);
     stream.Position = 0;
     return stream;
  }
  </code></pre>
  
  <p><strong>UPDATE 2:</strong></p>
  
  <p>Saving the .xltx template as a .xlsx and using the .xlsx as the template does not raise any errors when opened.</p>