wpdatatables
/
lib
/
phpoffice
/
phpspreadsheet
/
src
/
PhpSpreadsheet
/
Calculation
/
LookupRef.php
LookupRef.php in wpDataTables – WordPress Data Table, Dynamic Tables & Table Charts Plugin 6.5.1.7, at lib/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/LookupRef.php
| 1 | <?php |
| 2 | |
| 3 | namespace PhpOffice\PhpSpreadsheet\Calculation; |
| 4 | |
| 5 | use PhpOffice\PhpSpreadsheet\Calculation\LookupRef\Address; |
| 6 | use PhpOffice\PhpSpreadsheet\Calculation\LookupRef\HLookup; |
| 7 | use PhpOffice\PhpSpreadsheet\Calculation\LookupRef\Indirect; |
| 8 | use PhpOffice\PhpSpreadsheet\Calculation\LookupRef\Lookup; |
| 9 | use PhpOffice\PhpSpreadsheet\Calculation\LookupRef\Matrix; |
| 10 | use PhpOffice\PhpSpreadsheet\Calculation\LookupRef\Offset; |
| 11 | use PhpOffice\PhpSpreadsheet\Calculation\LookupRef\RowColumnInformation; |
| 12 | use PhpOffice\PhpSpreadsheet\Calculation\LookupRef\VLookup; |
| 13 | use PhpOffice\PhpSpreadsheet\Cell\Cell; |
| 14 | use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; |
| 15 | |
| 16 | /** |
| 17 | * @deprecated 1.18.0 |
| 18 | */ |
| 19 | class LookupRef |
| 20 | { |
| 21 | /** |
| 22 | * CELL_ADDRESS. |
| 23 | * |
| 24 | * Creates a cell address as text, given specified row and column numbers. |
| 25 | * |
| 26 | * Excel Function: |
| 27 | * =ADDRESS(row, column, [relativity], [referenceStyle], [sheetText]) |
| 28 | * |
| 29 | * @deprecated 1.18.0 |
| 30 | * Use the cell() method in the LookupRef\Address class instead |
| 31 | * @see LookupRef\Address::cell() |
| 32 | * |
| 33 | * @param mixed $row Row number to use in the cell reference |
| 34 | * @param mixed $column Column number to use in the cell reference |
| 35 | * @param int $relativity Flag indicating the type of reference to return |
| 36 | * 1 or omitted Absolute |
| 37 | * 2 Absolute row; relative column |
| 38 | * 3 Relative row; absolute column |
| 39 | * 4 Relative |
| 40 | * @param bool $referenceStyle A logical value that specifies the A1 or R1C1 reference style. |
| 41 | * TRUE or omitted CELL_ADDRESS returns an A1-style reference |
| 42 | * FALSE CELL_ADDRESS returns an R1C1-style reference |
| 43 | * @param array|string $sheetText Optional Name of worksheet to use |
| 44 | * |
| 45 | * @return array|string |
| 46 | */ |
| 47 | public static function cellAddress($row, $column, $relativity = 1, $referenceStyle = true, $sheetText = '') |
| 48 | { |
| 49 | return Address::cell($row, $column, $relativity, $referenceStyle, $sheetText); |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * COLUMN. |
| 54 | * |
| 55 | * Returns the column number of the given cell reference |
| 56 | * If the cell reference is a range of cells, COLUMN returns the column numbers of each column |
| 57 | * in the reference as a horizontal array. |
| 58 | * If cell reference is omitted, and the function is being called through the calculation engine, |
| 59 | * then it is assumed to be the reference of the cell in which the COLUMN function appears; |
| 60 | * otherwise this function returns 1. |
| 61 | * |
| 62 | * Excel Function: |
| 63 | * =COLUMN([cellAddress]) |
| 64 | * |
| 65 | * @deprecated 1.18.0 |
| 66 | * Use the COLUMN() method in the LookupRef\RowColumnInformation class instead |
| 67 | * @see LookupRef\RowColumnInformation::COLUMN() |
| 68 | * |
| 69 | * @param null|array|string $cellAddress A reference to a range of cells for which you want the column numbers |
| 70 | * |
| 71 | * @return int|int[]|string |
| 72 | */ |
| 73 | public static function COLUMN($cellAddress = null, ?Cell $cell = null) |
| 74 | { |
| 75 | return RowColumnInformation::COLUMN($cellAddress, $cell); |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * COLUMNS. |
| 80 | * |
| 81 | * Returns the number of columns in an array or reference. |
| 82 | * |
| 83 | * Excel Function: |
| 84 | * =COLUMNS(cellAddress) |
| 85 | * |
| 86 | * @deprecated 1.18.0 |
| 87 | * Use the COLUMNS() method in the LookupRef\RowColumnInformation class instead |
| 88 | * @see LookupRef\RowColumnInformation::COLUMNS() |
| 89 | * |
| 90 | * @param null|array|string $cellAddress An array or array formula, or a reference to a range of cells |
| 91 | * for which you want the number of columns |
| 92 | * |
| 93 | * @return int|string The number of columns in cellAddress, or a string if arguments are invalid |
| 94 | */ |
| 95 | public static function COLUMNS($cellAddress = null) |
| 96 | { |
| 97 | return RowColumnInformation::COLUMNS($cellAddress); |
| 98 | } |
| 99 | |
| 100 | /** |
| 101 | * ROW. |
| 102 | * |
| 103 | * Returns the row number of the given cell reference |
| 104 | * If the cell reference is a range of cells, ROW returns the row numbers of each row in the reference |
| 105 | * as a vertical array. |
| 106 | * If cell reference is omitted, and the function is being called through the calculation engine, |
| 107 | * then it is assumed to be the reference of the cell in which the ROW function appears; |
| 108 | * otherwise this function returns 1. |
| 109 | * |
| 110 | * Excel Function: |
| 111 | * =ROW([cellAddress]) |
| 112 | * |
| 113 | * @deprecated 1.18.0 |
| 114 | * Use the ROW() method in the LookupRef\RowColumnInformation class instead |
| 115 | * @see LookupRef\RowColumnInformation::ROW() |
| 116 | * |
| 117 | * @param null|array|string $cellAddress A reference to a range of cells for which you want the row numbers |
| 118 | * |
| 119 | * @return int|mixed[]|string |
| 120 | */ |
| 121 | public static function ROW($cellAddress = null, ?Cell $cell = null) |
| 122 | { |
| 123 | return RowColumnInformation::ROW($cellAddress, $cell); |
| 124 | } |
| 125 | |
| 126 | /** |
| 127 | * ROWS. |
| 128 | * |
| 129 | * Returns the number of rows in an array or reference. |
| 130 | * |
| 131 | * Excel Function: |
| 132 | * =ROWS(cellAddress) |
| 133 | * |
| 134 | * @deprecated 1.18.0 |
| 135 | * Use the ROWS() method in the LookupRef\RowColumnInformation class instead |
| 136 | * @see LookupRef\RowColumnInformation::ROWS() |
| 137 | * |
| 138 | * @param null|array|string $cellAddress An array or array formula, or a reference to a range of cells |
| 139 | * for which you want the number of rows |
| 140 | * |
| 141 | * @return int|string The number of rows in cellAddress, or a string if arguments are invalid |
| 142 | */ |
| 143 | public static function ROWS($cellAddress = null) |
| 144 | { |
| 145 | return RowColumnInformation::ROWS($cellAddress); |
| 146 | } |
| 147 | |
| 148 | /** |
| 149 | * HYPERLINK. |
| 150 | * |
| 151 | * Excel Function: |
| 152 | * =HYPERLINK(linkURL,displayName) |
| 153 | * |
| 154 | * @deprecated 1.18.0 |
| 155 | * Use the set() method in the LookupRef\Hyperlink class instead |
| 156 | * @see LookupRef\Hyperlink::set() |
| 157 | * |
| 158 | * @param mixed $linkURL Expect string. Value to check, is also the value returned when no error |
| 159 | * @param mixed $displayName Expect string. Value to return when testValue is an error condition |
| 160 | * @param Cell $cell The cell to set the hyperlink in |
| 161 | * |
| 162 | * @return string The value of $displayName (or $linkURL if $displayName was blank) |
| 163 | */ |
| 164 | public static function HYPERLINK($linkURL = '', $displayName = null, ?Cell $cell = null) |
| 165 | { |
| 166 | return LookupRef\Hyperlink::set($linkURL, $displayName, $cell); |
| 167 | } |
| 168 | |
| 169 | /** |
| 170 | * INDIRECT. |
| 171 | * |
| 172 | * Returns the reference specified by a text string. |
| 173 | * References are immediately evaluated to display their contents. |
| 174 | * |
| 175 | * Excel Function: |
| 176 | * =INDIRECT(cellAddress) |
| 177 | * |
| 178 | * @deprecated 1.18.0 |
| 179 | * Use the INDIRECT() method in the LookupRef\Indirect class instead |
| 180 | * @see LookupRef\Indirect::INDIRECT() |
| 181 | * |
| 182 | * @param array|string $cellAddress $cellAddress The cell address of the current cell (containing this formula) |
| 183 | * @param Cell $cell The current cell (containing this formula) |
| 184 | * |
| 185 | * @return array|string An array containing a cell or range of cells, or a string on error |
| 186 | * |
| 187 | * NOTE - INDIRECT() does not yet support the optional a1 parameter introduced in Excel 2010 |
| 188 | */ |
| 189 | public static function INDIRECT($cellAddress, Cell $cell) |
| 190 | { |
| 191 | return Indirect::INDIRECT($cellAddress, true, $cell); |
| 192 | } |
| 193 | |
| 194 | /** |
| 195 | * OFFSET. |
| 196 | * |
| 197 | * Returns a reference to a range that is a specified number of rows and columns from a cell or range of cells. |
| 198 | * The reference that is returned can be a single cell or a range of cells. You can specify the number of rows and |
| 199 | * the number of columns to be returned. |
| 200 | * |
| 201 | * Excel Function: |
| 202 | * =OFFSET(cellAddress, rows, cols, [height], [width]) |
| 203 | * |
| 204 | * @deprecated 1.18.0 |
| 205 | * Use the OFFSET() method in the LookupRef\Offset class instead |
| 206 | * @see LookupRef\Offset::OFFSET() |
| 207 | * |
| 208 | * @param null|string $cellAddress The reference from which you want to base the offset. |
| 209 | * Reference must refer to a cell or range of adjacent cells; |
| 210 | * otherwise, OFFSET returns the #VALUE! error value. |
| 211 | * @param mixed $rows The number of rows, up or down, that you want the upper-left cell to refer to. |
| 212 | * Using 5 as the rows argument specifies that the upper-left cell in the |
| 213 | * reference is five rows below reference. Rows can be positive (which means |
| 214 | * below the starting reference) or negative (which means above the starting |
| 215 | * reference). |
| 216 | * @param mixed $columns The number of columns, to the left or right, that you want the upper-left cell |
| 217 | * of the result to refer to. Using 5 as the cols argument specifies that the |
| 218 | * upper-left cell in the reference is five columns to the right of reference. |
| 219 | * Cols can be positive (which means to the right of the starting reference) |
| 220 | * or negative (which means to the left of the starting reference). |
| 221 | * @param mixed $height The height, in number of rows, that you want the returned reference to be. |
| 222 | * Height must be a positive number. |
| 223 | * @param mixed $width The width, in number of columns, that you want the returned reference to be. |
| 224 | * Width must be a positive number. |
| 225 | * |
| 226 | * @return array|int|string An array containing a cell or range of cells, or a string on error |
| 227 | */ |
| 228 | public static function OFFSET($cellAddress = null, $rows = 0, $columns = 0, $height = null, $width = null, ?Cell $cell = null) |
| 229 | { |
| 230 | return Offset::OFFSET($cellAddress, $rows, $columns, $height, $width, $cell); |
| 231 | } |
| 232 | |
| 233 | /** |
| 234 | * CHOOSE. |
| 235 | * |
| 236 | * Uses lookup_value to return a value from the list of value arguments. |
| 237 | * Use CHOOSE to select one of up to 254 values based on the lookup_value. |
| 238 | * |
| 239 | * Excel Function: |
| 240 | * =CHOOSE(index_num, value1, [value2], ...) |
| 241 | * |
| 242 | * @deprecated 1.18.0 |
| 243 | * Use the choose() method in the LookupRef\Selection class instead |
| 244 | * @see LookupRef\Selection::choose() |
| 245 | * |
| 246 | * @param array $chooseArgs |
| 247 | * |
| 248 | * @return mixed The selected value |
| 249 | */ |
| 250 | public static function CHOOSE(...$chooseArgs) |
| 251 | { |
| 252 | return LookupRef\Selection::choose(...$chooseArgs); |
| 253 | } |
| 254 | |
| 255 | /** |
| 256 | * MATCH. |
| 257 | * |
| 258 | * The MATCH function searches for a specified item in a range of cells |
| 259 | * |
| 260 | * Excel Function: |
| 261 | * =MATCH(lookup_value, lookup_array, [match_type]) |
| 262 | * |
| 263 | * @deprecated 1.18.0 |
| 264 | * Use the MATCH() method in the LookupRef\ExcelMatch class instead |
| 265 | * @see LookupRef\ExcelMatch::MATCH() |
| 266 | * |
| 267 | * @param mixed $lookupValue The value that you want to match in lookup_array |
| 268 | * @param mixed $lookupArray The range of cells being searched |
| 269 | * @param mixed $matchType The number -1, 0, or 1. -1 means above, 0 means exact match, 1 means below. |
| 270 | * If match_type is 1 or -1, the list has to be ordered. |
| 271 | * |
| 272 | * @return array|int|string The relative position of the found item |
| 273 | */ |
| 274 | public static function MATCH($lookupValue, $lookupArray, $matchType = 1) |
| 275 | { |
| 276 | return LookupRef\ExcelMatch::MATCH($lookupValue, $lookupArray, $matchType); |
| 277 | } |
| 278 | |
| 279 | /** |
| 280 | * INDEX. |
| 281 | * |
| 282 | * Uses an index to choose a value from a reference or array |
| 283 | * |
| 284 | * Excel Function: |
| 285 | * =INDEX(range_array, row_num, [column_num]) |
| 286 | * |
| 287 | * @deprecated 1.18.0 |
| 288 | * Use the index() method in the LookupRef\Matrix class instead |
| 289 | * @see LookupRef\Matrix::index() |
| 290 | * |
| 291 | * @param mixed $rowNum The row in the array or range from which to return a value. |
| 292 | * If row_num is omitted, column_num is required. |
| 293 | * @param mixed $columnNum The column in the array or range from which to return a value. |
| 294 | * If column_num is omitted, row_num is required. |
| 295 | * @param mixed $matrix |
| 296 | * |
| 297 | * @return mixed the value of a specified cell or array of cells |
| 298 | */ |
| 299 | public static function INDEX($matrix, $rowNum = 0, $columnNum = 0) |
| 300 | { |
| 301 | return Matrix::index($matrix, $rowNum, $columnNum); |
| 302 | } |
| 303 | |
| 304 | /** |
| 305 | * TRANSPOSE. |
| 306 | * |
| 307 | * @deprecated 1.18.0 |
| 308 | * Use the transpose() method in the LookupRef\Matrix class instead |
| 309 | * @see LookupRef\Matrix::transpose() |
| 310 | * |
| 311 | * @param array $matrixData A matrix of values |
| 312 | * |
| 313 | * @return array |
| 314 | * |
| 315 | * Unlike the Excel TRANSPOSE function, which will only work on a single row or column, |
| 316 | * this function will transpose a full matrix |
| 317 | */ |
| 318 | public static function TRANSPOSE($matrixData) |
| 319 | { |
| 320 | return Matrix::transpose($matrixData); |
| 321 | } |
| 322 | |
| 323 | /** |
| 324 | * VLOOKUP |
| 325 | * The VLOOKUP function searches for value in the left-most column of lookup_array and returns the value |
| 326 | * in the same row based on the index_number. |
| 327 | * |
| 328 | * @deprecated 1.18.0 |
| 329 | * Use the lookup() method in the LookupRef\VLookup class instead |
| 330 | * @see LookupRef\VLookup::lookup() |
| 331 | * |
| 332 | * @param mixed $lookup_value The value that you want to match in lookup_array |
| 333 | * @param mixed $lookup_array The range of cells being searched |
| 334 | * @param mixed $index_number The column number in table_array from which the matching value must be returned. |
| 335 | * The first column is 1. |
| 336 | * @param mixed $not_exact_match determines if you are looking for an exact match based on lookup_value |
| 337 | * |
| 338 | * @return mixed The value of the found cell |
| 339 | */ |
| 340 | public static function VLOOKUP($lookup_value, $lookup_array, $index_number, $not_exact_match = true) |
| 341 | { |
| 342 | return VLookup::lookup($lookup_value, $lookup_array, $index_number, $not_exact_match); |
| 343 | } |
| 344 | |
| 345 | /** |
| 346 | * HLOOKUP |
| 347 | * The HLOOKUP function searches for value in the top-most row of lookup_array and returns the value |
| 348 | * in the same column based on the index_number. |
| 349 | * |
| 350 | * @deprecated 1.18.0 |
| 351 | * Use the lookup() method in the LookupRef\HLookup class instead |
| 352 | * @see LookupRef\HLookup::lookup() |
| 353 | * |
| 354 | * @param mixed $lookup_value The value that you want to match in lookup_array |
| 355 | * @param mixed $lookup_array The range of cells being searched |
| 356 | * @param mixed $index_number The row number in table_array from which the matching value must be returned. |
| 357 | * The first row is 1. |
| 358 | * @param mixed $not_exact_match determines if you are looking for an exact match based on lookup_value |
| 359 | * |
| 360 | * @return mixed The value of the found cell |
| 361 | */ |
| 362 | public static function HLOOKUP($lookup_value, $lookup_array, $index_number, $not_exact_match = true) |
| 363 | { |
| 364 | return HLookup::lookup($lookup_value, $lookup_array, $index_number, $not_exact_match); |
| 365 | } |
| 366 | |
| 367 | /** |
| 368 | * LOOKUP |
| 369 | * The LOOKUP function searches for value either from a one-row or one-column range or from an array. |
| 370 | * |
| 371 | * @deprecated 1.18.0 |
| 372 | * Use the lookup() method in the LookupRef\Lookup class instead |
| 373 | * @see LookupRef\Lookup::lookup() |
| 374 | * |
| 375 | * @param mixed $lookup_value The value that you want to match in lookup_array |
| 376 | * @param mixed $lookup_vector The range of cells being searched |
| 377 | * @param null|mixed $result_vector The column from which the matching value must be returned |
| 378 | * |
| 379 | * @return mixed The value of the found cell |
| 380 | */ |
| 381 | public static function LOOKUP($lookup_value, $lookup_vector, $result_vector = null) |
| 382 | { |
| 383 | return Lookup::lookup($lookup_value, $lookup_vector, $result_vector); |
| 384 | } |
| 385 | |
| 386 | /** |
| 387 | * FORMULATEXT. |
| 388 | * |
| 389 | * @deprecated 1.18.0 |
| 390 | * Use the text() method in the LookupRef\Formula class instead |
| 391 | * @see LookupRef\Formula::text() |
| 392 | * |
| 393 | * @param mixed $cellReference The cell to check |
| 394 | * @param Cell $cell The current cell (containing this formula) |
| 395 | * |
| 396 | * @return string |
| 397 | */ |
| 398 | public static function FORMULATEXT($cellReference = '', ?Cell $cell = null) |
| 399 | { |
| 400 | return LookupRef\Formula::text($cellReference, $cell); |
| 401 | } |
| 402 | } |
| 403 |