PluginProbe
wpDataTables – WordPress Data Table, Dynamic Tables & Table Charts Plugin / 6.5.1.7
wpDataTables – WordPress Data Table, Dynamic Tables & Table Charts Plugin v6.5.1.7
6.5.1.7 6.5.1.6 6.5.1.5 6.5.1.4 6.5.1.3 6.5.1.2 6.5.1.1 6.5.0.9 6.5.0.8 6.5.0.7 6.5.0.6 trunk 3.4.2.40 3.4.2.41 3.4.2.42 3.4.2.43 3.4.2.44 3.4.2.45 3.4.2.46 3.4.2.47 3.4.2.48 3.4.2.49 3.4.2.50 6.3.2 6.3.3.1 All 47 releases
wpdatatables / lib / phpoffice / phpspreadsheet / src / PhpSpreadsheet / Worksheet / ColumnDimension.php

ColumnDimension.php in wpDataTables – WordPress Data Table, Dynamic Tables & Table Charts Plugin 6.5.1.7, at lib/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/ColumnDimension.php

138 lines 3.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace PhpOffice\PhpSpreadsheet\Worksheet;
4
5 use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
6 use PhpOffice\PhpSpreadsheet\Helper\Dimension as CssDimension;
7
8 class ColumnDimension extends Dimension
9 {
10 /**
11 * Column index.
12 *
13 * @var ?string
14 */
15 private $columnIndex;
16
17 /**
18 * Column width.
19 *
20 * When this is set to a negative value, the column width should be ignored by IWriter
21 *
22 * @var float
23 */
24 private $width = -1;
25
26 /**
27 * Auto size?
28 *
29 * @var bool
30 */
31 private $autoSize = false;
32
33 /**
34 * Create a new ColumnDimension.
35 *
36 * @param ?string $index Character column index
37 */
38 public function __construct($index = 'A')
39 {
40 // Initialise values
41 $this->columnIndex = $index;
42
43 // set dimension as unformatted by default
44 parent::__construct(0);
45 }
46
47 /**
48 * Get column index as string eg: 'A'.
49 */
50 public function getColumnIndex(): ?string
51 {
52 return $this->columnIndex;
53 }
54
55 /**
56 * Set column index as string eg: 'A'.
57 */
58 public function setColumnIndex(string $index): self
59 {
60 $this->columnIndex = $index;
61
62 return $this;
63 }
64
65 /**
66 * Get column index as numeric.
67 */
68 public function getColumnNumeric(): int
69 {
70 return Coordinate::columnIndexFromString($this->columnIndex ?? '');
71 }
72
73 /**
74 * Set column index as numeric.
75 */
76 public function setColumnNumeric(int $index): self
77 {
78 $this->columnIndex = Coordinate::stringFromColumnIndex($index);
79
80 return $this;
81 }
82
83 /**
84 * Get Width.
85 *
86 * Each unit of column width is equal to the width of one character in the default font size. A value of -1
87 * tells Excel to display this column in its default width.
88 * By default, this will be the return value; but this method also accepts an optional unit of measure argument
89 * and will convert the returned value to the specified UoM..
90 */
91 public function getWidth(?string $unitOfMeasure = null): float
92 {
93 return ($unitOfMeasure === null || $this->width < 0)
94 ? $this->width
95 : (new CssDimension((string) $this->width))->toUnit($unitOfMeasure);
96 }
97
98 /**
99 * Set Width.
100 *
101 * Each unit of column width is equal to the width of one character in the default font size. A value of -1
102 * tells Excel to display this column in its default width.
103 * By default, this will be the unit of measure for the passed value; but this method also accepts an
104 * optional unit of measure argument, and will convert the value from the specified UoM using an
105 * approximation method.
106 *
107 * @return $this
108 */
109 public function setWidth(float $width, ?string $unitOfMeasure = null)
110 {
111 $this->width = ($unitOfMeasure === null || $width < 0)
112 ? $width
113 : (new CssDimension("{$width}{$unitOfMeasure}"))->width();
114
115 return $this;
116 }
117
118 /**
119 * Get Auto Size.
120 */
121 public function getAutoSize(): bool
122 {
123 return $this->autoSize;
124 }
125
126 /**
127 * Set Auto Size.
128 *
129 * @return $this
130 */
131 public function setAutoSize(bool $autosizeEnabled)
132 {
133 $this->autoSize = $autosizeEnabled;
134
135 return $this;
136 }
137 }
138