visualizer
/
vendor
/
phpoffice
/
phpspreadsheet
/
src
/
PhpSpreadsheet
/
Reader
/
Xlsx
/
DataValidations.php
DataValidations.php in Visualizer – Tables & Charts Manager with Built-in AI Generator 3.5.0, at vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/DataValidations.php
| 1 | <?php |
| 2 | |
| 3 | namespace PhpOffice\PhpSpreadsheet\Reader\Xlsx; |
| 4 | |
| 5 | use PhpOffice\PhpSpreadsheet\Cell\Coordinate; |
| 6 | use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; |
| 7 | |
| 8 | class DataValidations |
| 9 | { |
| 10 | private $worksheet; |
| 11 | |
| 12 | private $worksheetXml; |
| 13 | |
| 14 | public function __construct(Worksheet $workSheet, \SimpleXMLElement $worksheetXml) |
| 15 | { |
| 16 | $this->worksheet = $workSheet; |
| 17 | $this->worksheetXml = $worksheetXml; |
| 18 | } |
| 19 | |
| 20 | public function load() |
| 21 | { |
| 22 | foreach ($this->worksheetXml->dataValidations->dataValidation as $dataValidation) { |
| 23 | // Uppercase coordinate |
| 24 | $range = strtoupper($dataValidation['sqref']); |
| 25 | $rangeSet = explode(' ', $range); |
| 26 | foreach ($rangeSet as $range) { |
| 27 | $stRange = $this->worksheet->shrinkRangeToFit($range); |
| 28 | |
| 29 | // Extract all cell references in $range |
| 30 | foreach (Coordinate::extractAllCellReferencesInRange($stRange) as $reference) { |
| 31 | // Create validation |
| 32 | $docValidation = $this->worksheet->getCell($reference)->getDataValidation(); |
| 33 | $docValidation->setType((string) $dataValidation['type']); |
| 34 | $docValidation->setErrorStyle((string) $dataValidation['errorStyle']); |
| 35 | $docValidation->setOperator((string) $dataValidation['operator']); |
| 36 | $docValidation->setAllowBlank($dataValidation['allowBlank'] != 0); |
| 37 | $docValidation->setShowDropDown($dataValidation['showDropDown'] == 0); |
| 38 | $docValidation->setShowInputMessage($dataValidation['showInputMessage'] != 0); |
| 39 | $docValidation->setShowErrorMessage($dataValidation['showErrorMessage'] != 0); |
| 40 | $docValidation->setErrorTitle((string) $dataValidation['errorTitle']); |
| 41 | $docValidation->setError((string) $dataValidation['error']); |
| 42 | $docValidation->setPromptTitle((string) $dataValidation['promptTitle']); |
| 43 | $docValidation->setPrompt((string) $dataValidation['prompt']); |
| 44 | $docValidation->setFormula1((string) $dataValidation->formula1); |
| 45 | $docValidation->setFormula2((string) $dataValidation->formula2); |
| 46 | } |
| 47 | } |
| 48 | } |
| 49 | } |
| 50 | } |
| 51 |