Skip to content
This repository has been archived by the owner on Mar 9, 2020. It is now read-only.

Adding pivot table results in corrupt xlsx when constructing ExcelPackage with existing office 2016 file #25

Closed
JasperE84 opened this issue Oct 7, 2017 · 1 comment

Comments

@JasperE84
Copy link

JasperE84 commented Oct 7, 2017

Hi there,
I noticed EPPlus creates corrupt excel files when starting from an existing Excel template.

Steps to reproduce

  • Install latest office 365 (office 2016)

  • I am using: 1705 (Build 8201.2193 CLick-to-Run) / Deferred Channel

  • Create folder c:\temp

  • Right click in windows explorer in c:\temp empty space, New file -> Microsoft Excel file

  • Name file "template.xlsx"
    Here is the blank file I then get:
    template.xlsx

  • Modify Sample12.cs as following:

string fileInput = @"c:\temp\template.xlsx";
string fileOutput = @"c:\temp\output.xlsx";
File.Copy(fileInput, fileOutput);
FileInfo newFile = new FileInfo(fileOutput);
using (ExcelPackage pck = new ExcelPackage(newFile))
{
<snip>
pck.Save();
}
return fileOutput;
  • Run sample application

  • Try to open c:\temp\output.xlsx

  • Excel will say file is corrupted
    Here is the corrupt file I'm getting
    output.xlsx

Workaround:

  • Take Sample12.xlsx from the default sample app without modifications
  • Copy the worksheets from your Excel 2016 template to the Sample12.xlsx file
  • Save using Excel
  • Use that as your new template
@JanKallman
Copy link
Owner

This is fixed in 4.5.1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants