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

Public Member Functions

 __construct ()
 Create a new Gnumeric. 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...
 
 listWorksheetInfo ($pFilename)
 Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns). More...
 
 load ($pFilename)
 Loads Spreadsheet from file. More...
 
 loadIntoExisting (string $pFilename, Spreadsheet $spreadsheet)
 Loads from file into Spreadsheet instance. 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 ()
 
 __construct ()
 IReader constructor. More...
 
 canRead ($pFilename)
 Can the current IReader read the file? 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...
 
 load ($pFilename)
 Loads PhpSpreadsheet from file. More...
 

Static Public Member Functions

static gnumericMappings ()
 

Data Fields

const NAMESPACE_GNM = 'http://www.gnumeric.org/v10.dtd'
 
const NAMESPACE_XSI = 'http://www.w3.org/2001/XMLSchema-instance'
 
const NAMESPACE_OFFICE = 'urn:oasis:names:tc:opendocument:xmlns:office:1.0'
 
const NAMESPACE_XLINK = 'http://www.w3.org/1999/xlink'
 
const NAMESPACE_DC = 'http://purl.org/dc/elements/1.1/'
 
const NAMESPACE_META = 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0'
 
const NAMESPACE_OOO = 'http://openoffice.org/2004/office'
 

Static Public Attributes

static $mappings
 

Private Member Functions

 gzfileGetContents ($filename)
 
 processComments (SimpleXMLElement $sheet)
 
 processMergedCells (?SimpleXMLElement $sheet)
 
 processAutofilter (?SimpleXMLElement $sheet)
 
 setColumnWidth (int $whichColumn, float $defaultWidth)
 
 setColumnInvisible (int $whichColumn)
 
 processColumnLoop (int $whichColumn, int $maxCol, SimpleXMLElement $columnOverride, float $defaultWidth)
 
 processColumnWidths (?SimpleXMLElement $sheet, int $maxCol)
 
 setRowHeight (int $whichRow, float $defaultHeight)
 
 setRowInvisible (int $whichRow)
 
 processRowLoop (int $whichRow, int $maxRow, SimpleXMLElement $rowOverride, float $defaultHeight)
 
 processRowHeights (?SimpleXMLElement $sheet, int $maxRow)
 
 processDefinedNames (?SimpleXMLElement $gnmXML)
 
 parseRichText (string $is)
 

Static Private Member Functions

static matchXml (XMLReader $xml, string $expectedLocalName)
 
static testSimpleXml ($value)
 

Private Attributes

 $expressions = []
 
 $spreadsheet
 
 $referenceHelper
 

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 21 of file Gnumeric.php.

Constructor & Destructor Documentation

◆ __construct()

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

Create a new Gnumeric.

Reimplemented from PhpOffice\PhpSpreadsheet\Reader\BaseReader.

Definition at line 71 of file Gnumeric.php.

72 {
73 parent::__construct();
74 $this->referenceHelper = ReferenceHelper::getInstance();
75 $this->securityScanner = XmlScanner::getInstance($this);
76 }
static getInstance(Reader\IReader $reader)
Definition: XmlScanner.php:39
static getInstance()
Get an instance of this class.

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

+ Here is the call graph for this function:

Member Function Documentation

◆ canRead()

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

Can the current IReader read the file?

Parameters
string$pFilename
Returns
bool

Implements PhpOffice\PhpSpreadsheet\Reader\IReader.

Definition at line 85 of file Gnumeric.php.

86 {
87 File::assertFile($pFilename);
88
89 // Check if gzlib functions are available
90 $data = '';
91 if (function_exists('gzread')) {
92 // Read signature data (first 3 bytes)
93 $fh = fopen($pFilename, 'rb');
94 if ($fh !== false) {
95 $data = fread($fh, 2);
96 fclose($fh);
97 }
98 }
99
100 return $data === chr(0x1F) . chr(0x8B);
101 }
static assertFile($filename)
Assert that given path is an existing file and is readable, otherwise throw exception.
Definition: File.php:143
$data
Definition: bench.php:6

References $data, and PhpOffice\PhpSpreadsheet\Shared\File\assertFile().

+ Here is the call graph for this function:

