Skip to content

Commit fd3252b

Browse files
committed
Add tests
1 parent f34facf commit fd3252b

File tree

4 files changed

+316
-46
lines changed

4 files changed

+316
-46
lines changed

src/PhpSpreadsheet/Reader/Xlsx.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1714,10 +1714,6 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet
17141714
}
17151715
}
17161716
}
1717-
if (empty($relsDrawing) && $xmlDrawing->count() == 0) {
1718-
// Save Drawing without rels and children as unparsed
1719-
$unparsedDrawings[$drawingRelId] = $xmlDrawing->asXML();
1720-
}
17211717
}
17221718

17231719
// store original rId of drawing files

src/PhpSpreadsheet/Writer/Xlsx/Drawing.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -599,15 +599,13 @@ private static function writeAttributeIf(XMLWriter $objWriter, ?bool $condition,
599599
}
600600

601601
/**
602-
* Get pass-through drawing XML if available and no drawings have been modified.
602+
* Get pass-through drawing XML if available.
603+
*
604+
* Returns the original drawing XML stored during load (when Reader pass-through was enabled).
605+
* This preserves unsupported drawing elements (shapes, textboxes) that PhpSpreadsheet cannot parse.
603606
*/
604607
private function getPassThroughDrawingXml(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $worksheet): ?string
605608
{
606-
// Only use pass-through if no drawings have been added/modified programmatically
607-
if (count($worksheet->getDrawingCollection()) !== 0) {
608-
return null;
609-
}
610-
611609
$unparsedLoadedData = $worksheet->getParentOrThrow()->getUnparsedLoadedData();
612610
if (!isset($unparsedLoadedData['sheets']) || !is_array($unparsedLoadedData['sheets'])) {
613611
return null;

0 commit comments

Comments
 (0)