PluginProbe
TablePress – Tables in WordPress made easy / 3.4
TablePress – Tables in WordPress made easy v3.4
3.4 3.3.4 3.3.3 3.3.2 3.3.1 trunk 1.12 1.14 1.9.2 2.0.4 2.1.7 2.1.8 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.3 2.3.1 2.3.2 2.4 2.4.1 2.4.2 2.4.3 All 45 releases
tablepress / libraries / vendor / PhpSpreadsheet / Worksheet / AutoFit.php

AutoFit.php in TablePress – Tables in WordPress made easy 3.4, at libraries/vendor/PhpSpreadsheet/Worksheet/AutoFit.php

50 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace TablePress\PhpOffice\PhpSpreadsheet\Worksheet;
4
5 use TablePress\PhpOffice\PhpSpreadsheet\Cell\CellAddress;
6 use TablePress\PhpOffice\PhpSpreadsheet\Cell\CellRange;
7 use TablePress\PhpOffice\PhpSpreadsheet\Cell\Coordinate;
8
9 class AutoFit
10 {
11 protected Worksheet $worksheet;
12
13 public function __construct(Worksheet $worksheet)
14 {
15 $this->worksheet = $worksheet;
16 }
17
18 /** @return mixed[] */
19 public function getAutoFilterIndentRanges(): array
20 {
21 $autoFilterIndentRanges = [];
22 $autoFilterIndentRanges[] = $this->getAutoFilterIndentRange($this->worksheet->getAutoFilter());
23
24 foreach ($this->worksheet->getTableCollection() as $table) {
25 if ($table->getShowHeaderRow() === true && $table->getAllowFilter() === true) {
26 $autoFilter = $table->getAutoFilter();
27 $autoFilterIndentRanges[] = $this->getAutoFilterIndentRange($autoFilter);
28 }
29 }
30
31 return array_filter($autoFilterIndentRanges);
32 }
33
34 private function getAutoFilterIndentRange(AutoFilter $autoFilter): ?string
35 {
36 $autoFilterRange = $autoFilter->getRange();
37 $autoFilterIndentRange = null;
38
39 if (!empty($autoFilterRange)) {
40 $autoFilterRangeBoundaries = Coordinate::rangeBoundaries($autoFilterRange);
41 $autoFilterIndentRange = (string) new CellRange(
42 CellAddress::fromColumnAndRow($autoFilterRangeBoundaries[0][0], $autoFilterRangeBoundaries[0][1]),
43 CellAddress::fromColumnAndRow($autoFilterRangeBoundaries[1][0], $autoFilterRangeBoundaries[0][1])
44 );
45 }
46
47 return $autoFilterIndentRange;
48 }
49 }
50