◆ gnumericMappings()

static PhpOffice\PhpSpreadsheet\Reader\Gnumeric::gnumericMappings ( )
static

Definition at line 207 of file Gnumeric.php.

207 : array
208 {
209 return array_merge(self::$mappings, Styles::$mappings);
210 }

References PhpOffice\PhpSpreadsheet\Reader\Gnumeric\Styles\$mappings.

◆ gzfileGetContents()

PhpOffice\PhpSpreadsheet\Reader\Gnumeric::gzfileGetContents (   $filename)
private
Parameters
string$filename
Returns
string

Definition at line 193 of file Gnumeric.php.

194 {
195 $file = @gzopen($filename, 'rb');
196 $data = '';
197 if ($file !== false) {
198 while (!gzeof($file)) {
199 $data .= gzread($file, 1024);
200 }
201 gzclose($file);
202 }
203
204 return $data;
205 }
$filename
Definition: buildRTE.php:89

References $data, and $filename.

Referenced by PhpOffice\PhpSpreadsheet\Reader\Gnumeric\loadIntoExisting().

+ Here is the caller graph for this function:

◆ listWorksheetInfo()

PhpOffice\PhpSpreadsheet\Reader\Gnumeric::listWorksheetInfo (   $pFilename)

Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns).

Parameters
string$pFilename
Returns
array

Definition at line 146 of file Gnumeric.php.

147 {
148 File::assertFile($pFilename);
149
150 $xml = new XMLReader();
151 $xml->xml($this->securityScanner->scanFile('compress.zlib://' . realpath($pFilename)), null, Settings::getLibXmlLoaderOptions());
152 $xml->setParserProperty(2, true);
153
154 $worksheetInfo = [];
155 while ($xml->read()) {
156 if (self::matchXml($xml, 'Sheet')) {
157 $tmpInfo = [
158 'worksheetName' => '',
159 'lastColumnLetter' => 'A',
160 'lastColumnIndex' => 0,
161 'totalRows' => 0,
162 'totalColumns' => 0,
163 ];
164
165 while ($xml->read()) {
166 if (self::matchXml($xml, 'Name')) {
167 $xml->read(); // Move onto the value node
168 $tmpInfo['worksheetName'] = (string) $xml->value;
169 } elseif (self::matchXml($xml, 'MaxCol')) {
170 $xml->read(); // Move onto the value node
171 $tmpInfo['lastColumnIndex'] = (int) $xml->value;
172 $tmpInfo['totalColumns'] = (int) $xml->value + 1;
173 } elseif (self::matchXml($xml, 'MaxRow')) {
174 $xml->read(); // Move onto the value node
175 $tmpInfo['totalRows'] = (int) $xml->value + 1;
176
177 break;
178 }
179 }
180 $tmpInfo['lastColumnLetter'] = Coordinate::stringFromColumnIndex($tmpInfo['lastColumnIndex'] + 1);
181 $worksheetInfo[] = $tmpInfo;
182 }
183 }
184
185 return $worksheetInfo;
186 }
static stringFromColumnIndex($columnIndex)
String from column index.
Definition: Coordinate.php:313
static getLibXmlLoaderOptions()
Get default options for libxml loader.
Definition: Settings.php:116

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

+ Here is the call graph for this function:

◆ listWorksheetNames()

PhpOffice\PhpSpreadsheet\Reader\Gnumeric::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 117 of file Gnumeric.php.

118 {
119 File::assertFile($pFilename);
120
121 $xml = new XMLReader();
122 $xml->xml($this->securityScanner->scanFile('compress.zlib://' . realpath($pFilename)), null, Settings::getLibXmlLoaderOptions());
123 $xml->setParserProperty(2, true);
124
125 $worksheetNames = [];
126 while ($xml->read()) {
127 if (self::matchXml($xml, 'SheetName')) {
128 $xml->read(); // Move onto the value node
129 $worksheetNames[] = (string) $xml->value;
130 } elseif (self::matchXml($xml, 'Sheets')) {
131 // break out of the loop once we've got our sheet names rather than parse the entire file
132 break;
133 }
134 }
135
136 return $worksheetNames;
137 }

