Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 400 and 401]

   1  <?php
   2  
   3  namespace PhpOffice\PhpSpreadsheet\Reader\Ods;
   4  
   5  use DOMElement;
   6  use DOMNode;
   7  
   8  class AutoFilter extends BaseLoader
   9  {
  10      public function read(DOMElement $workbookData): void
  11      {
  12          $this->readAutoFilters($workbookData);
  13      }
  14  
  15      protected function readAutoFilters(DOMElement $workbookData): void
  16      {
  17          $databases = $workbookData->getElementsByTagNameNS($this->tableNs, 'database-ranges');
  18  
  19          foreach ($databases as $autofilters) {
  20              foreach ($autofilters->childNodes as $autofilter) {
  21                  $autofilterRange = $this->getAttributeValue($autofilter, 'target-range-address');
  22                  if ($autofilterRange !== null) {
  23                      $baseAddress = FormulaTranslator::convertToExcelAddressValue($autofilterRange);
  24                      $this->spreadsheet->getActiveSheet()->setAutoFilter($baseAddress);
  25                  }
  26              }
  27          }
  28      }
  29  
  30      protected function getAttributeValue(?DOMNode $node, string $attributeName): ?string
  31      {
  32          if ($node !== null && $node->attributes !== null) {
  33              $attribute = $node->attributes->getNamedItemNS(
  34                  $this->tableNs,
  35                  $attributeName
  36              );
  37  
  38              if ($attribute !== null) {
  39                  return $attribute->nodeValue;
  40              }
  41          }
  42  
  43          return null;
  44      }
  45  }