mirror of
https://github.com/jmcnamara/libxlsxwriter.git
synced 2026-10-05 06:10:24 -06:00
[GH-ISSUE #524] Embedded image's vm attribute uses the shared image ref id, so mixing image kinds writes an out-of-range metadata index #520
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#520
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/524
Originally assigned to: @jmcnamara on GitHub.
An embedded image's cell carries a
vmattribute indexing the<valueMetadata>blocks, of which there is one per embedded image. But_prepare_drawings()passes the shared image reference id, which also countsfloating, header and background images. In a workbook containing only embedded
images the two coincide and the file is correct; add any other image and
vmpoints past the end of the metadata. Excel reports "Repaired Records: Cell
information from /xl/worksheets/sheetN.xml" and the image is lost.
Cause
_prepare_drawings()(workbook.c:1137):and
worksheet_set_error_cell()(worksheet.c:11762) writes that straight intothe cell:
num_embedded_imagesis the countvmshould be based on;image_ref_idisnot.
Observed
One embedded image, nothing else — correct:
The same embedded image in a workbook that also holds four other images:
vm="4"against a single metadata block.The rich-value relationship is wrong in the same workbook for what looks like
the same reason — it targets the wrong picture:
image1.pngis 120x40 (a floating image); the embedded image isimage4.png,2x2.
Checked structurally across arrangements —
vmvalues againstvalueMetadata count:Reproducing
Sheet 2's cell gets
vm="2"whilexl/metadata.xmlhas<valueMetadata count="1">.Suggested fix
Pass the embedded-image index —
self->num_embedded_imagesafter theincrement — to
worksheet_set_error_cell()rather thanref_id, and record italongside the id in
embedded_image_md5sso a duplicate embedded image resolvesto the original's rich-value index rather than its image ref id.
Found while adding image support to writexl (R). Version 1.2.4.
@billdenney commented on GitHub (Jul 28, 2026):
BTW, sorry for all the noise here. I'm working to make
writexlimplement the entire surface oflibxlsxwriter, so I'm reporting what I find along the way. Hopefully this is helpful. For some of these that seem to have definitive solutions, I'll try to provide minimally-invasive PRs, too.@jmcnamara commented on GitHub (Jul 29, 2026):
@billdenney I am going to delete the previous interaction. You are doing your best. I am doing my best. Let's leave it at that. Keep posting the bugs/issues. My responses will be slow.
@jmcnamara commented on GitHub (Jul 29, 2026):
Thanks. I'll look into it.