References $xml, PhpOffice\PhpSpreadsheet\Shared\File\assertFile(), and PhpOffice\PhpSpreadsheet\Settings\getLibXmlLoaderOptions().

+ Here is the call graph for this function:

◆ load()

PhpOffice\PhpSpreadsheet\Reader\Gnumeric::load (   $pFilename)

Loads Spreadsheet from file.

Parameters
string$pFilename
Returns
Spreadsheet

Implements PhpOffice\PhpSpreadsheet\Reader\IReader.

Definition at line 242 of file Gnumeric.php.

243 {
244 // Create new Spreadsheet
246 $spreadsheet->removeSheetByIndex(0);
247
248 // Load into this instance
249 return $this->loadIntoExisting($pFilename, $spreadsheet);
250 }
loadIntoExisting(string $pFilename, Spreadsheet $spreadsheet)
Loads from file into Spreadsheet instance.
Definition: Gnumeric.php:255

References PhpOffice\PhpSpreadsheet\Reader\Gnumeric\$spreadsheet, and PhpOffice\PhpSpreadsheet\Reader\Gnumeric\loadIntoExisting().

+ Here is the call graph for this function:

◆ loadIntoExisting()

PhpOffice\PhpSpreadsheet\Reader\Gnumeric::loadIntoExisting ( string  $pFilename,
Spreadsheet  $spreadsheet 
)

Loads from file into Spreadsheet instance.

Definition at line 255 of file Gnumeric.php.

256 {
257 $this->spreadsheet = $spreadsheet;
258 File::assertFile($pFilename);
259
260 $gFileData = $this->gzfileGetContents($pFilename);
261
262 $xml2 = simplexml_load_string($this->securityScanner->scan($gFileData), 'SimpleXMLElement', Settings::getLibXmlLoaderOptions());
263 $xml = self::testSimpleXml($xml2);
264
265 $gnmXML = $xml->children(self::NAMESPACE_GNM);
266 (new Properties($this->spreadsheet))->readProperties($xml, $gnmXML);
267
268 $worksheetID = 0;
269 foreach ($gnmXML->Sheets->Sheet as $sheet) {
270 $worksheetName = (string) $sheet->Name;
271 if ((isset($this->loadSheetsOnly)) && (!in_array($worksheetName, $this->loadSheetsOnly))) {
272 continue;
273 }
274
275 $maxRow = $maxCol = 0;
276
277 // Create new Worksheet
278 $this->spreadsheet->createSheet();
279 $this->spreadsheet->setActiveSheetIndex($worksheetID);
280 // Use false for $updateFormulaCellReferences to prevent adjustment of worksheet references in formula
281 // cells... during the load, all formulae should be correct, and we're simply bringing the worksheet
282 // name in line with the formula, not the reverse
283 $this->spreadsheet->getActiveSheet()->setTitle($worksheetName, false, false);
284
285 if (!$this->readDataOnly) {
286 (new PageSetup($this->spreadsheet))
287 ->printInformation($sheet)
288 ->sheetMargins($sheet);
289 }
290
291 foreach ($sheet->Cells->Cell as $cell) {
292 $cellAttributes = $cell->attributes();
293 $row = (int) $cellAttributes->Row + 1;
294 $column = (int) $cellAttributes->Col;
295
296 if ($row > $maxRow) {
297 $maxRow = $row;
298 }
299 if ($column > $maxCol) {
300 $maxCol = $column;
301 }
302
303 $column = Coordinate::stringFromColumnIndex($column + 1);
304
305 // Read cell?
306 if ($this->getReadFilter() !== null) {
307 if (!$this->getReadFilter()->readCell($column, $row, $worksheetName)) {
308 continue;
309 }
310 }
311
312 $ValueType = $cellAttributes->ValueType;
313 $ExprID = (string) $cellAttributes->ExprID;
315 if ($ExprID > '') {
316 if (((string) $cell) > '') {
317 $this->expressions[$ExprID] = [
318 'column' => $cellAttributes->Col,
319 'row' => $cellAttributes->Row,
320 'formula' => (string) $cell,
321 ];
322 } else {
323 $expression = $this->expressions[$ExprID];
324
325 $cell = $this->referenceHelper->updateFormulaReferences(
326 $expression['formula'],
327 'A1',
328 $cellAttributes->Col - $expression['column'],
329 $cellAttributes->Row - $expression['row'],
330 $worksheetName
331 );
332 }
334 } else {
335 $vtype = (string) $ValueType;
336 if (array_key_exists($vtype, self::$mappings['dataType'])) {
337 $type = self::$mappings['dataType'][$vtype];
338 }
339 if ($vtype === '20') { // Boolean
340 $cell = $cell == 'TRUE';
341 }
342 }
343 $this->spreadsheet->getActiveSheet()->getCell($column . $row)->setValueExplicit((string) $cell, $type);
344 }
345
346 if ($sheet->Styles !== null) {
347 (new Styles($this->spreadsheet, $this->readDataOnly))->read($sheet, $maxRow, $maxCol);
348 }
349
350 $this->processComments($sheet);
351 $this->processColumnWidths($sheet, $maxCol);
352 $this->processRowHeights($sheet, $maxRow);
353 $this->processMergedCells($sheet);
354 $this->processAutofilter($sheet);
355
356 ++$worksheetID;
357 }
358
359 $this->processDefinedNames($gnmXML);
360
361 // Return
362 return $this->spreadsheet;
363 }
processColumnWidths(?SimpleXMLElement $sheet, int $maxCol)
Definition: Gnumeric.php:429
processDefinedNames(?SimpleXMLElement $gnmXML)
Definition: Gnumeric.php:511
processComments(SimpleXMLElement $sheet)
Definition: Gnumeric.php:212
processRowHeights(?SimpleXMLElement $sheet, int $maxRow)
Definition: Gnumeric.php:487
processMergedCells(?SimpleXMLElement $sheet)
Definition: Gnumeric.php:365
processAutofilter(?SimpleXMLElement $sheet)
Definition: Gnumeric.php:377
if(!file_exists(getcwd() . '/ilias.ini.php'))
registration confirmation script for ilias
Definition: confirmReg.php:12
$row
$type

References $row, PhpOffice\PhpSpreadsheet\Reader\Gnumeric\$spreadsheet, $type, $xml, PhpOffice\PhpSpreadsheet\Shared\File\assertFile(), PhpOffice\PhpSpreadsheet\Settings\getLibXmlLoaderOptions(), PhpOffice\PhpSpreadsheet\Reader\BaseReader\getReadFilter(), PhpOffice\PhpSpreadsheet\Reader\Gnumeric\gzfileGetContents(), if, PhpOffice\PhpSpreadsheet\Reader\Gnumeric\processAutofilter(), PhpOffice\PhpSpreadsheet\Reader\Gnumeric\processColumnWidths(), PhpOffice\PhpSpreadsheet\Reader\Gnumeric\processComments(), PhpOffice\PhpSpreadsheet\Reader\Gnumeric\processDefinedNames(), PhpOffice\PhpSpreadsheet\Reader\Gnumeric\processMergedCells(), PhpOffice\PhpSpreadsheet\Reader\Gnumeric\processRowHeights(), PhpOffice\PhpSpreadsheet\Cell\Coordinate\stringFromColumnIndex(), PhpOffice\PhpSpreadsheet\Reader\Gnumeric\testSimpleXml(), and PhpOffice\PhpSpreadsheet\Cell\DataType\TYPE_FORMULA.

Referenced by PhpOffice\PhpSpreadsheet\Reader\Gnumeric\load().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ matchXml()

static PhpOffice\PhpSpreadsheet\Reader\Gnumeric::matchXml ( XMLReader  $xml,
string  $expectedLocalName 
)
staticprivate

Definition at line 103 of file Gnumeric.php.

103 : bool
104 {
105 return $xml->namespaceURI === self::NAMESPACE_GNM
106 && $xml->localName === $expectedLocalName
107 && $xml->nodeType === XMLReader::ELEMENT;
108 }

References $xml.

◆ parseRichText()

PhpOffice\PhpSpreadsheet\Reader\Gnumeric::parseRichText ( string  $is)
private

Definition at line 533 of file Gnumeric.php.

533 : RichText
534 {
535 $value = new RichText();
536 $value->createText($is);
537
538 return $value;
539 }

Referenced by PhpOffice\PhpSpreadsheet\Reader\Gnumeric\processComments().

+ Here is the caller graph for this function:

◆ processAutofilter()

PhpOffice\PhpSpreadsheet\Reader\Gnumeric::processAutofilter ( ?SimpleXMLElement  $sheet)
private

Definition at line 377 of file Gnumeric.php.

377 : void
378 {
379 if ($sheet !== null && isset($sheet->Filters)) {
380 foreach ($sheet->Filters->Filter as $autofilter) {
381 if ($autofilter !== null) {
382 $attributes = $autofilter->attributes();
383 if (isset($attributes['Area'])) {
384 $this->spreadsheet->getActiveSheet()->setAutoFilter((string) $attributes['Area']);
385 }
386 }
387 }
388 }
389 }
if(array_key_exists('yes', $_REQUEST)) $attributes
Definition: getconsent.php:85

References $attributes.

Referenced by PhpOffice\PhpSpreadsheet\Reader\Gnumeric\loadIntoExisting().

+ Here is the caller graph for this function:

◆ processColumnLoop()

PhpOffice\PhpSpreadsheet\Reader\Gnumeric::processColumnLoop ( int  $whichColumn,
int  $maxCol,
SimpleXMLElement  $columnOverride,
float  $defaultWidth 
)
private

Definition at line 407 of file Gnumeric.php.

407 : int
408 {
409 $columnAttributes = self::testSimpleXml($columnOverride->attributes());
410 $column = $columnAttributes['No'];
411 $columnWidth = ((float) $columnAttributes['Unit']) / 5.4;
412 $hidden = (isset($columnAttributes['Hidden'])) && ((string) $columnAttributes['Hidden'] == '1');
413 $columnCount = (int) ($columnAttributes['Count'] ?? 1);
414 while ($whichColumn < $column) {
415 $this->setColumnWidth($whichColumn, $defaultWidth);
416 ++$whichColumn;
417 }
418 while (($whichColumn < ($column + $columnCount)) && ($whichColumn <= $maxCol)) {
419 $this->setColumnWidth($whichColumn, $columnWidth);
420 if ($hidden) {
421 $this->setColumnInvisible($whichColumn);
422 }
423 ++$whichColumn;
424 }
425
426 return $whichColumn;
427 }
setColumnWidth(int $whichColumn, float $defaultWidth)
Definition: Gnumeric.php:391
if(! $row) $columnCount

References $columnCount, PhpOffice\PhpSpreadsheet\Reader\Gnumeric\setColumnInvisible(), PhpOffice\PhpSpreadsheet\Reader\Gnumeric\setColumnWidth(), and PhpOffice\PhpSpreadsheet\Reader\Gnumeric\testSimpleXml().

Referenced by PhpOffice\PhpSpreadsheet\Reader\Gnumeric\processColumnWidths().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ processColumnWidths()

PhpOffice\PhpSpreadsheet\Reader\Gnumeric::processColumnWidths ( ?SimpleXMLElement  $sheet,
int  $maxCol 
)
private

Definition at line 429 of file Gnumeric.php.

429 : void
430 {
431 if ((!$this->readDataOnly) && $sheet !== null && (isset($sheet->Cols))) {
432 // Column Widths
433 $defaultWidth = 0;
434 $columnAttributes = $sheet->Cols->attributes();
435 if ($columnAttributes !== null) {
436 $defaultWidth = $columnAttributes['DefaultSizePts'] / 5.4;
437 }
438 $whichColumn = 0;
439 foreach ($sheet->Cols->ColInfo as $columnOverride) {
440 $whichColumn = $this->processColumnLoop($whichColumn, $maxCol, $columnOverride, $defaultWidth);
441 }
442 while ($whichColumn <= $maxCol) {
443 $this->setColumnWidth($whichColumn, $defaultWidth);
444 ++$whichColumn;
445 }
446 }
447 }
processColumnLoop(int $whichColumn, int $maxCol, SimpleXMLElement $columnOverride, float $defaultWidth)
Definition: Gnumeric.php:407

References PhpOffice\PhpSpreadsheet\Reader\Gnumeric\processColumnLoop(), and PhpOffice\PhpSpreadsheet\Reader\Gnumeric\setColumnWidth().

Referenced by PhpOffice\PhpSpreadsheet\Reader\Gnumeric\loadIntoExisting().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ processComments()

PhpOffice\PhpSpreadsheet\Reader\Gnumeric::processComments ( SimpleXMLElement  $sheet)
private

Definition at line 212 of file Gnumeric.php.

212 : void
213 {
214 if ((!$this->readDataOnly) && (isset($sheet->Objects))) {
215 foreach ($sheet->Objects->children(self::NAMESPACE_GNM) as $key => $comment) {
216 $commentAttributes = $comment->attributes();
217 // Only comment objects are handled at the moment
218 if ($commentAttributes->Text) {
219 $this->spreadsheet->getActiveSheet()->getComment((string) $commentAttributes->ObjectBound)
220 ->setAuthor((string) $commentAttributes->Author)
221 ->setText($this->parseRichText((string) $commentAttributes->Text));
222 }
223 }
224 }
225 }
$comment
Definition: buildRTE.php:83
$key
Definition: croninfo.php:18

References $comment, $key, and PhpOffice\PhpSpreadsheet\Reader\Gnumeric\parseRichText().

Referenced by PhpOffice\PhpSpreadsheet\Reader\Gnumeric\loadIntoExisting().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ processDefinedNames()

PhpOffice\PhpSpreadsheet\Reader\Gnumeric::processDefinedNames ( ?SimpleXMLElement  $gnmXML)
private

Definition at line 511 of file Gnumeric.php.

511 : void
512 {
513 // Loop through definedNames (global named ranges)
514 if ($gnmXML !== null && isset($gnmXML->Names)) {
515 foreach ($gnmXML->Names->Name as $definedName) {
516 $name = (string) $definedName->name;
517 $value = (string) $definedName->value;
518 if (stripos($value, '#REF!') !== false) {
519 continue;
520 }
521
522 [$worksheetName] = Worksheet::extractSheetTitle($value, true);
523 $worksheetName = trim($worksheetName, "'");
524 $worksheet = $this->spreadsheet->getSheetByName($worksheetName);
525 // Worksheet might still be null if we're only loading selected sheets rather than the full spreadsheet
526 if ($worksheet !== null) {
527 $this->spreadsheet->addDefinedName(DefinedName::createInstance($name, $worksheet, $value));
528 }
529 }
530 }
531 }
static createInstance(string $name, ?Worksheet $worksheet=null, ?string $value=null, bool $localOnly=false, ?Worksheet $scope=null)
Create a new defined name, either a range or a formula.
Definition: DefinedName.php:84

References $name, and PhpOffice\PhpSpreadsheet\DefinedName\createInstance().

Referenced by PhpOffice\PhpSpreadsheet\Reader\Gnumeric\loadIntoExisting().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ processMergedCells()

PhpOffice\PhpSpreadsheet\Reader\Gnumeric::processMergedCells ( ?SimpleXMLElement  $sheet)
private

Definition at line 365 of file Gnumeric.php.

365 : void
366 {
367 // Handle Merged Cells in this worksheet
368 if ($sheet !== null && isset($sheet->MergedRegions)) {
369 foreach ($sheet->MergedRegions->Merge as $mergeCells) {
370 if (strpos($mergeCells, ':') !== false) {
371 $this->spreadsheet->getActiveSheet()->mergeCells($mergeCells);
372 }
373 }
374 }
375 }

Referenced by PhpOffice\PhpSpreadsheet\Reader\Gnumeric\loadIntoExisting().

+ Here is the caller graph for this function:

◆ processRowHeights()

PhpOffice\PhpSpreadsheet\Reader\Gnumeric::processRowHeights ( ?SimpleXMLElement  $sheet,
int  $maxRow 
)
private

Definition at line 487 of file Gnumeric.php.

