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 / NamedRange.php

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

57 lines 1.1 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;
4
5 use TablePress\PhpOffice\PhpSpreadsheet\Cell\Coordinate;
6 use TablePress\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
7
8 class NamedRange extends DefinedName
9 {
10 /**
11 * Create a new Named Range.
12 */
13 public function __construct(
14 string $name,
15 ?Worksheet $worksheet = null,
16 string $range = 'A1',
17 bool $localOnly = false,
18 ?Worksheet $scope = null
19 ) {
20 if ($worksheet === null && $scope === null) {
21 throw new Exception('You must specify a worksheet or a scope for a Named Range');
22 }
23 parent::__construct($name, $worksheet, $range, $localOnly, $scope);
24 }
25
26 /**
27 * Get the range value.
28 */
29 public function getRange(): string
30 {
31 return $this->value;
32 }
33
34 /**
35 * Set the range value.
36 */
37 public function setRange(string $range): self
38 {
39 if (!empty($range)) {
40 $this->value = $range;
41 }
42
43 return $this;
44 }
45
46 /** @return string[] */
47 public function getCellsInRange(): array
48 {
49 $range = $this->value;
50 if (str_starts_with($range, '=')) {
51 $range = (string) substr($range, 1);
52 }
53
54 return Coordinate::extractAllCellReferencesInRange($range);
55 }
56 }
57