Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.
<?php

namespace PhpOffice\PhpSpreadsheet\Reader\Xlsx;

use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
> use SimpleXMLElement;
class SheetViewOptions extends BaseParserClass {
> /** @var Worksheet */
private $worksheet;
> /** @var ?SimpleXMLElement */
private $worksheetXml;
< public function __construct(Worksheet $workSheet, \SimpleXMLElement $worksheetXml = null)
> public function __construct(Worksheet $workSheet, ?SimpleXMLElement $worksheetXml = null)
{ $this->worksheet = $workSheet; $this->worksheetXml = $worksheetXml; }
< /** < * @param bool $readDataOnly < */ < public function load($readDataOnly = false)
> public function load(bool $readDataOnly, Styles $styleReader): void
{ if ($this->worksheetXml === null) { return; } if (isset($this->worksheetXml->sheetPr)) {
< $this->tabColor($this->worksheetXml->sheetPr); < $this->codeName($this->worksheetXml->sheetPr); < $this->outlines($this->worksheetXml->sheetPr); < $this->pageSetup($this->worksheetXml->sheetPr);
> $sheetPr = $this->worksheetXml->sheetPr; > $this->tabColor($sheetPr, $styleReader); > $this->codeName($sheetPr); > $this->outlines($sheetPr); > $this->pageSetup($sheetPr);
} if (isset($this->worksheetXml->sheetFormatPr)) { $this->sheetFormat($this->worksheetXml->sheetFormatPr); } if (!$readDataOnly && isset($this->worksheetXml->printOptions)) { $this->printOptions($this->worksheetXml->printOptions); } }
< private function tabColor(\SimpleXMLElement $sheetPr)
> private function tabColor(SimpleXMLElement $sheetPr, Styles $styleReader): void
{
< if (isset($sheetPr->tabColor, $sheetPr->tabColor['rgb'])) { < $this->worksheet->getTabColor()->setARGB((string) $sheetPr->tabColor['rgb']);
> if (isset($sheetPr->tabColor)) { > $this->worksheet->getTabColor()->setARGB($styleReader->readColor($sheetPr->tabColor));
} }
< private function codeName(\SimpleXMLElement $sheetPr)
> private function codeName(SimpleXMLElement $sheetPrx): void
{
> $sheetPr = $sheetPrx->attributes() ?? [];
if (isset($sheetPr['codeName'])) { $this->worksheet->setCodeName((string) $sheetPr['codeName'], false); } }
< private function outlines(\SimpleXMLElement $sheetPr)
> private function outlines(SimpleXMLElement $sheetPr): void
{ if (isset($sheetPr->outlinePr)) {
< if (isset($sheetPr->outlinePr['summaryRight']) && < !self::boolean((string) $sheetPr->outlinePr['summaryRight'])) {
> $attr = $sheetPr->outlinePr->attributes() ?? []; > if ( > isset($attr['summaryRight']) && > !self::boolean((string) $attr['summaryRight']) > ) {
$this->worksheet->setShowSummaryRight(false); } else { $this->worksheet->setShowSummaryRight(true); }
< if (isset($sheetPr->outlinePr['summaryBelow']) && < !self::boolean((string) $sheetPr->outlinePr['summaryBelow'])) {
> if ( > isset($attr['summaryBelow']) && > !self::boolean((string) $attr['summaryBelow']) > ) {
$this->worksheet->setShowSummaryBelow(false); } else { $this->worksheet->setShowSummaryBelow(true); } } }
< private function pageSetup(\SimpleXMLElement $sheetPr)
> private function pageSetup(SimpleXMLElement $sheetPr): void
{ if (isset($sheetPr->pageSetUpPr)) {
< if (isset($sheetPr->pageSetUpPr['fitToPage']) && < !self::boolean((string) $sheetPr->pageSetUpPr['fitToPage'])) {
> $attr = $sheetPr->pageSetUpPr->attributes() ?? []; > if ( > isset($attr['fitToPage']) && > !self::boolean((string) $attr['fitToPage']) > ) {
$this->worksheet->getPageSetup()->setFitToPage(false); } else { $this->worksheet->getPageSetup()->setFitToPage(true); } } }
< private function sheetFormat(\SimpleXMLElement $sheetFormatPr)
> private function sheetFormat(SimpleXMLElement $sheetFormatPrx): void
{
< if (isset($sheetFormatPr['customHeight']) &&
> $sheetFormatPr = $sheetFormatPrx->attributes() ?? []; > if ( > isset($sheetFormatPr['customHeight']) &&
self::boolean((string) $sheetFormatPr['customHeight']) &&
< isset($sheetFormatPr['defaultRowHeight'])) {
> isset($sheetFormatPr['defaultRowHeight']) > ) {
$this->worksheet->getDefaultRowDimension() ->setRowHeight((float) $sheetFormatPr['defaultRowHeight']); } if (isset($sheetFormatPr['defaultColWidth'])) { $this->worksheet->getDefaultColumnDimension() ->setWidth((float) $sheetFormatPr['defaultColWidth']); }
< if (isset($sheetFormatPr['zeroHeight']) && < ((string) $sheetFormatPr['zeroHeight'] === '1')) {
> if ( > isset($sheetFormatPr['zeroHeight']) && > ((string) $sheetFormatPr['zeroHeight'] === '1') > ) {
$this->worksheet->getDefaultRowDimension()->setZeroHeight(true); } }
< private function printOptions(\SimpleXMLElement $printOptions)
> private function printOptions(SimpleXMLElement $printOptionsx): void
{
< if (self::boolean((string) $printOptions['gridLinesSet'])) {
> $printOptions = $printOptionsx->attributes() ?? []; > if (isset($printOptions['gridLinesSet']) && self::boolean((string) $printOptions['gridLinesSet'])) {
$this->worksheet->setShowGridlines(true); }
< if (self::boolean((string) $printOptions['gridLines'])) {
> if (isset($printOptions['gridLines']) && self::boolean((string) $printOptions['gridLines'])) {
$this->worksheet->setPrintGridlines(true); }
< if (self::boolean((string) $printOptions['horizontalCentered'])) {
> if (isset($printOptions['horizontalCentered']) && self::boolean((string) $printOptions['horizontalCentered'])) {
$this->worksheet->getPageSetup()->setHorizontalCentered(true); }
< if (self::boolean((string) $printOptions['verticalCentered'])) {
> if (isset($printOptions['verticalCentered']) && self::boolean((string) $printOptions['verticalCentered'])) {
$this->worksheet->getPageSetup()->setVerticalCentered(true); } } }