-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Open
Description
Issue: Grouped images are not preserved when reading and writing xlsx files
Environment
PhpSpreadsheet version: 5.2.0 (also affects earlier versions)
PHP version: 8.x
File format: .xlsx (Office Open XML)
Description
When loading an Excel file containing grouped images and saving it back, the images inside the group are lost.
Screenshot
test file
Xml file comparison
Xml debug
works :
<xdr:twoCellAnchor>
<xdr:pic>
<a:blip r:embed="rId1"/>
</xdr:pic>
</xdr:twoCellAnchor>
don't work :
<xdr:twoCellAnchor>
<xdr:grpSp> ← THE PROBLEM
<xdr:pic>
<a:blip r:embed="rId2"/>
</xdr:pic>
<xdr:pic>
<a:blip r:embed="rId3"/>
</xdr:pic>
</xdr:grpSp>
</xdr:twoCellAnchor>
What happens
1) Reader/Xlsx.php (~line 1489)
Parses <xdr:pic> elements directly under <xdr:twoCellAnchor>
Does NOT parse <xdr:pic> inside <xdr:grpSp>
Grouped images are never loaded into DrawingCollection
2) Writer/Xlsx/Drawing.php
Regenerates Drawing XML from DrawingCollection only
Grouped images are not in the collection
Result: Grouped images omitted from output
Workaround:
Manually ungroup all images before processing (not always possible)
Solutions :
Option 1: Full Group Support (complex)
Option 2: Append the unsupported xml elements (pass-through)
Metadata
Metadata
Assignees
Labels
No labels