mirror of
https://github.com/jmcnamara/libxlsxwriter.git
synced 2026-10-23 08:07:32 -06:00
[GH-ISSUE #523] drawing_id counts sheets that produce no drawing, breaking later sheets' drawing relationships #522
Labels
No labels
awaiting user feedback
bug
cmake
cmake
docs
feature request
in progress
long term
medium term
medium term
pull-request
question
question
ready to close
short term
under investigation
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github-starred/libxlsxwriter#522
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @billdenney on GitHub (Jul 28, 2026).
Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/523
Originally assigned to: @jmcnamara on GitHub.
A worksheet whose only image is embedded, or is a header/footer image,
consumes a
drawing_idwithout producing adrawing<N>.xml. Every floatingimage on a later sheet then gets a relationship target one too high,
pointing at a part that does not exist. Excel opens the file, reports
"Removed Part: Drawing shape", and drops the image.
Cause
_prepare_drawings()(workbook.c:1106) increments the id for any sheet withany of five things:
but the packager numbers the drawing files counting only sheets that actually
have one —
_get_drawing_count()(packager.c:619):Embedded images and header/footer VML produce no
worksheet->drawing, so thetwo counters diverge from that sheet onward.
has_background_imagelookslike the same case, though I have not tested it.
Reproducing
Order is what matters — a drawing-less-but-counted sheet poisons every floating
image after it:
sheet2.xml.rels->drawing2.xml, which is absentsheet3.xml.rels->drawing3.xml, absentMinimal C:
xl/worksheets/_rels/sheet2.xml.relstargets../drawings/drawing2.xml, butonly
xl/drawings/drawing1.xmlexists.Substituting
worksheet_set_header_opt()with animage_leftfor the embeddedimage on sheet 1 reproduces it identically.
Comment VML is not affected:
_prepare_vml_objects()incrementsvml_drawing_idfor comment VML and header VML alike, and both produce a file,so that counter stays in step.
Suggested fix
Increment
drawing_idonly where a drawing part will be written — i.e. movethe increment to where
worksheet->drawingis created — or track a separatecounter for the relationship target.
Found while adding image support to writexl (R). Version 1.2.4.
@jmcnamara commented on GitHub (Jul 29, 2026):
Thanks. I'll look into it.