Skip to content
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

Throws KeyNotFoundException when getting the count of drawings. #1673

Open
robincodex opened this issue Nov 8, 2024 · 3 comments
Open

Throws KeyNotFoundException when getting the count of drawings. #1673

robincodex opened this issue Nov 8, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@robincodex
Copy link

EPPlus usage

Personal use

Environment

Windows

Epplus version

7.4.0

Spreadsheet application

Microsoft365 Excel

Description

This error appears after version 7.4.0, version 4.3.2 doesn't have this problem.

test.xlsx

This error occurs when sheet.Drawings.Count

System.Collections.Generic.KeyNotFoundException: The given key '' was not present in the dictionary.
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at OfficeOpenXml.Packaging.ZipPackageRelationshipCollection.get_Item(String id)
   at OfficeOpenXml.Packaging.ZipPackagePartBase.GetRelationship(String id)
   at OfficeOpenXml.Drawing.ExcelPicture..ctor(ExcelDrawings drawings, XmlNode node, ExcelGroupShape shape)
   at OfficeOpenXml.Drawing.ExcelDrawing.GetDrawingFromNode(ExcelDrawings drawings, XmlNode node, XmlElement drawNode, ExcelGroupShape parent)
   at OfficeOpenXml.Drawing.ExcelDrawing.GetDrawing(ExcelDrawings drawings, XmlNode node)
   at OfficeOpenXml.Drawing.ExcelDrawings.AddDrawings()
   at OfficeOpenXml.Drawing.ExcelDrawings..ctor(ExcelPackage xlPackage, ExcelWorksheet sheet)
   at OfficeOpenXml.ExcelWorksheet.LoadDrawings()
   at OfficeOpenXml.ExcelWorksheet.get_Drawings()
@robincodex robincodex added the bug Something isn't working label Nov 8, 2024
@swmal
Copy link
Contributor

swmal commented Nov 8, 2024

Thanks for reporting, we will have a look at this.

OssianEPPlus added a commit that referenced this issue Nov 21, 2024
@OssianEPPlus
Copy link
Contributor

That's because we only recently added support for Linked Images, before we did not check the "linked" property.
Your file has a Link attribute but it contained no value.
Drawings1.xml:
image

We have added a fix for this. It should be in Our NuGet Develop Feed within a few days.

Out of curiosity, how did you add your image/create your workbook?
Microsoft365 Excel does not generate xml that way when I attempt to.

@robincodex
Copy link
Author

That's because we only recently added support for Linked Images, before we did not check the "linked" property. Your file has a Link attribute but it contained no value. Drawings1.xml: image

We have added a fix for this. It should be in Our NuGet Develop Feed within a few days.

Out of curiosity, how did you add your image/create your workbook? Microsoft365 Excel does not generate xml that way when I attempt to.

This file was exported from Tencent Cloud Documents, similar to Google Docs, so it seems I shouldn't have given feedback on this issue, it's an error caused by Cloud Documents not adhering to standards.

Thank you for resolving this; I apologize for any inconvenience caused.

JanKallman pushed a commit that referenced this issue Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants