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









share|improve this question
























  • 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















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









share|improve this question
























  • 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













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









share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 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


















  • 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
















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

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















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






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














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





















































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







Popular posts from this blog

How to change which sound is reproduced for terminal bell?

Can I use Tabulator js library in my java Spring + Thymeleaf project?

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents