ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
PhpOffice\PhpSpreadsheet\Reader\Xlsx Class Reference
+ Inheritance diagram for PhpOffice\PhpSpreadsheet\Reader\Xlsx:
+ Collaboration diagram for PhpOffice\PhpSpreadsheet\Reader\Xlsx:

Public Member Functions

 __construct ()
 Create a new Xlsx Reader instance. More...
 
 canRead ($pFilename)
 Can the current IReader read the file? More...
 
 listWorksheetNames ($pFilename)
 Reads names of the worksheets from a file, without parsing the whole file to a Spreadsheet object. More...
 
- Public Member Functions inherited from PhpOffice\PhpSpreadsheet\Reader\BaseReader
 __construct ()
 IReader constructor. More...
 
 getReadDataOnly ()
 Read data only? If this is true, then the Reader will only read data values for cells, it will not read any formatting information. More...
 
 setReadDataOnly ($pValue)
 Set read data only Set to true, to advise the Reader only to read data values for cells, and to ignore any formatting information. More...
 
 getReadEmptyCells ()
 Read empty cells? If this is true (the default), then the Reader will read data values for all cells, irrespective of value. More...
 
 setReadEmptyCells ($pValue)
 Set read empty cells Set to true (the default) to advise the Reader read data values for all cells, irrespective of value. More...
 
 getIncludeCharts ()
 Read charts in workbook? If this is true, then the Reader will include any charts that exist in the workbook. More...
 
 setIncludeCharts ($pValue)
 Set read charts in workbook Set to true, to advise the Reader to include any charts that exist in the workbook. More...
 
 getLoadSheetsOnly ()
 Get which sheets to load Returns either an array of worksheet names (the list of worksheets that should be loaded), or a null indicating that all worksheets in the workbook should be loaded. More...
 
 setLoadSheetsOnly ($value)
 Set which sheets to load. More...
 
 setLoadAllSheets ()
 Set all sheets to load Tells the Reader to load all worksheets from the workbook. More...
 
 getReadFilter ()
 Read filter. More...
 
 setReadFilter (IReadFilter $pValue)
 Set read filter. More...
 
 getSecurityScanner ()
 
- Public Member Functions inherited from PhpOffice\PhpSpreadsheet\Reader\IReader
 load ($pFilename)
 Loads PhpSpreadsheet from file. More...
 

Static Public Member Functions

static stripWhiteSpaceFromStyleString ($string)
 

Private Member Functions

 castToFormula ($c, $r, &$cellDataType, &$value, &$calculatedValue, &$sharedFormulas, $castBaseType)
 
 getFromZipArchive (ZipArchive $archive, $fileName='')
 
 readRibbon (Spreadsheet $excel, $customUITarget, $zip)
 
 readHyperLinkDrawing ($objDrawing, $cellAnchor, $hyperlinks)
 
 readProtection (Spreadsheet $excel, SimpleXMLElement $xmlWorkbook)
 
 readFormControlProperties (Spreadsheet $excel, ZipArchive $zip, $dir, $fileWorksheet, $docSheet, array &$unparsedLoadedData)
 
 readPrinterSettings (Spreadsheet $excel, ZipArchive $zip, $dir, $fileWorksheet, $docSheet, array &$unparsedLoadedData)
 
 castXsdBooleanToBool ($xsdBoolean)
 Convert an 'xsd:boolean' XML value to a PHP boolean value. More...
 
 getWorkbookBaseName (ZipArchive $zip)
 
 readSheetProtection (Worksheet $docSheet, SimpleXMLElement $xmlSheet)
 

Static Private Member Functions

static castToBoolean ($c)
 
static castToError ($c)
 
static castToString ($c)
 
static readStyle (Style $docStyle, $style)
 
static getArrayItem ($array, $key=0)
 
static dirAdd ($base, $add)
 
static toCSSArray ($style)
 
static boolean ($value)
 
static getLockValue (SimpleXmlElement $protection, string $key)
 

Private Attributes

 $referenceHelper
 

Static Private Attributes

static $theme = null
 

Additional Inherited Members

- Protected Member Functions inherited from PhpOffice\PhpSpreadsheet\Reader\BaseReader
 openFile ($pFilename)
 Open file for reading. More...
 
- Protected Attributes inherited from PhpOffice\PhpSpreadsheet\Reader\BaseReader
 $readDataOnly = false
 
 $readEmptyCells = true
 
 $includeCharts = false
 
 $loadSheetsOnly
 
 $readFilter
 
 $fileHandle
 
 $securityScanner
 

Detailed Description

Definition at line 41 of file Xlsx.php.

Constructor & Destructor Documentation

◆ __construct()

PhpOffice\PhpSpreadsheet\Reader\Xlsx::__construct ( )

Create a new Xlsx Reader instance.

Implements PhpOffice\PhpSpreadsheet\Reader\IReader.

Definition at line 60 of file Xlsx.php.

References PhpOffice\PhpSpreadsheet\ReferenceHelper\getInstance(), and PhpOffice\PhpSpreadsheet\Reader\Security\XmlScanner\getInstance().

61  {
62  parent::__construct();
63  $this->referenceHelper = ReferenceHelper::getInstance();
64  $this->securityScanner = XmlScanner::getInstance($this);
65  }
static getInstance(Reader\IReader $reader)
Definition: XmlScanner.php:39
static getInstance()
Get an instance of this class.
+ Here is the call graph for this function:

Member Function Documentation

◆ boolean()

static PhpOffice\PhpSpreadsheet\Reader\Xlsx::boolean (   $value)
staticprivate

Definition at line 1772 of file Xlsx.php.

1773  {
1774  if (is_object($value)) {
1775  $value = (string) $value;
1776  }
1777  if (is_numeric($value)) {
1778  return (bool) $value;
1779  }
1780 
1781  return $value === 'true' || $value === 'TRUE';
1782  }

◆ canRead()

PhpOffice\PhpSpreadsheet\Reader\Xlsx::canRead (   $pFilename)

Can the current IReader read the file?

Parameters
string$pFilename
Returns
bool

Implements PhpOffice\PhpSpreadsheet\Reader\IReader.

Definition at line 74 of file Xlsx.php.

References $result, PhpOffice\PhpSpreadsheet\Shared\File\assertFile(), and PhpOffice\PhpSpreadsheet\Reader\Xlsx\getWorkbookBaseName().

75  {
76  File::assertFile($pFilename);
77 
78  $result = false;
79  $zip = new ZipArchive();
80 
81  if ($zip->open($pFilename) === true) {
82  $workbookBasename = $this->getWorkbookBaseName($zip);
83  $result = !empty($workbookBasename);
84 
85  $zip->close();
86  }
87 
88  return $result;
89  }
$result
static assertFile($filename)
Assert that given path is an existing file and is readable, otherwise throw exception.
Definition: File.php:143
getWorkbookBaseName(ZipArchive $zip)
Definition: Xlsx.php:1934
+ Here is the call graph for this function:

◆ castToBoolean()

static PhpOffice\PhpSpreadsheet\Reader\Xlsx::castToBoolean (   $c)
staticprivate

Definition at line 238 of file Xlsx.php.

References $c, and if.

239  {
240  $value = isset($c->v) ? (string) $c->v : null;
241  if ($value == '0') {
242  return false;
243  } elseif ($value == '1') {
244  return true;
245  }
246 
247  return (bool) $c->v;
248  }
if(!file_exists(getcwd() . '/ilias.ini.php'))
registration confirmation script for ilias
Definition: confirmReg.php:12

◆ castToError()

static PhpOffice\PhpSpreadsheet\Reader\Xlsx::castToError (   $c)
staticprivate

Definition at line 250 of file Xlsx.php.

References $c.

251  {
252  return isset($c->v) ? (string) $c->v : null;
253  }

◆ castToFormula()

PhpOffice\PhpSpreadsheet\Reader\Xlsx::castToFormula (   $c,
  $r,
$cellDataType,
$value,
$calculatedValue,
$sharedFormulas,
  $castBaseType 
)
private

Definition at line 260 of file Xlsx.php.

References $c, $current, $r, if, and PhpOffice\PhpSpreadsheet\Cell\Coordinate\indexesFromString().

Referenced by PhpOffice\PhpSpreadsheet\Reader\Xlsx\getFromZipArchive().

260  : void
261  {
262  $cellDataType = 'f';
263  $value = "={$c->f}";
264  $calculatedValue = self::$castBaseType($c);
265 
266  // Shared formula?
267  if (isset($c->f['t']) && strtolower((string) $c->f['t']) == 'shared') {
268  $instance = (string) $c->f['si'];
269 
270  if (!isset($sharedFormulas[(string) $c->f['si']])) {
271  $sharedFormulas[$instance] = ['master' => $r, 'formula' => $value];
272  } else {
273  $master = Coordinate::indexesFromString($sharedFormulas[$instance]['master']);
275 
276  $difference = [0, 0];
277  $difference[0] = $current[0] - $master[0];
278  $difference[1] = $current[1] - $master[1];
279 
280  $value = $this->referenceHelper->updateFormulaReferences($sharedFormulas[$instance]['formula'], 'A1', $difference[0], $difference[1]);
281  }
282  }
283  }
$r
Definition: example_031.php:79
if(!file_exists(getcwd() . '/ilias.ini.php'))
registration confirmation script for ilias
Definition: confirmReg.php:12
static indexesFromString(string $coordinates)
Get indexes from a string coordinates.
Definition: Coordinate.php:52
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ castToString()

