@@ -784,6 +784,19 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet
784
784
785
785
$ charts = $ chartDetails = [];
786
786
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
+
787
800
$ sheetCreated = false ;
788
801
if ($ xmlWorkbookNS ->sheets ) {
789
802
foreach ($ xmlWorkbookNS ->sheets ->sheet as $ eleSheet ) {
@@ -940,6 +953,28 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet
940
953
941
954
break ;
942
955
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
+
943
978
if (!$ useFormula ) {
944
979
$ value = self ::castToError ($ c );
945
980
} else {
0 commit comments