This project has moved and is read-only. For the latest updates, please go here.

Unreadable contents found after using xlPackage.Save()

Feb 19, 2013 at 7:19 PM
Edited Feb 20, 2013 at 12:33 AM
Here's the code I'm using, but keep on getting unreadable error when try to open the saved file with Excel 2010.
        FileInfo regFile = new FileInfo(@"mysample.xlsx");
        using (ExcelPackage xlPackage = new ExcelPackage(regFile)) 

            ExcelWorksheet allApp = xlPackage.Workbook.Worksheets[1];

            allApp.Cells[2, 1].Value = "1";



Everything works fine, and the sheet has been changed to what I want, just the above error came out when I open the excel file.
I believe is the way Epplus writes xml is different from what Excel expects? Can anyone help?
Feb 19, 2013 at 7:52 PM
Edited Feb 19, 2013 at 8:42 PM
Feb 19, 2013 at 8:45 PM
Edited Feb 19, 2013 at 8:51 PM
Worksheet\array numbering starts at zero - 0. So the first worksheet in referenced at [0] in the array of worksheets.

And when defining the ExcelPackage by default one file parameter is a new spreadsheet and the 2nd a template. For example:

ExcelPackage xlPackage = new ExcelPackage(@"d:\newspreadsheet.xlsx", @"d:\templatespreadsheet.xlsx");
Feb 20, 2013 at 12:31 AM
Well, the excel file mysample.xlsx and its spreadsheets are created by me manually. So actually there're several sheets and data in it already.
I just want to get access to one of the sheets and make some changes then save it.
After I did all these, I tried to open the excel with ms office 2010, and it gave me the unreadable contents error.
Feb 20, 2013 at 5:26 PM
If you could post as much code as possible I could try it and find the bugs.
Feb 23, 2013 at 9:44 AM
Well, actually above are all the codes I have been using. When I use Excel to open the file I have just changed by my web application, it told me there's some unreadable contents and asked me to repair them or not, if I click on yes, then it repair some .xml style files for the spreadsheets. The contents in the spreadsheets are what I expected, just cannot get rid of the unreadable contents error.
mysample.xlsx has three empty spreadsheets, and I just tried to write something into it.
Nothing else.
Just wondering no one has the similar problem? Is it because the version of my Excel? Or is it because of windows 8 system?
Feb 23, 2013 at 6:12 PM
Your operating system will have no affect at all on spreadsheets. If you create a Microsoft hotmail\outlook email account you will have access to Microsoft's web version of Excel which can you use for additional testing.