static PhpOffice\PhpSpreadsheet\Reader\Xlsx::castToString (   $c)
staticprivate

Definition at line 255 of file Xlsx.php.

References $c.

256  {
257  return isset($c->v) ? (string) $c->v : null;
258  }

◆ castXsdBooleanToBool()

PhpOffice\PhpSpreadsheet\Reader\Xlsx::castXsdBooleanToBool (   $xsdBoolean)
private

Convert an 'xsd:boolean' XML value to a PHP boolean value.

A valid 'xsd:boolean' XML value can be one of the following four values: 'true', 'false', '1', '0'. It is case sensitive.

Note that just doing '(bool) $xsdBoolean' is not safe, since '(bool) "false"' returns true.

See also
https://www.w3.org/TR/xmlschema11-2/#boolean
Parameters
string$xsdBooleanAn XML string value of type 'xsd:boolean'
Returns
bool Boolean value

Definition at line 1920 of file Xlsx.php.

Referenced by PhpOffice\PhpSpreadsheet\Reader\Xlsx\getFromZipArchive().

1921  {
1922  if ($xsdBoolean === 'false') {
1923  return false;
1924  }
1925 
1926  return (bool) $xsdBoolean;
1927  }
+ Here is the caller graph for this function:

◆ dirAdd()

static PhpOffice\PhpSpreadsheet\Reader\Xlsx::dirAdd (   $base,
  $add 
)
staticprivate

Definition at line 1731 of file Xlsx.php.

References $base.

1732  {
1733  return preg_replace('~[^/]+/\.\./~', '', dirname($base) . "/$add");
1734  }
$base
Definition: index.php:4

◆ getArrayItem()

static PhpOffice\PhpSpreadsheet\Reader\Xlsx::getArrayItem (   $array,
  $key = 0 
)
staticprivate

Definition at line 1726 of file Xlsx.php.

References $key.

1727  {
1728  return $array[$key] ?? null;
1729  }
$key
Definition: croninfo.php:18

◆ getFromZipArchive()

PhpOffice\PhpSpreadsheet\Reader\Xlsx::getFromZipArchive ( ZipArchive  $archive,
  $fileName = '' 
)
private
Parameters
string$fileName
Returns
string

Definition at line 290 of file Xlsx.php.

References $attributes, $c, $comment, $contentType, $key, $r, $row, $style, PhpOffice\PhpSpreadsheet\Shared\Drawing\angleToDegrees(), PhpOffice\PhpSpreadsheet\Shared\File\assertFile(), PhpOffice\PhpSpreadsheet\Style\NumberFormat\builtInFormatCode(), PhpOffice\PhpSpreadsheet\Shared\Date\CALENDAR_MAC_1904, PhpOffice\PhpSpreadsheet\Shared\Date\CALENDAR_WINDOWS_1900, PhpOffice\PhpSpreadsheet\Reader\Xlsx\castToFormula(), PhpOffice\PhpSpreadsheet\Reader\Xlsx\castXsdBooleanToBool(), PhpOffice\PhpSpreadsheet\Shared\StringHelper\controlCharacterOOXML2PHP(), PhpOffice\PhpSpreadsheet\Cell\Coordinate\coordinateFromString(), PhpOffice\PhpSpreadsheet\DefinedName\createInstance(), PhpOffice\PhpSpreadsheet\Shared\Drawing\EMUToPixels(), PhpOffice\PhpSpreadsheet\Worksheet\Worksheet\extractSheetTitle(), PhpOffice\PhpSpreadsheet\Style\NumberFormat\FORMAT_GENERAL, PhpOffice\PhpSpreadsheet\Settings\getLibXmlLoaderOptions(), PhpOffice\PhpSpreadsheet\Reader\BaseReader\getReadDataOnly(), PhpOffice\PhpSpreadsheet\Reader\BaseReader\getReadFilter(), PhpOffice\PhpSpreadsheet\Reader\Xlsx\getWorkbookBaseName(), PhpOffice\PhpSpreadsheet\Reader\IReader\load(), PhpOffice\PhpSpreadsheet\Reader\Xlsx\Chart\readChart(), PhpOffice\PhpSpreadsheet\Reader\Xlsx\readFormControlProperties(), PhpOffice\PhpSpreadsheet\Reader\Xlsx\readHyperLinkDrawing(), PhpOffice\PhpSpreadsheet\Reader\Xlsx\readPrinterSettings(), PhpOffice\PhpSpreadsheet\Reader\Xlsx\readProtection(), PhpOffice\PhpSpreadsheet\Reader\Xlsx\readRibbon(), PhpOffice\PhpSpreadsheet\Reader\Xlsx\readSheetProtection(), PhpOffice\PhpSpreadsheet\Shared\File\realpath(), PhpOffice\PhpSpreadsheet\Shared\Date\setExcelCalendar(), PhpOffice\PhpSpreadsheet\Cell\Coordinate\stringFromColumnIndex(), PhpOffice\PhpSpreadsheet\DefinedName\testIfFormula(), PhpOffice\PhpSpreadsheet\Cell\DataType\TYPE_NUMERIC, and PhpOffice\PhpSpreadsheet\Cell\DataType\TYPE_STRING.

Referenced by PhpOffice\PhpSpreadsheet\Reader\Xlsx\readFormControlProperties(), PhpOffice\PhpSpreadsheet\Reader\Xlsx\readPrinterSettings(), and PhpOffice\PhpSpreadsheet\Reader\Xlsx\readRibbon().

291  {
292  // Root-relative paths
293  if (strpos($fileName, '//') !== false) {
294  $fileName = substr($fileName, strpos($fileName, '//') + 1);
295  }
296  $fileName = File::realpath($fileName);
297 
298  // Sadly, some 3rd party xlsx generators don't use consistent case for filenaming
299  // so we need to load case-insensitively from the zip file
300 
301  // Apache POI fixes
302  $contents = $archive->getFromName($fileName, 0, ZipArchive::FL_NOCASE);
303  if ($contents === false) {
304  $contents = $archive->getFromName(substr($fileName, 1), 0, ZipArchive::FL_NOCASE);
305  }
306 
307  return $contents;
308  }
static realpath($pFilename)
Returns canonicalized absolute pathname, also for ZIP archives.
Definition: File.php:76
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLockValue()

static PhpOffice\PhpSpreadsheet\Reader\Xlsx::getLockValue ( SimpleXmlElement  $protection,
string  $key 
)
staticprivate

Definition at line 1830 of file Xlsx.php.

References $key.

1830  : ?bool
1831  {
1832  $returnValue = null;
1833  $protectKey = $protection[$key];
1834  if (!empty($protectKey)) {
1835  $protectKey = (string) $protectKey;
1836  $returnValue = $protectKey !== 'false' && (bool) $protectKey;
1837  }
1838 
1839  return $returnValue;
1840  }
$key
Definition: croninfo.php:18

◆ getWorkbookBaseName()

PhpOffice\PhpSpreadsheet\Reader\Xlsx::getWorkbookBaseName ( ZipArchive  $zip)
private
Parameters
ZipArchive$zipOpened zip archive
Returns
string basename of the used excel workbook

Definition at line 1934 of file Xlsx.php.

References PhpOffice\PhpSpreadsheet\Settings\getLibXmlLoaderOptions().

Referenced by PhpOffice\PhpSpreadsheet\Reader\Xlsx\canRead(), and PhpOffice\PhpSpreadsheet\Reader\Xlsx\getFromZipArchive().

1935  {
1936  $workbookBasename = '';
1937 
1938  // check if it is an OOXML archive
1939  $rels = simplexml_load_string(
1940  $this->securityScanner->scan(
1941  $this->getFromZipArchive($zip, '_rels/.rels')
1942  ),
1943  'SimpleXMLElement',
1945  );
1946  if ($rels !== false) {
1947  foreach ($rels->Relationship as $rel) {
1948  switch ($rel['Type']) {
1949  case 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument':
1950  $basename = basename($rel['Target']);
1951  if (preg_match('/workbook.*\.xml/', $basename)) {
1952  $workbookBasename = $basename;
1953  }
1954 
1955  break;
1956  }
1957  }
1958  }
1959 
1960  return $workbookBasename;
1961  }
static getLibXmlLoaderOptions()
Get default options for libxml loader.
Definition: Settings.php:116
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ listWorksheetNames()

PhpOffice\PhpSpreadsheet\Reader\Xlsx::listWorksheetNames (   $pFilename)

Reads names of the worksheets from a file, without parsing the whole file to a Spreadsheet object.

Parameters
string$pFilename
Returns
array

Definition at line 98 of file Xlsx.php.

References $row, $xml, PhpOffice\PhpSpreadsheet\Shared\File\assertFile(), PhpOffice\PhpSpreadsheet\Settings\getLibXmlLoaderOptions(), PhpOffice\PhpSpreadsheet\Shared\File\realpath(), and PhpOffice\PhpSpreadsheet\Cell\Coordinate\stringFromColumnIndex().

99  {
100  File::assertFile($pFilename);
101 
102  $worksheetNames = [];
103 
104  $zip = new ZipArchive();
105  $zip->open($pFilename);
106 
107  // The files we're looking at here are small enough that simpleXML is more efficient than XMLReader
108  //~ http://schemas.openxmlformats.org/package/2006/relationships");
109  $rels = simplexml_load_string(
110  $this->securityScanner->scan($this->getFromZipArchive($zip, '_rels/.rels'))
111  );
112  foreach ($rels->Relationship as $rel) {
113  switch ($rel['Type']) {
114  case 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument':
115  //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"
116  $xmlWorkbook = simplexml_load_string(
117  $this->securityScanner->scan($this->getFromZipArchive($zip, "{$rel['Target']}"))
118  );
119 
120  if ($xmlWorkbook->sheets) {
121  foreach ($xmlWorkbook->sheets->sheet as $eleSheet) {
122  // Check if sheet should be skipped
123  $worksheetNames[] = (string) $eleSheet['name'];
124  }
125  }
126  }
127  }
128 
129  $zip->close();
130 
131  return $worksheetNames;
132  }
static assertFile($filename)
Assert that given path is an existing file and is readable, otherwise throw exception.
Definition: File.php:143
+ Here is the call graph for this function:

◆ readFormControlProperties()

PhpOffice\PhpSpreadsheet\Reader\Xlsx::readFormControlProperties ( Spreadsheet  $excel,
ZipArchive  $zip,
  $dir,
  $fileWorksheet,
  $docSheet,
array &  $unparsedLoadedData 
)
private

Definition at line 1842 of file Xlsx.php.

References PhpOffice\PhpSpreadsheet\Reader\Xlsx\getFromZipArchive(), and PhpOffice\PhpSpreadsheet\Settings\getLibXmlLoaderOptions().

Referenced by PhpOffice\PhpSpreadsheet\Reader\Xlsx\getFromZipArchive().

1842  : void
1843  {
1844  if (!$zip->locateName(dirname("$dir/$fileWorksheet") . '/_rels/' . basename($fileWorksheet) . '.rels')) {
1845  return;
1846  }
1847 
1848  //~ http://schemas.openxmlformats.org/package/2006/relationships"
1849  $relsWorksheet = simplexml_load_string(
1850  $this->securityScanner->scan(
1851  $this->getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . '/_rels/' . basename($fileWorksheet) . '.rels')
1852  ),
1853  'SimpleXMLElement',
1855  );
1856  $ctrlProps = [];
1857  foreach ($relsWorksheet->Relationship as $ele) {
1858  if ($ele['Type'] == 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/ctrlProp') {
1859  $ctrlProps[(string) $ele['Id']] = $ele;
1860  }
1861  }
1862 
1863  $unparsedCtrlProps = &$unparsedLoadedData['sheets'][$docSheet->getCodeName()]['ctrlProps'];
1864  foreach ($ctrlProps as $rId => $ctrlProp) {
1865  $rId = substr($rId, 3); // rIdXXX
1866  $unparsedCtrlProps[$rId] = [];
1867  $unparsedCtrlProps[$rId]['filePath'] = self::dirAdd("$dir/$fileWorksheet", $ctrlProp['Target']);
1868  $unparsedCtrlProps[$rId]['relFilePath'] = (string) $ctrlProp['Target'];
1869  $unparsedCtrlProps[$rId]['content'] = $this->securityScanner->scan($this->getFromZipArchive($zip, $unparsedCtrlProps[$rId]['filePath']));
1870  }
1871  unset($unparsedCtrlProps);
1872  }
getFromZipArchive(ZipArchive $archive, $fileName='')
Definition: Xlsx.php:290
static getLibXmlLoaderOptions()
Get default options for libxml loader.
Definition: Settings.php:116
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readHyperLinkDrawing()

PhpOffice\PhpSpreadsheet\Reader\Xlsx::readHyperLinkDrawing (   $objDrawing,
  $cellAnchor,
  $hyperlinks 
)
private
Parameters
\PhpOffice\PhpSpreadsheet\Worksheet\Drawing$objDrawing
SimpleXMLElement$cellAnchor
array$hyperlinks

Definition at line 1789 of file Xlsx.php.

Referenced by PhpOffice\PhpSpreadsheet\Reader\Xlsx\getFromZipArchive().

1789  : void
1790  {
1791  $hlinkClick = $cellAnchor->pic->nvPicPr->cNvPr->children('http://schemas.openxmlformats.org/drawingml/2006/main')->hlinkClick;
1792 
1793  if ($hlinkClick->count() === 0) {
1794  return;
1795  }
1796 
1797  $hlinkId = (string) $hlinkClick->attributes('http://schemas.openxmlformats.org/officeDocument/2006/relationships')['id'];
1798  $hyperlink = new Hyperlink(
1799  $hyperlinks[$hlinkId],
1800  (string) self::getArrayItem($cellAnchor->pic->nvPicPr->cNvPr->attributes(), 'name')
1801  );
1802  $objDrawing->setHyperlink($hyperlink);
1803  }
+ Here is the caller graph for this function:

◆ readPrinterSettings()

PhpOffice\PhpSpreadsheet\Reader\Xlsx::readPrinterSettings ( Spreadsheet  $excel,
ZipArchive  $zip,
  $dir,
  $fileWorksheet,
  $docSheet,
array &  $unparsedLoadedData 
)
private

Definition at line 1874 of file Xlsx.php.

References PhpOffice\PhpSpreadsheet\Reader\Xlsx\getFromZipArchive(), and PhpOffice\PhpSpreadsheet\Settings\getLibXmlLoaderOptions().

Referenced by PhpOffice\PhpSpreadsheet\Reader\Xlsx\getFromZipArchive().

1874  : void
1875  {
1876  if (!$zip->locateName(dirname("$dir/$fileWorksheet") . '/_rels/' . basename($fileWorksheet) . '.rels')) {
1877  return;
1878  }
1879 
1880  //~ http://schemas.openxmlformats.org/package/2006/relationships"
1881  $relsWorksheet = simplexml_load_string(
1882  $this->securityScanner->scan(
1883  $this->getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . '/_rels/' . basename($fileWorksheet) . '.rels')
1884  ),
1885  'SimpleXMLElement',
1887  );
1888  $sheetPrinterSettings = [];
1889  foreach ($relsWorksheet->Relationship as $ele) {
1890  if ($ele['Type'] == 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/printerSettings') {
1891  $sheetPrinterSettings[(string) $ele['Id']] = $ele;
1892  }
1893  }
1894 
1895  $unparsedPrinterSettings = &$unparsedLoadedData['sheets'][$docSheet->getCodeName()]['printerSettings'];
1896  foreach ($sheetPrinterSettings as $rId => $printerSettings) {
1897  $rId = substr($rId, 3) . 'ps'; // rIdXXX, add 'ps' suffix to avoid identical resource identifier collision with unparsed vmlDrawing
1898  $unparsedPrinterSettings[$rId] = [];
1899  $unparsedPrinterSettings[$rId]['filePath'] = self::dirAdd("$dir/$fileWorksheet", $printerSettings['Target']);
1900  $unparsedPrinterSettings[$rId]['relFilePath'] = (string) $printerSettings['Target'];
1901  $unparsedPrinterSettings[$rId]['content'] = $this->securityScanner->scan($this->getFromZipArchive($zip, $unparsedPrinterSettings[$rId]['filePath']));
1902  }
1903  unset($unparsedPrinterSettings);
1904  }
getFromZipArchive(ZipArchive $archive, $fileName='')
Definition: Xlsx.php:290
static getLibXmlLoaderOptions()
Get default options for libxml loader.
Definition: Settings.php:116
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readProtection()

PhpOffice\PhpSpreadsheet\Reader\Xlsx::readProtection ( Spreadsheet  $excel,
SimpleXMLElement  $xmlWorkbook 
)
private

Definition at line 1805 of file Xlsx.php.

References PhpOffice\PhpSpreadsheet\Spreadsheet\getSecurity().

Referenced by PhpOffice\PhpSpreadsheet\Reader\Xlsx\getFromZipArchive().

1805  : void
1806  {
1807  if (!$xmlWorkbook->workbookProtection) {
1808  return;
1809  }
1810 
1811  $excel->getSecurity()->setLockRevision(self::getLockValue($xmlWorkbook->workbookProtection, 'lockRevision'));
1812  $excel->getSecurity()->setLockStructure(self::getLockValue($xmlWorkbook->workbookProtection, 'lockStructure'));
1813  $excel->getSecurity()->setLockWindows(self::getLockValue($xmlWorkbook->workbookProtection, 'lockWindows'));
1814 
1815  if ($xmlWorkbook->workbookProtection['revisionsPassword']) {
1816  $excel->getSecurity()->setRevisionsPassword(
1817  (string) $xmlWorkbook->workbookProtection['revisionsPassword'],
1818  true
1819  );
1820  }
1821 
1822  if ($xmlWorkbook->workbookProtection['workbookPassword']) {
1823  $excel->getSecurity()->setWorkbookPassword(
1824  (string) $xmlWorkbook->workbookProtection['workbookPassword'],
1825  true
1826  );
1827  }
1828  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readRibbon()

PhpOffice\PhpSpreadsheet\Reader\Xlsx::readRibbon ( Spreadsheet  $excel,
  $customUITarget,
  $zip 
)
private
Parameters
mixed$customUITarget
mixed$zip

Definition at line 1684 of file Xlsx.php.

References $baseDir, PhpOffice\PhpSpreadsheet\Reader\Xlsx\getFromZipArchive(), PhpOffice\PhpSpreadsheet\Settings\getLibXmlLoaderOptions(), PhpOffice\PhpSpreadsheet\Spreadsheet\setRibbonBinObjects(), and PhpOffice\PhpSpreadsheet\Spreadsheet\setRibbonXMLData().

Referenced by PhpOffice\PhpSpreadsheet\Reader\Xlsx\getFromZipArchive().

1684  : void
1685  {
1686  $baseDir = dirname($customUITarget);
1687  $nameCustomUI = basename($customUITarget);
1688  // get the xml file (ribbon)
1689  $localRibbon = $this->getFromZipArchive($zip, $customUITarget);
1690  $customUIImagesNames = [];
1691  $customUIImagesBinaries = [];
1692  // something like customUI/_rels/customUI.xml.rels
1693  $pathRels = $baseDir . '/_rels/' . $nameCustomUI . '.rels';
1694  $dataRels = $this->getFromZipArchive($zip, $pathRels);
1695  if ($dataRels) {
1696  // exists and not empty if the ribbon have some pictures (other than internal MSO)
1697  $UIRels = simplexml_load_string(
1698  $this->securityScanner->scan($dataRels),
1699  'SimpleXMLElement',
1701  );
1702  if (false !== $UIRels) {
1703  // we need to save id and target to avoid parsing customUI.xml and "guess" if it's a pseudo callback who load the image
1704  foreach ($UIRels->Relationship as $ele) {
1705  if ($ele['Type'] == 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image') {
1706  // an image ?
1707  $customUIImagesNames[(string) $ele['Id']] = (string) $ele['Target'];
1708  $customUIImagesBinaries[(string) $ele['Target']] = $this->getFromZipArchive($zip, $baseDir . '/' . (string) $ele['Target']);
1709  }
1710  }
1711  }
1712  }
1713  if ($localRibbon) {
1714  $excel->setRibbonXMLData($customUITarget, $localRibbon);
1715  if (count($customUIImagesNames) > 0 && count($customUIImagesBinaries) > 0) {
1716  $excel->setRibbonBinObjects($customUIImagesNames, $customUIImagesBinaries);
1717  } else {
1718  $excel->setRibbonBinObjects(null, null);
1719  }
1720  } else {
1721  $excel->setRibbonXMLData(null, null);
1722  $excel->setRibbonBinObjects(null, null);
1723  }
1724  }
getFromZipArchive(ZipArchive $archive, $fileName='')
Definition: Xlsx.php:290
static getLibXmlLoaderOptions()
Get default options for libxml loader.
Definition: Settings.php:116
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readSheetProtection()

PhpOffice\PhpSpreadsheet\Reader\Xlsx::readSheetProtection ( Worksheet  $docSheet,
SimpleXMLElement  $xmlSheet 
)
private

Definition at line 1963 of file Xlsx.php.

References PhpOffice\PhpSpreadsheet\Worksheet\Worksheet\getProtection(), and PhpOffice\PhpSpreadsheet\Worksheet\Worksheet\protectCells().

Referenced by PhpOffice\PhpSpreadsheet\Reader\Xlsx\getFromZipArchive().

1963  : void
1964  {
1965  if ($this->readDataOnly || !$xmlSheet->sheetProtection) {
1966  return;
1967  }
1968 
1969  $algorithmName = (string) $xmlSheet->sheetProtection['algorithmName'];
1970  $protection = $docSheet->getProtection();
1971  $protection->setAlgorithm($algorithmName);
1972 
1973  if ($algorithmName) {
1974  $protection->setPassword((string) $xmlSheet->sheetProtection['hashValue'], true);
1975  $protection->setSalt((string) $xmlSheet->sheetProtection['saltValue']);
1976  $protection->setSpinCount((int) $xmlSheet->sheetProtection['spinCount']);
1977  } else {
1978  $protection->setPassword((string) $xmlSheet->sheetProtection['password'], true);
1979  }
1980 
1981  if ($xmlSheet->protectedRanges->protectedRange) {
1982  foreach ($xmlSheet->protectedRanges->protectedRange as $protectedRange) {
1983  $docSheet->protectCells((string) $protectedRange['sqref'], (string) $protectedRange['password'], true);
1984  }
1985  }
1986  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readStyle()

static PhpOffice\PhpSpreadsheet\Reader\Xlsx::readStyle ( Style  $docStyle,
  $style 
)
staticprivate
Parameters
SimpleXMLElement | stdClass$style

Definition at line 1574 of file Xlsx.php.

References $style, PhpOffice\PhpSpreadsheet\Shared\StringHelper\controlCharacterOOXML2PHP(), PhpOffice\PhpSpreadsheet\Reader\Xlsx\Styles\readAlignmentStyle(), PhpOffice\PhpSpreadsheet\Reader\Xlsx\Styles\readBorderStyle(), PhpOffice\PhpSpreadsheet\Reader\Xlsx\Styles\readColor(), PhpOffice\PhpSpreadsheet\Reader\Xlsx\Styles\readFontStyle(), PhpOffice\PhpSpreadsheet\Reader\Xlsx\Styles\readProtectionHidden(), and PhpOffice\PhpSpreadsheet\Reader\Xlsx\Styles\readProtectionLocked().

1574  : void
1575  {
1576  $docStyle->getNumberFormat()->setFormatCode($style->numFmt);
1577 
1578  // font
1579  if (isset($style->font)) {
1580  Styles::readFontStyle($docStyle->getFont(), $style->font);
1581  }
1582 
1583  // fill
1584  if (isset($style->fill)) {
1585  Styles::readFillStyle($docStyle->getFill(), $style->fill);
1586  }
1587 
1588  // border
1589  if (isset($style->border)) {
1590  Styles::readBorderStyle($docStyle->getBorders(), $style->border);
1591  }
1592 
1593  // alignment
1594  if (isset($style->alignment)) {
1595  Styles::readAlignmentStyle($docStyle->getAlignment(), $style->alignment);
1596  }
1597 
1598  // protection
1599  if (isset($style->protection)) {
1600  Styles::readProtectionLocked($docStyle, $style->protection);
1601  Styles::readProtectionHidden($docStyle, $style->protection);
1602  }
1603 
1604  // top-level style settings
1605  if (isset($style->quotePrefix)) {
1606  $docStyle->setQuotePrefix((bool) $style->quotePrefix);
1607  }
1608  }
$style
Definition: example_012.php:70
static readProtectionHidden(Style $docStyle, $style)
Definition: Styles.php:227
static readFontStyle(Font $fontStyle, SimpleXMLElement $fontStyleXml)
Definition: Styles.php:43
static readBorderStyle(Borders $borderStyle, SimpleXMLElement $borderStyleXml)
Definition: Styles.php:126
static readProtectionLocked(Style $docStyle, $style)
Definition: Styles.php:216
static readAlignmentStyle(Alignment $alignment, SimpleXMLElement $alignmentXml)
Definition: Styles.php:157
+ Here is the call graph for this function:

◆ stripWhiteSpaceFromStyleString()

static PhpOffice\PhpSpreadsheet\Reader\Xlsx::stripWhiteSpaceFromStyleString (   $string)
static

Definition at line 1767 of file Xlsx.php.

1768  {
1769  return trim(str_replace(["\r", "\n", ' '], '', $string), ';');
1770  }

◆ toCSSArray()

static PhpOffice\PhpSpreadsheet\Reader\Xlsx::toCSSArray (   $style)
staticprivate

Definition at line 1736 of file Xlsx.php.

References $style, PhpOffice\PhpSpreadsheet\Shared\Font\centimeterSizeToPixels(), PhpOffice\PhpSpreadsheet\Shared\Font\fontSizeToPixels(), and PhpOffice\PhpSpreadsheet\Shared\Font\inchSizeToPixels().

1737  {
1738  $style = self::stripWhiteSpaceFromStyleString($style);
1739 
1740  $temp = explode(';', $style);
1741  $style = [];
1742  foreach ($temp as $item) {
1743  $item = explode(':', $item);
1744 
1745  if (strpos($item[1], 'px') !== false) {
1746  $item[1] = str_replace('px', '', $item[1]);
1747  }
1748  if (strpos($item[1], 'pt') !== false) {
1749  $item[1] = str_replace('pt', '', $item[1]);
1750  $item[1] = Font::fontSizeToPixels($item[1]);
1751  }
1752  if (strpos($item[1], 'in') !== false) {
1753  $item[1] = str_replace('in', '', $item[1]);
1754  $item[1] = Font::inchSizeToPixels($item[1]);
1755  }
1756  if (strpos($item[1], 'cm') !== false) {
1757  $item[1] = str_replace('cm', '', $item[1]);
1758  $item[1] = Font::centimeterSizeToPixels($item[1]);
1759  }
1760 
1761  $style[$item[0]] = $item[1];
1762  }
1763 
1764  return $style;
1765  }
$style
Definition: example_012.php:70
static centimeterSizeToPixels($sizeInCm)
Calculate an (approximate) pixel size, based on centimeter size.
Definition: Font.php:386
static inchSizeToPixels($sizeInInch)
Calculate an (approximate) pixel size, based on inch size.
Definition: Font.php:374
static fontSizeToPixels($fontSizeInPoints)
Calculate an (approximate) pixel size, based on a font points size.
Definition: Font.php:362
+ Here is the call graph for this function:

Field Documentation

◆ $referenceHelper

PhpOffice\PhpSpreadsheet\Reader\Xlsx::$referenceHelper
private

Definition at line 48 of file Xlsx.php.

◆ $theme

PhpOffice\PhpSpreadsheet\Reader\Xlsx::$theme = null
staticprivate

Definition at line 55 of file Xlsx.php.


The documentation for this class was generated from the following file: