EPPlus worksheet System.Collections.Generic.KeyNotFoundException
up vote
0
down vote
favorite
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
excel epplus worksheet
|
show 1 more comment
up vote
0
down vote
favorite
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
excel epplus worksheet
are you sure that path is pointing to the correct path?
– Yahya Hussein
Nov 13 at 9:48
I edited my question
– Richard
Nov 13 at 12:16
What is the line that throws the exception? Is it a file format readable by epplus? i.e. is it xlsx?
– shahkalpesh
Nov 13 at 12:45
the line withint
throws exception and yes the file is readable, when I open the file and rename the sheet it works normally for example
– Richard
Nov 13 at 13:11
Please paste the stacktrace because I cant relate the exception to the line of code.
– shahkalpesh
Nov 13 at 13:52
|
show 1 more comment
up vote
0
down vote
favorite
up vote
0
down vote
favorite
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
excel epplus worksheet
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
excel epplus worksheet
excel epplus worksheet
edited Nov 14 at 8:52
asked Nov 13 at 9:45
Richard
63
63
are you sure that path is pointing to the correct path?
– Yahya Hussein
Nov 13 at 9:48
I edited my question
– Richard
Nov 13 at 12:16
What is the line that throws the exception? Is it a file format readable by epplus? i.e. is it xlsx?
– shahkalpesh
Nov 13 at 12:45
the line withint
throws exception and yes the file is readable, when I open the file and rename the sheet it works normally for example
– Richard
Nov 13 at 13:11
Please paste the stacktrace because I cant relate the exception to the line of code.
– shahkalpesh
Nov 13 at 13:52
|
show 1 more comment
are you sure that path is pointing to the correct path?
– Yahya Hussein
Nov 13 at 9:48
I edited my question
– Richard
Nov 13 at 12:16
What is the line that throws the exception? Is it a file format readable by epplus? i.e. is it xlsx?
– shahkalpesh
Nov 13 at 12:45
the line withint
throws exception and yes the file is readable, when I open the file and rename the sheet it works normally for example
– Richard
Nov 13 at 13:11
Please paste the stacktrace because I cant relate the exception to the line of code.
– shahkalpesh
Nov 13 at 13:52
are you sure that path is pointing to the correct path?
– Yahya Hussein
Nov 13 at 9:48
are you sure that path is pointing to the correct path?
– Yahya Hussein
Nov 13 at 9:48
I edited my question
– Richard
Nov 13 at 12:16
I edited my question
– Richard
Nov 13 at 12:16
What is the line that throws the exception? Is it a file format readable by epplus? i.e. is it xlsx?
– shahkalpesh
Nov 13 at 12:45
What is the line that throws the exception? Is it a file format readable by epplus? i.e. is it xlsx?
– shahkalpesh
Nov 13 at 12:45
the line with
int
throws exception and yes the file is readable, when I open the file and rename the sheet it works normally for example– Richard
Nov 13 at 13:11
the line with
int
throws exception and yes the file is readable, when I open the file and rename the sheet it works normally for example– Richard
Nov 13 at 13:11
Please paste the stacktrace because I cant relate the exception to the line of code.
– shahkalpesh
Nov 13 at 13:52
Please paste the stacktrace because I cant relate the exception to the line of code.
– shahkalpesh
Nov 13 at 13:52
|
show 1 more comment
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53278101%2fepplus-worksheet-system-collections-generic-keynotfoundexception%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
are you sure that path is pointing to the correct path?
– Yahya Hussein
Nov 13 at 9:48
I edited my question
– Richard
Nov 13 at 12:16
What is the line that throws the exception? Is it a file format readable by epplus? i.e. is it xlsx?
– shahkalpesh
Nov 13 at 12:45
the line with
int
throws exception and yes the file is readable, when I open the file and rename the sheet it works normally for example– Richard
Nov 13 at 13:11
Please paste the stacktrace because I cant relate the exception to the line of code.
– shahkalpesh
Nov 13 at 13:52