487 : void
488 {
489 if ((!$this->readDataOnly) && $sheet !== null && (isset($sheet->Rows))) {
490 // Row Heights
491 $defaultHeight = 0;
492 $rowAttributes = $sheet->Rows->attributes();
493 if ($rowAttributes !== null) {
494 $defaultHeight = (float) $rowAttributes['DefaultSizePts'];
495 }
496 $whichRow = 0;
497
498 foreach ($sheet->Rows->RowInfo as $rowOverride) {
499 $whichRow = $this->processRowLoop($whichRow, $maxRow, $rowOverride, $defaultHeight);
500 }
501 // never executed, I can't figure out any circumstances
502 // under which it would be executed, and, even if
503 // such exist, I'm not convinced this is needed.
504 //while ($whichRow < $maxRow) {
505 // ++$whichRow;
506 // $this->spreadsheet->getActiveSheet()->getRowDimension($whichRow)->setRowHeight($defaultHeight);
507 //}
508 }
509 }
processRowLoop(int $whichRow, int $maxRow, SimpleXMLElement $rowOverride, float $defaultHeight)
Definition: Gnumeric.php:465

References PhpOffice\PhpSpreadsheet\Reader\Gnumeric\processRowLoop().

Referenced by PhpOffice\PhpSpreadsheet\Reader\Gnumeric\loadIntoExisting().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ processRowLoop()

PhpOffice\PhpSpreadsheet\Reader\Gnumeric::processRowLoop ( int  $whichRow,
int  $maxRow,
SimpleXMLElement  $rowOverride,
float  $defaultHeight 
)
private

Definition at line 465 of file Gnumeric.php.

465 : int
466 {
467 $rowAttributes = self::testSimpleXml($rowOverride->attributes());
468 $row = $rowAttributes['No'];
469 $rowHeight = (float) $rowAttributes['Unit'];
470 $hidden = (isset($rowAttributes['Hidden'])) && ((string) $rowAttributes['Hidden'] == '1');
471 $rowCount = (int) ($rowAttributes['Count'] ?? 1);
472 while ($whichRow < $row) {
473 ++$whichRow;
474 $this->setRowHeight($whichRow, $defaultHeight);
475 }
476 while (($whichRow < ($row + $rowCount)) && ($whichRow < $maxRow)) {
477 ++$whichRow;
478 $this->setRowHeight($whichRow, $rowHeight);
479 if ($hidden) {
480 $this->setRowInvisible($whichRow);
481 }
482 }
483
484 return $whichRow;
485 }
setRowHeight(int $whichRow, float $defaultHeight)
Definition: Gnumeric.php:449

References $row, PhpOffice\PhpSpreadsheet\Reader\Gnumeric\setRowHeight(), PhpOffice\PhpSpreadsheet\Reader\Gnumeric\setRowInvisible(), and PhpOffice\PhpSpreadsheet\Reader\Gnumeric\testSimpleXml().

Referenced by PhpOffice\PhpSpreadsheet\Reader\Gnumeric\processRowHeights().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setColumnInvisible()

PhpOffice\PhpSpreadsheet\Reader\Gnumeric::setColumnInvisible ( int  $whichColumn)
private

Definition at line 399 of file Gnumeric.php.

399 : void
400 {
401 $columnDimension = $this->spreadsheet->getActiveSheet()->getColumnDimension(Coordinate::stringFromColumnIndex($whichColumn + 1));
402 if ($columnDimension !== null) {
403 $columnDimension->setVisible(false);
404 }
405 }

References PhpOffice\PhpSpreadsheet\Cell\Coordinate\stringFromColumnIndex().

Referenced by PhpOffice\PhpSpreadsheet\Reader\Gnumeric\processColumnLoop().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setColumnWidth()

PhpOffice\PhpSpreadsheet\Reader\Gnumeric::setColumnWidth ( int  $whichColumn,
float  $defaultWidth 
)
private

Definition at line 391 of file Gnumeric.php.

391 : void
392 {
393 $columnDimension = $this->spreadsheet->getActiveSheet()->getColumnDimension(Coordinate::stringFromColumnIndex($whichColumn + 1));
394 if ($columnDimension !== null) {
395 $columnDimension->setWidth($defaultWidth);
396 }
397 }

References PhpOffice\PhpSpreadsheet\Cell\Coordinate\stringFromColumnIndex().

