Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Word can not open docx due to incorrect serialization for CT_Point2D when used in CT_Anchor for CT_Drawing #1498

Open
1 of 5 tasks
paulhahn-rapiddata opened this issue Feb 27, 2025 · 1 comment

Comments

@paulhahn-rapiddata
Copy link

paulhahn-rapiddata commented Feb 27, 2025

NPOI Version

2.7.2

File Type

  • XLSX
  • XLS
  • DOCX
  • XLSM
  • OTHER

Reproduce Steps

  1. Add drawing to your document
  2. anchor the drawing
  3. Set CT_Anchor.simplePos to an instance of CT_Point2D

This will create a tag:
<a:simplePos x="0" y="0" />
as child of the anchor tag.

Issue Description

The modified document can not be opened by word. If manually editing the tag to this:
<wp:simplePos x="0" y="0" />
word will be able to open and display the document.

I assume that this a tag should be a wp tag instead, but i am not a docx expert.
Here is the NPOI code line that would need the change from a to wp:

sw.Write(string.Format("<a:{0}", nodeName));

I tried to circumvent the issue by setting simplePos to null, which generates the anchor without the tag. However, this will also not be accepted by word.

This means that effectively it is not possible to anchor a drawing with NPOI, potentially other elements as well.

@tonyqus
Copy link
Member

tonyqus commented Feb 27, 2025

Can you create a PR for this?

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants