-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
exception on loading : An item with the same key has already been added. #1121
Comments
which version of NPOI are you using? And please show me the code to reproduce the issue. |
Can you share the code to reproduce the issue? |
A simple loading file will raise the exception. const string path = @"d:\whatever\optax_price_xiaomi_obnov_1707.2.xlsx";
var wb = new XSSFWorkbook(path); As for the file, there're duplicated entries in <Relationship Id="rId4" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="../media/image4.jpeg"/>
...
<Relationship Id="rId91" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="../media/image4.jpeg"/> I think it's because of image reuse (i.e. copy & paste inside Excel) as put in the cell of E10 & E133. I implemented a quick fix in if (targetMode == TargetMode.Internal)
{
var uriOriginalString = targetUri.OriginalString;
if (!internalRelationshipsByTargetName.ContainsKey(uriOriginalString))
{
internalRelationshipsByTargetName.Add(uriOriginalString, rel);
}
} p.s. I understand |
I notice this file is generated by LibreOffice. I resave the file with Microsoft Office and I don't see a duplicate key anymore Here is the drawing1.xml.rels from the MIcrosoft Office resaved file. In this case, I don't think it is a bug. The file provided is not well-generated. |
This file I get for a supplier via loading from a website url. |
I suppose that NPOI should have a policy on whether to fix issues relating to malformed but Excel-readable files. The answer is probably yes. |
Fair enough. I'll fix this issue and see if we can suppress the exception without breaking anything |
wow, many thanks! you are the best! |
Hello
Got some issue with the next file:
optax_price_xiaomi_obnov_1707 (2).xlsx
any way how to "try catch" such an error and to read this file till the end?
The text was updated successfully, but these errors were encountered: