File tree 1 file changed +17
-22
lines changed
src/PhpSpreadsheet/Reader
1 file changed +17
-22
lines changed Original file line number Diff line number Diff line change @@ -541,28 +541,11 @@ public function load(string $filename, int $flags = 0): Spreadsheet
541
541
$ xmlStyles = $ this ->loadZip ("$ dir/ $ xpath [Target]" , $ mainNS );
542
542
}
543
543
544
- $ fills = [];
545
- $ fonts = [];
546
- $ borders = [];
547
- $ xfTags = [];
548
- $ cellXfTags = [];
549
- if (count ($ xmlStyles ) > 0 ) {
550
- foreach ($ xmlStyles ->fills ->fill as $ fill ) {
551
- $ fills [] = $ fill ;
552
- }
553
- foreach ($ xmlStyles ->fonts ->font as $ font ) {
554
- $ fonts [] = $ font ;
555
- }
556
- foreach ($ xmlStyles ->borders ->border as $ border ) {
557
- $ borders [] = $ border ;
558
- }
559
- foreach ($ xmlStyles ->cellXfs ->xf as $ xf ) {
560
- $ xfTags [] = $ xf ;
561
- }
562
- foreach ($ xmlStyles ->cellStyleXfs ->xf as $ xf ) {
563
- $ cellXfTags [] = $ xf ;
564
- }
565
- }
544
+ $ fills = self ::extractStyles ($ xmlStyles , 'fills ' , 'fill ' );
545
+ $ fonts = self ::extractStyles ($ xmlStyles , 'fonts ' , 'font ' );
546
+ $ borders = self ::extractStyles ($ xmlStyles , 'borders ' , 'border ' );
547
+ $ xfTags = self ::extractStyles ($ xmlStyles , 'cellXfs ' , 'xf ' );
548
+ $ cellXfTags = self ::extractStyles ($ xmlStyles , 'cellStyleXfs ' , 'xf ' );
566
549
567
550
$ styles = [];
568
551
$ cellStyles = [];
@@ -2094,4 +2077,16 @@ private function readAutoFilterTablesInTablesFile(
2094
2077
}
2095
2078
}
2096
2079
}
2080
+
2081
+ private static function extractStyles (?SimpleXMLElement $ sxml , string $ node1 , string $ node2 ): array
2082
+ {
2083
+ $ array = [];
2084
+ if ($ sxml && $ sxml ->{$ node1 }->{$ node2 }) {
2085
+ foreach ($ sxml ->{$ node1 }->{$ node2 } as $ node ) {
2086
+ $ array [] = $ node ;
2087
+ }
2088
+ }
2089
+
2090
+ return $ array ;
2091
+ }
2097
2092
}
You can’t perform that action at this time.
0 commit comments