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

Exception thrown during Package.Save()

Jan 23, 2014 at 7:33 PM
Hi, I am currently running into an issue when I attempt to save my excel package.

Here's the stack trace:
EPPlus.dll!OfficeOpenXml.ExcelStyles.RemoveUnusedStyles()         Line 663  
EPPlus.dll!OfficeOpenXml.ExcelStyles.UpdateXml()                  Line 459  
EPPlus.dll!OfficeOpenXml.ExcelWorkbook.Save()                     Line 649  
EPPlus.dll!OfficeOpenXml.ExcelPackage.Save()                      Line 712  
Specifically it's happening on line 675
673         foreach (ExcelColumn col in sheet._columns)
674         {
675                 if(col.StyleID>=0) CellXfs[col.StyleID].useCnt++;
676         }
the conditional checks if StyleID is > 0 to be used as an index access into the CellXfs collection, but in this case CellXfs.Count is 11 and the StyleID being passed in is 20.

Any idea why this would be the case? Should there be a compound conditional or should StyleID never be larger than CellXfs.Count

I'm compiling from source at commit 13fc263b49bf