'EPPlus worksheet System.Collections.Generic.KeyNotFoundException

I have a problem with one Excel and its worksheet. When I use basic code

using (var p =new ExcelPackage(new FileInfo(path))){
      int wN=p.Workbook.Worksheets.Count;
}

I get an error: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary. Also when I open the file in Excel the worksheet is there. This is a workbook.xml part of that .xlsx file.

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?><workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><fileVersion lastEdited="4" lowestEdited="4" rupBuild="4505" /><workbookPr defaultThemeVersion="123820" /><bookViews><workbookView xWindow="480" yWindow="15" windowWidth="15120" windowHeight="9285" /></bookViews><sheets><sheet name="Report Page" sheetId="1" r:id="rId1"/></sheets><calcPr calcId="122211" /><webPublishing codePage="1252" /></workbook>

I have no problem opening other .xlsx files and the file is on my disk so there are no network issues and so.

EDIT here is the error:

System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.

at System.ThrowHelper.ThrowKeyNotFoundException()
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at OfficeOpenXml.Packaging.ZipPackageRelationshipCollection.get_Item(String id)
at OfficeOpenXml.Packaging.ZipPackageRelationshipBase.GetRelationship(String id)
at OfficeOpenXml.ExcelWorksheet.LoadHyperLinks(XmlReader xr)
at OfficeOpenXml.ExcelWorksheet.CreateXml()
at OfficeOpenXml.ExcelWorksheet..ctor(XmlNamespaceManager ns, ExcelPackage excelPackage, String relID, Uri uriWorksheet, String sheetName, Int32 sheetID, Int32 positionID, eWorkSheetHidden hide)
at OfficeOpenXml.ExcelWorksheets..ctor(ExcelPackage pck, XmlNamespaceManager nsm, XmlNode topNode)
at OfficeOpenXml.ExcelWorkbook.get_Worksheets()
at Testing_process.CreateExcel.MainTest(String path, String worksheet, Int32 offset) in c:\Users\*******\CreateExcel.cs:line 36
at Testing_process.Program.Main(String[] args) in c:\Users\******\Program.cs:line 302


Solution 1:[1]

Open and save excel with office instead of other software.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 rj w