@@ -784,6 +784,19 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet
784784
785785 $ charts = $ chartDetails = [];
786786
787+ // Add richData (contains relation of in-cell images)
788+ $ richData = [];
789+ $ relationsFileName = $ dir . '/richData/_rels/richValueRel.xml.rels ' ;
790+ if ($ zip ->locateName ($ relationsFileName )) {
791+ $ relsWorksheet = $ this ->loadZip ($ relationsFileName , Namespaces::RELATIONSHIPS );
792+ foreach ($ relsWorksheet ->Relationship as $ elex ) {
793+ $ ele = self ::getAttributes ($ elex );
794+ if ($ ele ['Type ' ] == Namespaces::IMAGE ) {
795+ $ richData ['image ' ][(string ) $ ele ['Id ' ]] = (string ) $ ele ['Target ' ];
796+ }
797+ }
798+ }
799+
787800 $ sheetCreated = false ;
788801 if ($ xmlWorkbookNS ->sheets ) {
789802 foreach ($ xmlWorkbookNS ->sheets ->sheet as $ eleSheet ) {
@@ -940,6 +953,28 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet
940953
941954 break ;
942955 case DataType::TYPE_ERROR :
956+ if (isset ($ cAttr ->vm , $ richData ['image ' ]['rId ' . $ cAttr ->vm ]) && !$ useFormula ) {
957+ $ imagePath = $ dir . '/ ' . str_replace ('../ ' , '' , $ richData ['image ' ]['rId ' . $ cAttr ->vm ]);
958+ $ objDrawing = new \PhpOffice \PhpSpreadsheet \Worksheet \Drawing ();
959+ $ objDrawing ->setPath (
960+ 'zip:// ' . File::realpath ($ filename ) . '# ' . $ imagePath ,
961+ false ,
962+ $ zip
963+ );
964+
965+ $ objDrawing ->setCoordinates ($ r );
966+ $ objDrawing ->setOffsetX (0 );
967+ $ objDrawing ->setOffsetY (0 );
968+ $ objDrawing ->setResizeProportional (false );
969+ $ objDrawing ->setWorksheet ($ docSheet );
970+
971+ $ value = $ objDrawing ;
972+ $ cellDataType = DataType::TYPE_NULL ;
973+ $ c ->t = DataType::TYPE_NULL ;
974+
975+ break ;
976+ }
977+
943978 if (!$ useFormula ) {
944979 $ value = self ::castToError ($ c );
945980 } else {
0 commit comments