Referenced by PhpOffice\PhpSpreadsheet\Reader\Gnumeric\processColumnLoop(), and PhpOffice\PhpSpreadsheet\Reader\Gnumeric\processColumnWidths().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setRowHeight()

PhpOffice\PhpSpreadsheet\Reader\Gnumeric::setRowHeight ( int  $whichRow,
float  $defaultHeight 
)
private

Definition at line 449 of file Gnumeric.php.

449 : void
450 {
451 $rowDimension = $this->spreadsheet->getActiveSheet()->getRowDimension($whichRow);
452 if ($rowDimension !== null) {
453 $rowDimension->setRowHeight($defaultHeight);
454 }
455 }

Referenced by PhpOffice\PhpSpreadsheet\Reader\Gnumeric\processRowLoop().

+ Here is the caller graph for this function:

◆ setRowInvisible()

PhpOffice\PhpSpreadsheet\Reader\Gnumeric::setRowInvisible ( int  $whichRow)
private

Definition at line 457 of file Gnumeric.php.

457 : void
458 {
459 $rowDimension = $this->spreadsheet->getActiveSheet()->getRowDimension($whichRow);
460 if ($rowDimension !== null) {
461 $rowDimension->setVisible(false);
462 }
463 }

Referenced by PhpOffice\PhpSpreadsheet\Reader\Gnumeric\processRowLoop().

+ Here is the caller graph for this function:

◆ testSimpleXml()

static PhpOffice\PhpSpreadsheet\Reader\Gnumeric::testSimpleXml (   $value)
staticprivate
Parameters
mixed$value

Definition at line 230 of file Gnumeric.php.

230 : SimpleXMLElement
231 {
232 return ($value instanceof SimpleXMLElement) ? $value : new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><root></root>');
233 }

Referenced by PhpOffice\PhpSpreadsheet\Reader\Gnumeric\loadIntoExisting(), PhpOffice\PhpSpreadsheet\Reader\Gnumeric\processColumnLoop(), and PhpOffice\PhpSpreadsheet\Reader\Gnumeric\processRowLoop().

+ Here is the caller graph for this function:

Field Documentation

◆ $expressions

PhpOffice\PhpSpreadsheet\Reader\Gnumeric::$expressions = []
private

Definition at line 42 of file Gnumeric.php.

◆ $mappings

PhpOffice\PhpSpreadsheet\Reader\Gnumeric::$mappings
static

◆ $referenceHelper

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

Definition at line 52 of file Gnumeric.php.

◆ $spreadsheet

PhpOffice\PhpSpreadsheet\Reader\Gnumeric::$spreadsheet
private

◆ NAMESPACE_DC

const PhpOffice\PhpSpreadsheet\Reader\Gnumeric::NAMESPACE_DC = 'http://purl.org/dc/elements/1.1/'

◆ NAMESPACE_GNM

const PhpOffice\PhpSpreadsheet\Reader\Gnumeric::NAMESPACE_GNM = 'http://www.gnumeric.org/v10.dtd'

◆ NAMESPACE_META

const PhpOffice\PhpSpreadsheet\Reader\Gnumeric::NAMESPACE_META = 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0'

◆ NAMESPACE_OFFICE

const PhpOffice\PhpSpreadsheet\Reader\Gnumeric::NAMESPACE_OFFICE = 'urn:oasis:names:tc:opendocument:xmlns:office:1.0'

◆ NAMESPACE_OOO

const PhpOffice\PhpSpreadsheet\Reader\Gnumeric::NAMESPACE_OOO = 'http://openoffice.org/2004/office'

Definition at line 35 of file Gnumeric.php.

◆ NAMESPACE_XLINK

const PhpOffice\PhpSpreadsheet\Reader\Gnumeric::NAMESPACE_XLINK = 'http://www.w3.org/1999/xlink'

Definition at line 29 of file Gnumeric.php.

◆ NAMESPACE_XSI

const PhpOffice\PhpSpreadsheet\Reader\Gnumeric::NAMESPACE_XSI = 'http://www.w3.org/2001/XMLSchema-instance'

Definition at line 25 of file Gnumeric.php.


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