Unable to open worksheet

Nov 21, 2011 at 9:30 PM
I have been using the EPPlus library and really getting along great with it.  However, I have hit the following snag using a couple of Excel files.  When executing the code below.  I get the following error message.  I am lost on what to try to fix this?

FileInfo existingFile = new FileInfo(filePath);
using (ExcelPackage package = new ExcelPackage(existingFile))
// this line throws the error...
ExcelWorksheet sheet = package.Workbook.Worksheets["COVER"];


System.Exception was unhandled by user code  Message=Invalid Address format BTNINSTRUCTIONS_CLICK  Source=EPPlus  StackTrace:       at OfficeOpenXml.ExcelCellBase.GetRowCol(String address, Int32& row, Int32& col, Boolean throwException)       at OfficeOpenXml.ExcelCellBase.GetRowColFromAddress(String CellAddress, Int32& Row, Int32& Column)       at OfficeOpenXml.ExcelCellBase.GetRowColFromAddress(String CellAddress, Int32& FromRow, Int32& FromColumn, Int32& ToRow, Int32& ToColumn)       at OfficeOpenXml.ExcelAddressBase.SetAddress(String address)       at OfficeOpenXml.ExcelAddressBase..ctor(String address)       at OfficeOpenXml.ExcelAddress..ctor(String address)       at OfficeOpenXml.ExcelWorkbook.GetDefinedNames()       at OfficeOpenXml.ExcelPackage.get_Workbook()       at Consolidations20xx.Y34File.SheetExists(Int32 fileId, String sheetName) in C:\SourceControl\Consolidations20xx\Consolidations20xx\Classes\Y34File.cs:line 236       at Consolidations20xx.FileList.btnProcessFiles_Click(Object sender, EventArgs e) in C:\SourceControl\Consolidations20xx\Consolidations20xx\FileList.aspx.cs:line 62       at DevExpress.Web.ASPxEditors.ASPxButton.OnClick(EventArgs e)       at DevExpress.Web.ASPxEditors.ASPxButton.RaisePostBackEvent(String eventArgument)       at DevExpress.Web.ASPxClasses.ASPxWebControl.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)       at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)       at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)  InnerException: 
Nov 28, 2011 at 5:28 AM

Something in your template file causes the component to crash. Make sure you don't use any features not supported by EPPlus. Otherwise create an issue and upload your file, so I can have a look at it.

Nov 30, 2011 at 10:03 PM

Thanks.  I will upload the file for you to look at.  I appreciate your help as all my files are throwing this error.

Dec 6, 2011 at 1:57 PM

Please let me know if I can provide any more information on this.  I am really stuck here.  I have submitted an issue and uploaded my file.  Thank you very much for your time and help.

Dec 12, 2011 at 4:23 PM


I got the same issue with some random(?) files.

I am still not sure what the underlying cause is, but it "helps" as a work-around to save the Excel file in a different format, like OpenDocument Spreadsheet (ODS), then open that new file and save it back as an Excel workbook.




Feb 25, 2014 at 11:00 AM
i have same problem :( no solution