@@ -300,44 +300,7 @@ public function loadIntoExisting(string $filename, Spreadsheet $spreadsheet): Sp
300
300
}
301
301
}
302
302
303
- $ ValueType = $ cellAttributes ->ValueType ;
304
- $ ExprID = (string ) $ cellAttributes ->ExprID ;
305
- $ type = DataType::TYPE_FORMULA ;
306
- if ($ ExprID > '' ) {
307
- if (((string ) $ cell ) > '' ) {
308
- $ this ->expressions [$ ExprID ] = [
309
- 'column ' => $ cellAttributes ->Col ,
310
- 'row ' => $ cellAttributes ->Row ,
311
- 'formula ' => (string ) $ cell ,
312
- ];
313
- } else {
314
- $ expression = $ this ->expressions [$ ExprID ];
315
-
316
- $ cell = $ this ->referenceHelper ->updateFormulaReferences (
317
- $ expression ['formula ' ],
318
- 'A1 ' ,
319
- $ cellAttributes ->Col - $ expression ['column ' ],
320
- $ cellAttributes ->Row - $ expression ['row ' ],
321
- $ worksheetName
322
- );
323
- }
324
- $ type = DataType::TYPE_FORMULA ;
325
- } else {
326
- $ vtype = (string ) $ ValueType ;
327
- if (array_key_exists ($ vtype , self ::$ mappings ['dataType ' ])) {
328
- $ type = self ::$ mappings ['dataType ' ][$ vtype ];
329
- }
330
- if ($ vtype === '20 ' ) { // Boolean
331
- $ cell = $ cell == 'TRUE ' ;
332
- }
333
- }
334
-
335
- $ this ->spreadsheet ->getActiveSheet ()->getCell ($ column . $ row )->setValueExplicit ((string ) $ cell , $ type );
336
- if (isset ($ cellAttributes ->ValueFormat )) {
337
- $ this ->spreadsheet ->getActiveSheet ()->getCell ($ column . $ row )
338
- ->getStyle ()->getNumberFormat ()
339
- ->setFormatCode ((string ) $ cellAttributes ->ValueFormat );
340
- }
303
+ $ this ->loadCell ($ cell , $ worksheetName , $ cellAttributes , $ column , $ row );
341
304
}
342
305
343
306
if ($ sheet ->Styles !== null ) {
@@ -536,4 +499,51 @@ private function parseRichText(string $is): RichText
536
499
537
500
return $ value ;
538
501
}
502
+
503
+ private function loadCell (
504
+ SimpleXMLElement $ cell ,
505
+ string $ worksheetName ,
506
+ SimpleXMLElement $ cellAttributes ,
507
+ string $ column ,
508
+ int $ row
509
+ ): void {
510
+ $ ValueType = $ cellAttributes ->ValueType ;
511
+ $ ExprID = (string ) $ cellAttributes ->ExprID ;
512
+ $ type = DataType::TYPE_FORMULA ;
513
+ if ($ ExprID > '' ) {
514
+ if (((string ) $ cell ) > '' ) {
515
+ $ this ->expressions [$ ExprID ] = [
516
+ 'column ' => $ cellAttributes ->Col ,
517
+ 'row ' => $ cellAttributes ->Row ,
518
+ 'formula ' => (string ) $ cell ,
519
+ ];
520
+ } else {
521
+ $ expression = $ this ->expressions [$ ExprID ];
522
+
523
+ $ cell = $ this ->referenceHelper ->updateFormulaReferences (
524
+ $ expression ['formula ' ],
525
+ 'A1 ' ,
526
+ $ cellAttributes ->Col - $ expression ['column ' ],
527
+ $ cellAttributes ->Row - $ expression ['row ' ],
528
+ $ worksheetName
529
+ );
530
+ }
531
+ $ type = DataType::TYPE_FORMULA ;
532
+ } else {
533
+ $ vtype = (string ) $ ValueType ;
534
+ if (array_key_exists ($ vtype , self ::$ mappings ['dataType ' ])) {
535
+ $ type = self ::$ mappings ['dataType ' ][$ vtype ];
536
+ }
537
+ if ($ vtype === '20 ' ) { // Boolean
538
+ $ cell = $ cell == 'TRUE ' ;
539
+ }
540
+ }
541
+
542
+ $ this ->spreadsheet ->getActiveSheet ()->getCell ($ column . $ row )->setValueExplicit ((string ) $ cell , $ type );
543
+ if (isset ($ cellAttributes ->ValueFormat )) {
544
+ $ this ->spreadsheet ->getActiveSheet ()->getCell ($ column . $ row )
545
+ ->getStyle ()->getNumberFormat ()
546
+ ->setFormatCode ((string ) $ cellAttributes ->ValueFormat );
547
+ }
548
+ }
539
549
}
0 commit comments