@@ -854,6 +854,8 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet
854
854
}
855
855
856
856
// Read cell!
857
+ $ useFormula = isset ($ c ->f )
858
+ && ((string ) $ c ->f !== '' || (isset ($ c ->f ->attributes ()['t ' ]) && strtolower ((string ) $ c ->f ->attributes ()['t ' ]) === 'shared ' ));
857
859
switch ($ cellDataType ) {
858
860
case DataType::TYPE_STRING :
859
861
if ((string ) $ c ->v != '' ) {
@@ -868,7 +870,7 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet
868
870
869
871
break ;
870
872
case DataType::TYPE_BOOL :
871
- if (!isset ( $ c -> f ) || (( string ) $ c -> f ) === '' ) {
873
+ if (!$ useFormula ) {
872
874
if (isset ($ c ->v )) {
873
875
$ value = self ::castToBoolean ($ c );
874
876
} else {
@@ -883,16 +885,16 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet
883
885
884
886
break ;
885
887
case DataType::TYPE_STRING2 :
886
- if (isset ( $ c -> f ) ) {
888
+ if ($ useFormula ) {
887
889
$ this ->castToFormula ($ c , $ r , $ cellDataType , $ value , $ calculatedValue , 'castToString ' );
888
890
self ::storeFormulaAttributes ($ c ->f , $ docSheet , $ r );
889
891
} else {
890
- $ value = self ::castToString ($ c );
892
+ $ value = self ::castToString ($ c );
891
893
}
892
894
893
895
break ;
894
896
case DataType::TYPE_INLINE :
895
- if (isset ( $ c -> f ) ) {
897
+ if ($ useFormula ) {
896
898
$ this ->castToFormula ($ c , $ r , $ cellDataType , $ value , $ calculatedValue , 'castToError ' );
897
899
self ::storeFormulaAttributes ($ c ->f , $ docSheet , $ r );
898
900
} else {
@@ -901,7 +903,7 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet
901
903
902
904
break ;
903
905
case DataType::TYPE_ERROR :
904
- if (!isset ( $ c -> f ) ) {
906
+ if (!$ useFormula ) {
905
907
$ value = self ::castToError ($ c );
906
908
} else {
907
909
// Formula
@@ -916,7 +918,7 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet
916
918
917
919
break ;
918
920
default :
919
- if (!isset ( $ c -> f ) ) {
921
+ if (!$ useFormula ) {
920
922
$ value = self ::castToString ($ c );
921
923
if (is_numeric ($ value )) {
922
924
$ value += 0 ;
0 commit comments