1 | <?php |
||
11 | class CellHelper |
||
12 | { |
||
13 | /** @var array Cache containing the mapping column index => cell index */ |
||
14 | private static $columnIndexToCellIndexCache = []; |
||
15 | |||
16 | /** |
||
17 | * Returns the cell index (base 26) associated to the base 10 column index. |
||
18 | * Excel uses A to Z letters for column indexing, where A is the 1st column, |
||
19 | * Z is the 26th and AA is the 27th. |
||
20 | * The mapping is zero based, so that 0 maps to A, B maps to 1, Z to 25 and AA to 26. |
||
21 | * |
||
22 | * @param int $columnIndex The Excel column index (0, 42, ...) |
||
23 | * @return string The associated cell index ('A', 'BC', ...) |
||
24 | */ |
||
25 | 105 | public static function getCellIndexFromColumnIndex($columnIndex) |
|
48 | |||
49 | /** |
||
50 | * @param $value |
||
51 | * @return bool Whether the given value is considered "empty" |
||
52 | */ |
||
53 | 45 | public static function isEmpty($value) |
|
57 | |||
58 | /** |
||
59 | * @param $value |
||
60 | * @return bool Whether the given value is a non empty string |
||
61 | */ |
||
62 | 177 | public static function isNonEmptyString($value) |
|
66 | |||
67 | /** |
||
68 | * Returns whether the given value is numeric. |
||
69 | * A numeric value is from type "integer" or "double" ("float" is not returned by gettype). |
||
70 | * |
||
71 | * @param $value |
||
72 | * @return bool Whether the given value is numeric |
||
73 | */ |
||
74 | 30 | public static function isNumeric($value) |
|
79 | |||
80 | /** |
||
81 | * Returns whether the given value is boolean. |
||
82 | * "true"/"false" and 0/1 are not booleans. |
||
83 | * |
||
84 | * @param $value |
||
85 | * @return bool Whether the given value is boolean |
||
86 | */ |
||
87 | 33 | public static function isBoolean($value) |
|
91 | } |
||
92 |