ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
PHPExcel_Reader_OOCalc Class Reference
+ Inheritance diagram for PHPExcel_Reader_OOCalc:
+ Collaboration diagram for PHPExcel_Reader_OOCalc:

Public Member Functions

 __construct ()
 Create a new PHPExcel_Reader_OOCalc. More...
 
 canRead ($pFilename)
 Can the current PHPExcel_Reader_IReader read the file? More...
 
 listWorksheetNames ($pFilename)
 Reads names of the worksheets from a file, without parsing the whole file to a PHPExcel object. More...
 
 listWorksheetInfo ($pFilename)
 Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns) More...
 
 load ($pFilename)
 Loads PHPExcel from file. More...
 
 loadIntoExisting ($pFilename, PHPExcel $objPHPExcel)
 Loads PHPExcel from file into PHPExcel instance. More...
 
- Public Member Functions inherited from PHPExcel_Reader_Abstract
 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=FALSE)
 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...
 
 getIncludeCharts ()
 Read charts in workbook? If this is true, then the Reader will include any charts that exist in the workbook. More...
 
 setIncludeCharts ($pValue=FALSE)
 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=NULL)
 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 (PHPExcel_Reader_IReadFilter $pValue)
 Set read filter. More...
 
 canRead ($pFilename)
 Can the current PHPExcel_Reader_IReader read the file? More...
 
 securityScan ($xml)
 Scan theXML for use of <!ENTITY to prevent XXE/XEE attacks. More...
 
 securityScanFile ($filestream)
 Scan theXML for use of <!ENTITY to prevent XXE/XEE attacks. More...
 
 canRead ($pFilename)
 Can the current PHPExcel_Reader_IReader read the file? More...
 
 load ($pFilename)
 

Private Member Functions

 _parseRichText ($is='')
 

Static Private Member Functions

static identifyFixedStyleValue ($styleList, &$styleAttributeValue)
 

Private Attributes

 $_styles = array()
 

Additional Inherited Members

- Protected Member Functions inherited from PHPExcel_Reader_Abstract
 _openFile ($pFilename)
 Open file for reading. More...
 
- Protected Attributes inherited from PHPExcel_Reader_Abstract
 $_readDataOnly = FALSE
 
 $_includeCharts = FALSE
 
 $_loadSheetsOnly = NULL
 
 $_readFilter = NULL
 
 $_fileHandle = NULL
 

Detailed Description

Definition at line 45 of file OOCalc.php.

Constructor & Destructor Documentation

◆ __construct()

PHPExcel_Reader_OOCalc::__construct ( )

Create a new PHPExcel_Reader_OOCalc.

Definition at line 58 of file OOCalc.php.

Member Function Documentation

◆ _parseRichText()

PHPExcel_Reader_OOCalc::_parseRichText (   $is = '')
private

Definition at line 703 of file OOCalc.php.

703 {
704 $value = new PHPExcel_RichText();
705
706 $value->createText($is);
707
708 return $value;
709 }

◆ canRead()

PHPExcel_Reader_OOCalc::canRead (   $pFilename)

Can the current PHPExcel_Reader_IReader read the file?

Parameters
string$pFilename
Returns
boolean
Exceptions
PHPExcel_Reader_Exception

Reimplemented from PHPExcel_Reader_Abstract.

Definition at line 70 of file OOCalc.php.

71 {
72 // Check if file exists
73 if (!file_exists($pFilename)) {
74 throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
75 }
76
78
79 // Check if zip class exists
80// if (!class_exists($zipClass, FALSE)) {
81// throw new PHPExcel_Reader_Exception($zipClass . " library is not enabled");
82// }
83
84 $mimeType = 'UNKNOWN';
85 // Load file
86 $zip = new $zipClass;
87 if ($zip->open($pFilename) === true) {
88 // check if it is an OOXML archive
89 $stat = $zip->statName('mimetype');
90 if ($stat && ($stat['size'] <= 255)) {
91 $mimeType = $zip->getFromName($stat['name']);
92 } elseif($stat = $zip->statName('META-INF/manifest.xml')) {
93 $xml = simplexml_load_string($this->securityScan($zip->getFromName('META-INF/manifest.xml')), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions());
94 $namespacesContent = $xml->getNamespaces(true);
95 if (isset($namespacesContent['manifest'])) {
96 $manifest = $xml->children($namespacesContent['manifest']);
97 foreach($manifest as $manifestDataSet) {
98 $manifestAttributes = $manifestDataSet->attributes($namespacesContent['manifest']);
99 if ($manifestAttributes->{'full-path'} == '/') {
100 $mimeType = (string) $manifestAttributes->{'media-type'};
101 break;
102 }
103 }
104 }
105 }
106
107 $zip->close();
108
109 return ($mimeType === 'application/vnd.oasis.opendocument.spreadsheet');
110 }
111
112 return FALSE;
113 }
securityScan($xml)
Scan theXML for use of <!ENTITY to prevent XXE/XEE attacks.
Definition: Abstract.php:236
static getZipClass()
Return the name of the Zip handler Class that PHPExcel is configured to use (PCLZip or ZipArchive) or...
Definition: Settings.php:141
static getLibXmlLoaderOptions()
Get default options for libxml loader.
Definition: Settings.php:381

References PHPExcel_Settings\getLibXmlLoaderOptions(), PHPExcel_Settings\getZipClass(), and PHPExcel_Reader_Abstract\securityScan().

+ Here is the call graph for this function:

◆ identifyFixedStyleValue()

static PHPExcel_Reader_OOCalc::identifyFixedStyleValue (   $styleList,
$styleAttributeValue 
)
staticprivate

Definition at line 310 of file OOCalc.php.

310 {
311 $styleAttributeValue = strtolower($styleAttributeValue);
312 foreach($styleList as $style) {
313 if ($styleAttributeValue == strtolower($style)) {
314 $styleAttributeValue = $style;
315 return true;
316 }
317 }
318 return false;
319 }
$style
Definition: example_012.php:70

References $style.

◆ listWorksheetInfo()

PHPExcel_Reader_OOCalc::listWorksheetInfo (   $pFilename)

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

Parameters
string$pFilename
Exceptions
PHPExcel_Reader_Exception

Definition at line 174 of file OOCalc.php.

175 {
176 // Check if file exists
177 if (!file_exists($pFilename)) {
178 throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
179 }
180
181 $worksheetInfo = array();
182
183 $zipClass = PHPExcel_Settings::getZipClass();
184
185 $zip = new $zipClass;
186 if (!$zip->open($pFilename)) {
187 throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! Error opening file.");
188 }
189
190 $xml = new XMLReader();
191 $res = $xml->xml($this->securityScanFile('zip://'.realpath($pFilename).'#content.xml'), null, PHPExcel_Settings::getLibXmlLoaderOptions());
192 $xml->setParserProperty(2,true);
193
194 // Step into the first level of content of the XML
195 $xml->read();
196 while ($xml->read()) {
197 // Quickly jump through to the office:body node
198 while ($xml->name !== 'office:body') {
199 if ($xml->isEmptyElement)
200 $xml->read();
201 else
202 $xml->next();
203 }
204 // Now read each node until we find our first table:table node
205 while ($xml->read()) {
206 if ($xml->name == 'table:table' && $xml->nodeType == XMLReader::ELEMENT) {
207 $worksheetNames[] = $xml->getAttribute('table:name');
208
209 $tmpInfo = array(
210 'worksheetName' => $xml->getAttribute('table:name'),
211 'lastColumnLetter' => 'A',
212 'lastColumnIndex' => 0,
213 'totalRows' => 0,
214 'totalColumns' => 0,
215 );
216
217 // Loop through each child node of the table:table element reading
218 $currCells = 0;
219 do {
220 $xml->read();
221 if ($xml->name == 'table:table-row' && $xml->nodeType == XMLReader::ELEMENT) {
222 $rowspan = $xml->getAttribute('table:number-rows-repeated');
223 $rowspan = empty($rowspan) ? 1 : $rowspan;
224 $tmpInfo['totalRows'] += $rowspan;
225 $tmpInfo['totalColumns'] = max($tmpInfo['totalColumns'],$currCells);
226 $currCells = 0;
227 // Step into the row
228 $xml->read();
229 do {
230 if ($xml->name == 'table:table-cell' && $xml->nodeType == XMLReader::ELEMENT) {
231 if (!$xml->isEmptyElement) {
232 $currCells++;
233 $xml->next();
234 } else {
235 $xml->read();
236 }
237 } elseif ($xml->name == 'table:covered-table-cell' && $xml->nodeType == XMLReader::ELEMENT) {
238 $mergeSize = $xml->getAttribute('table:number-columns-repeated');
239 $currCells += $mergeSize;
240 $xml->read();
241 }
242 } while ($xml->name != 'table:table-row');
243 }
244 } while ($xml->name != 'table:table');
245
246 $tmpInfo['totalColumns'] = max($tmpInfo['totalColumns'],$currCells);
247 $tmpInfo['lastColumnIndex'] = $tmpInfo['totalColumns'] - 1;
248 $tmpInfo['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($tmpInfo['lastColumnIndex']);
249 $worksheetInfo[] = $tmpInfo;
250 }
251 }
252
253// foreach($workbookData->table as $worksheetDataSet) {
254// $worksheetData = $worksheetDataSet->children($namespacesContent['table']);
255// $worksheetDataAttributes = $worksheetDataSet->attributes($namespacesContent['table']);
256//
257// $rowIndex = 0;
258// foreach ($worksheetData as $key => $rowData) {
259// switch ($key) {
260// case 'table-row' :
261// $rowDataTableAttributes = $rowData->attributes($namespacesContent['table']);
262// $rowRepeats = (isset($rowDataTableAttributes['number-rows-repeated'])) ?
263// $rowDataTableAttributes['number-rows-repeated'] : 1;
264// $columnIndex = 0;
265//
266// foreach ($rowData as $key => $cellData) {
267// $cellDataTableAttributes = $cellData->attributes($namespacesContent['table']);
268// $colRepeats = (isset($cellDataTableAttributes['number-columns-repeated'])) ?
269// $cellDataTableAttributes['number-columns-repeated'] : 1;
270// $cellDataOfficeAttributes = $cellData->attributes($namespacesContent['office']);
271// if (isset($cellDataOfficeAttributes['value-type'])) {
272// $tmpInfo['lastColumnIndex'] = max($tmpInfo['lastColumnIndex'], $columnIndex + $colRepeats - 1);
273// $tmpInfo['totalRows'] = max($tmpInfo['totalRows'], $rowIndex + $rowRepeats);
274// }
275// $columnIndex += $colRepeats;
276// }
277// $rowIndex += $rowRepeats;
278// break;
279// }
280// }
281//
282// $tmpInfo['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($tmpInfo['lastColumnIndex']);
283// $tmpInfo['totalColumns'] = $tmpInfo['lastColumnIndex'] + 1;
284//
285// }
286// }
287 }
288
289 return $worksheetInfo;
290 }
static stringFromColumnIndex($pColumnIndex=0)
String from columnindex.
Definition: Cell.php:825
securityScanFile($filestream)
Scan theXML for use of <!ENTITY to prevent XXE/XEE attacks.
Definition: Abstract.php:251

References $res, PHPExcel_Settings\getLibXmlLoaderOptions(), PHPExcel_Settings\getZipClass(), and PHPExcel_Cell\stringFromColumnIndex().

+ Here is the call graph for this function:

◆ listWorksheetNames()

PHPExcel_Reader_OOCalc::listWorksheetNames (   $pFilename)

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

Parameters
string$pFilename
Exceptions
PHPExcel_Reader_Exception

Definition at line 122 of file OOCalc.php.

123 {
124 // Check if file exists
125 if (!file_exists($pFilename)) {
126 throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
127 }
128
129 $zipClass = PHPExcel_Settings::getZipClass();
130
131 $zip = new $zipClass;
132 if (!$zip->open($pFilename)) {
133 throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! Error opening file.");
134 }
135
136 $worksheetNames = array();
137
138 $xml = new XMLReader();
139 $res = $xml->xml($this->securityScanFile('zip://'.realpath($pFilename).'#content.xml'), null, PHPExcel_Settings::getLibXmlLoaderOptions());
140 $xml->setParserProperty(2,true);
141
142 // Step into the first level of content of the XML
143 $xml->read();
144 while ($xml->read()) {
145 // Quickly jump through to the office:body node
146 while ($xml->name !== 'office:body') {
147 if ($xml->isEmptyElement)
148 $xml->read();
149 else
150 $xml->next();
151 }
152 // Now read each node until we find our first table:table node
153 while ($xml->read()) {
154 if ($xml->name == 'table:table' && $xml->nodeType == XMLReader::ELEMENT) {
155 // Loop through each table:table node reading the table:name attribute for each worksheet name
156 do {
157 $worksheetNames[] = $xml->getAttribute('table:name');
158 $xml->next();
159 } while ($xml->name == 'table:table' && $xml->nodeType == XMLReader::ELEMENT);
160 }
161 }
162 }
163
164 return $worksheetNames;
165 }

References $res, PHPExcel_Settings\getLibXmlLoaderOptions(), and PHPExcel_Settings\getZipClass().

+ Here is the call graph for this function:

◆ load()

PHPExcel_Reader_OOCalc::load (   $pFilename)

Loads PHPExcel from file.

Parameters
string$pFilename
Returns
PHPExcel
Exceptions
PHPExcel_Reader_Exception

Implements PHPExcel_Reader_IReader.

Definition at line 300 of file OOCalc.php.

301 {
302 // Create new PHPExcel
303 $objPHPExcel = new PHPExcel();
304
305 // Load into this instance
306 return $this->loadIntoExisting($pFilename, $objPHPExcel);
307 }
$objPHPExcel
loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
Loads PHPExcel from file into PHPExcel instance.
Definition: OOCalc.php:330

References $objPHPExcel.

◆ loadIntoExisting()

PHPExcel_Reader_OOCalc::loadIntoExisting (   $pFilename,
PHPExcel  $objPHPExcel 
)

Loads PHPExcel from file into PHPExcel instance.

Parameters
string$pFilename
PHPExcel$objPHPExcel
Returns
PHPExcel
Exceptions
PHPExcel_Reader_Exception

Definition at line 330 of file OOCalc.php.

331 {
332 // Check if file exists
333 if (!file_exists($pFilename)) {
334 throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
335 }
336
337 $timezoneObj = new DateTimeZone('Europe/London');
338 $GMT = new DateTimeZone('UTC');
339
340 $zipClass = PHPExcel_Settings::getZipClass();
341
342 $zip = new $zipClass;
343 if (!$zip->open($pFilename)) {
344 throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! Error opening file.");
345 }
346
347// echo '<h1>Meta Information</h1>';
348 $xml = simplexml_load_string($this->securityScan($zip->getFromName("meta.xml")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions());
349 $namespacesMeta = $xml->getNamespaces(true);
350// echo '<pre>';
351// print_r($namespacesMeta);
352// echo '</pre><hr />';
353
354 $docProps = $objPHPExcel->getProperties();
355 $officeProperty = $xml->children($namespacesMeta['office']);
356 foreach($officeProperty as $officePropertyData) {
357 $officePropertyDC = array();
358 if (isset($namespacesMeta['dc'])) {
359 $officePropertyDC = $officePropertyData->children($namespacesMeta['dc']);
360 }
361 foreach($officePropertyDC as $propertyName => $propertyValue) {
362 $propertyValue = (string) $propertyValue;
363 switch ($propertyName) {
364 case 'title' :
365 $docProps->setTitle($propertyValue);
366 break;
367 case 'subject' :
368 $docProps->setSubject($propertyValue);
369 break;
370 case 'creator' :
371 $docProps->setCreator($propertyValue);
372 $docProps->setLastModifiedBy($propertyValue);
373 break;
374 case 'date' :
375 $creationDate = strtotime($propertyValue);
376 $docProps->setCreated($creationDate);
377 $docProps->setModified($creationDate);
378 break;
379 case 'description' :
380 $docProps->setDescription($propertyValue);
381 break;
382 }
383 }
384 $officePropertyMeta = array();
385 if (isset($namespacesMeta['dc'])) {
386 $officePropertyMeta = $officePropertyData->children($namespacesMeta['meta']);
387 }
388 foreach($officePropertyMeta as $propertyName => $propertyValue) {
389 $propertyValueAttributes = $propertyValue->attributes($namespacesMeta['meta']);
390 $propertyValue = (string) $propertyValue;
391 switch ($propertyName) {
392 case 'initial-creator' :
393 $docProps->setCreator($propertyValue);
394 break;
395 case 'keyword' :
396 $docProps->setKeywords($propertyValue);
397 break;
398 case 'creation-date' :
399 $creationDate = strtotime($propertyValue);
400 $docProps->setCreated($creationDate);
401 break;
402 case 'user-defined' :
404 foreach ($propertyValueAttributes as $key => $value) {
405 if ($key == 'name') {
406 $propertyValueName = (string) $value;
407 } elseif($key == 'value-type') {
408 switch ($value) {
409 case 'date' :
410 $propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue,'date');
412 break;
413 case 'boolean' :
414 $propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue,'bool');
416 break;
417 case 'float' :
418 $propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue,'r4');
420 break;
421 default :
423 }
424 }
425 }
426 $docProps->setCustomProperty($propertyValueName,$propertyValue,$propertyValueType);
427 break;
428 }
429 }
430 }
431
432
433// echo '<h1>Workbook Content</h1>';
434 $xml = simplexml_load_string($this->securityScan($zip->getFromName("content.xml")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions());
435 $namespacesContent = $xml->getNamespaces(true);
436// echo '<pre>';
437// print_r($namespacesContent);
438// echo '</pre><hr />';
439
440 $workbook = $xml->children($namespacesContent['office']);
441 foreach($workbook->body->spreadsheet as $workbookData) {
442 $workbookData = $workbookData->children($namespacesContent['table']);
443 $worksheetID = 0;
444 foreach($workbookData->table as $worksheetDataSet) {
445 $worksheetData = $worksheetDataSet->children($namespacesContent['table']);
446// print_r($worksheetData);
447// echo '<br />';
448 $worksheetDataAttributes = $worksheetDataSet->attributes($namespacesContent['table']);
449// print_r($worksheetDataAttributes);
450// echo '<br />';
451 if ((isset($this->_loadSheetsOnly)) && (isset($worksheetDataAttributes['name'])) &&
452 (!in_array($worksheetDataAttributes['name'], $this->_loadSheetsOnly))) {
453 continue;
454 }
455
456// echo '<h2>Worksheet '.$worksheetDataAttributes['name'].'</h2>';
457 // Create new Worksheet
458 $objPHPExcel->createSheet();
459 $objPHPExcel->setActiveSheetIndex($worksheetID);
460 if (isset($worksheetDataAttributes['name'])) {
461 $worksheetName = (string) $worksheetDataAttributes['name'];
462 // Use false for $updateFormulaCellReferences to prevent adjustment of worksheet references in
463 // formula cells... during the load, all formulae should be correct, and we're simply
464 // bringing the worksheet name in line with the formula, not the reverse
465 $objPHPExcel->getActiveSheet()->setTitle($worksheetName,false);
466 }
467
468 $rowID = 1;
469 foreach($worksheetData as $key => $rowData) {
470// echo '<b>'.$key.'</b><br />';
471 switch ($key) {
472 case 'table-header-rows':
473 foreach ($rowData as $key=>$cellData) {
474 $rowData = $cellData;
475 break;
476 }
477 case 'table-row' :
478 $rowDataTableAttributes = $rowData->attributes($namespacesContent['table']);
479 $rowRepeats = (isset($rowDataTableAttributes['number-rows-repeated'])) ?
480 $rowDataTableAttributes['number-rows-repeated'] : 1;
481 $columnID = 'A';
482 foreach($rowData as $key => $cellData) {
483 if ($this->getReadFilter() !== NULL) {
484 if (!$this->getReadFilter()->readCell($columnID, $rowID, $worksheetName)) {
485 continue;
486 }
487 }
488
489// echo '<b>'.$columnID.$rowID.'</b><br />';
490 $cellDataText = (isset($namespacesContent['text'])) ?
491 $cellData->children($namespacesContent['text']) :
492 '';
493 $cellDataOffice = $cellData->children($namespacesContent['office']);
494 $cellDataOfficeAttributes = $cellData->attributes($namespacesContent['office']);
495 $cellDataTableAttributes = $cellData->attributes($namespacesContent['table']);
496
497// echo 'Office Attributes: ';
498// print_r($cellDataOfficeAttributes);
499// echo '<br />Table Attributes: ';
500// print_r($cellDataTableAttributes);
501// echo '<br />Cell Data Text';
502// print_r($cellDataText);
503// echo '<br />';
504//
505 $type = $formatting = $hyperlink = null;
506 $hasCalculatedValue = false;
507 $cellDataFormula = '';
508 if (isset($cellDataTableAttributes['formula'])) {
509 $cellDataFormula = $cellDataTableAttributes['formula'];
510 $hasCalculatedValue = true;
511 }
512
513 if (isset($cellDataOffice->annotation)) {
514// echo 'Cell has comment<br />';
515 $annotationText = $cellDataOffice->annotation->children($namespacesContent['text']);
516 $textArray = array();
517 foreach($annotationText as $t) {
518 if (isset($t->span)) {
519 foreach($t->span as $text) {
520 $textArray[] = (string)$text;
521 }
522 } else {
523 $textArray[] = (string) $t;
524 }
525 }
526 $text = implode("\n",$textArray);
527// echo $text,'<br />';
528 $objPHPExcel->getActiveSheet()->getComment( $columnID.$rowID )
529// ->setAuthor( $author )
530 ->setText($this->_parseRichText($text) );
531 }
532
533 if (isset($cellDataText->p)) {
534 // Consolidate if there are multiple p records (maybe with spans as well)
535 $dataArray = array();
536 // Text can have multiple text:p and within those, multiple text:span.
537 // text:p newlines, but text:span does not.
538 // Also, here we assume there is no text data is span fields are specified, since
539 // we have no way of knowing proper positioning anyway.
540 foreach ($cellDataText->p as $pData) {
541 if (isset($pData->span)) {
542 // span sections do not newline, so we just create one large string here
543 $spanSection = "";
544 foreach ($pData->span as $spanData) {
545 $spanSection .= $spanData;
546 }
547 array_push($dataArray, $spanSection);
548 } else {
549 array_push($dataArray, $pData);
550 }
551 }
552 $allCellDataText = implode($dataArray, "\n");
553
554// echo 'Value Type is '.$cellDataOfficeAttributes['value-type'].'<br />';
555 switch ($cellDataOfficeAttributes['value-type']) {
556 case 'string' :
558 $dataValue = $allCellDataText;
559 if (isset($dataValue->a)) {
560 $dataValue = $dataValue->a;
561 $cellXLinkAttributes = $dataValue->attributes($namespacesContent['xlink']);
562 $hyperlink = $cellXLinkAttributes['href'];
563 }
564 break;
565 case 'boolean' :
567 $dataValue = ($allCellDataText == 'TRUE') ? True : False;
568 break;
569 case 'percentage' :
571 $dataValue = (float) $cellDataOfficeAttributes['value'];
572 if (floor($dataValue) == $dataValue) {
573 $dataValue = (integer) $dataValue;
574 }
576 break;
577 case 'currency' :
579 $dataValue = (float) $cellDataOfficeAttributes['value'];
580 if (floor($dataValue) == $dataValue) {
581 $dataValue = (integer) $dataValue;
582 }
584 break;
585 case 'float' :
587 $dataValue = (float) $cellDataOfficeAttributes['value'];
588 if (floor($dataValue) == $dataValue) {
589 if ($dataValue == (integer) $dataValue)
590 $dataValue = (integer) $dataValue;
591 else
592 $dataValue = (float) $dataValue;
593 }
594 break;
595 case 'date' :
597 $dateObj = new DateTime($cellDataOfficeAttributes['date-value'], $GMT);
598 $dateObj->setTimeZone($timezoneObj);
599 list($year,$month,$day,$hour,$minute,$second) = explode(' ',$dateObj->format('Y m d H i s'));
600 $dataValue = PHPExcel_Shared_Date::FormattedPHPToExcel($year,$month,$day,$hour,$minute,$second);
601 if ($dataValue != floor($dataValue)) {
603 } else {
605 }
606 break;
607 case 'time' :
609 $dataValue = PHPExcel_Shared_Date::PHPToExcel(strtotime('01-01-1970 '.implode(':',sscanf($cellDataOfficeAttributes['time-value'],'PT%dH%dM%dS'))));
611 break;
612 }
613// echo 'Data value is '.$dataValue.'<br />';
614// if ($hyperlink !== NULL) {
615// echo 'Hyperlink is '.$hyperlink.'<br />';
616// }
617 } else {
619 $dataValue = NULL;
620 }
621
622 if ($hasCalculatedValue) {
624// echo 'Formula: ', $cellDataFormula, PHP_EOL;
625 $cellDataFormula = substr($cellDataFormula,strpos($cellDataFormula,':=')+1);
626 $temp = explode('"',$cellDataFormula);
627 $tKey = false;
628 foreach($temp as &$value) {
629 // Only replace in alternate array entries (i.e. non-quoted blocks)
630 if ($tKey = !$tKey) {
631 $value = preg_replace('/\[([^\.]+)\.([^\.]+):\.([^\.]+)\]/Ui','$1!$2:$3',$value); // Cell range reference in another sheet
632 $value = preg_replace('/\[([^\.]+)\.([^\.]+)\]/Ui','$1!$2',$value); // Cell reference in another sheet
633 $value = preg_replace('/\[\.([^\.]+):\.([^\.]+)\]/Ui','$1:$2',$value); // Cell range reference
634 $value = preg_replace('/\[\.([^\.]+)\]/Ui','$1',$value); // Simple cell reference
635 $value = PHPExcel_Calculation::_translateSeparator(';',',',$value,$inBraces);
636 }
637 }
638 unset($value);
639 // Then rebuild the formula string
640 $cellDataFormula = implode('"',$temp);
641// echo 'Adjusted Formula: ', $cellDataFormula, PHP_EOL;
642 }
643
644 $colRepeats = (isset($cellDataTableAttributes['number-columns-repeated'])) ?
645 $cellDataTableAttributes['number-columns-repeated'] : 1;
646 if ($type !== NULL) {
647 for ($i = 0; $i < $colRepeats; ++$i) {
648 if ($i > 0) {
649 ++$columnID;
650 }
651 if ($type !== PHPExcel_Cell_DataType::TYPE_NULL) {
652 for ($rowAdjust = 0; $rowAdjust < $rowRepeats; ++$rowAdjust) {
653 $rID = $rowID + $rowAdjust;
654 $objPHPExcel->getActiveSheet()->getCell($columnID.$rID)->setValueExplicit((($hasCalculatedValue) ? $cellDataFormula : $dataValue),$type);
655 if ($hasCalculatedValue) {
656// echo 'Forumla result is '.$dataValue.'<br />';
657 $objPHPExcel->getActiveSheet()->getCell($columnID.$rID)->setCalculatedValue($dataValue);
658 }
659 if ($formatting !== NULL) {
660 $objPHPExcel->getActiveSheet()->getStyle($columnID.$rID)->getNumberFormat()->setFormatCode($formatting);
661 } else {
662 $objPHPExcel->getActiveSheet()->getStyle($columnID.$rID)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_GENERAL);
663 }
664 if ($hyperlink !== NULL) {
665 $objPHPExcel->getActiveSheet()->getCell($columnID.$rID)->getHyperlink()->setUrl($hyperlink);
666 }
667 }
668 }
669 }
670 }
671
672 // Merged cells
673 if ((isset($cellDataTableAttributes['number-columns-spanned'])) || (isset($cellDataTableAttributes['number-rows-spanned']))) {
675 $columnTo = $columnID;
676 if (isset($cellDataTableAttributes['number-columns-spanned'])) {
677 $columnTo = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($columnID) + $cellDataTableAttributes['number-columns-spanned'] -2);
678 }
679 $rowTo = $rowID;
680 if (isset($cellDataTableAttributes['number-rows-spanned'])) {
681 $rowTo = $rowTo + $cellDataTableAttributes['number-rows-spanned'] - 1;
682 }
683 $cellRange = $columnID.$rowID.':'.$columnTo.$rowTo;
684 $objPHPExcel->getActiveSheet()->mergeCells($cellRange);
685 }
686 }
687
688 ++$columnID;
689 }
690 $rowID += $rowRepeats;
691 break;
692 }
693 }
694 ++$worksheetID;
695 }
696 }
697
698 // Return
699 return $objPHPExcel;
700 }
$dataArray
static _translateSeparator($fromSeparator, $toSeparator, $formula, &$inBraces)
static columnIndexFromString($pString='A')
Column index from string.
Definition: Cell.php:782
static convertProperty($propertyValue, $propertyType)
getReadFilter()
Read filter.
Definition: Abstract.php:173
_parseRichText($is='')
Definition: OOCalc.php:703
static FormattedPHPToExcel($year, $month, $day, $hours=0, $minutes=0, $seconds=0)
FormattedPHPToExcel.
Definition: Date.php:215
static PHPToExcel($dateValue=0, $adjustToTimezone=FALSE, $timezone=NULL)
Convert a date from PHP to Excel.
Definition: Date.php:185
$text

References $dataArray, $objPHPExcel, $t, $text, PHPExcel_Calculation\_translateSeparator(), PHPExcel_Cell\columnIndexFromString(), PHPExcel_DocumentProperties\convertProperty(), PHPExcel_Style_NumberFormat\FORMAT_CURRENCY_USD_SIMPLE, PHPExcel_Style_NumberFormat\FORMAT_DATE_TIME4, PHPExcel_Style_NumberFormat\FORMAT_DATE_XLSX15, PHPExcel_Style_NumberFormat\FORMAT_GENERAL, PHPExcel_Style_NumberFormat\FORMAT_PERCENTAGE_00, PHPExcel_Shared_Date\FormattedPHPToExcel(), PHPExcel_Settings\getLibXmlLoaderOptions(), PHPExcel_Settings\getZipClass(), PHPExcel_Shared_Date\PHPToExcel(), PHPExcel_DocumentProperties\PROPERTY_TYPE_BOOLEAN, PHPExcel_DocumentProperties\PROPERTY_TYPE_DATE, PHPExcel_DocumentProperties\PROPERTY_TYPE_FLOAT, PHPExcel_DocumentProperties\PROPERTY_TYPE_STRING, PHPExcel_Cell\stringFromColumnIndex(), PHPExcel_Cell_DataType\TYPE_BOOL, PHPExcel_Cell_DataType\TYPE_FORMULA, PHPExcel_Cell_DataType\TYPE_NULL, PHPExcel_Cell_DataType\TYPE_NUMERIC, and PHPExcel_Cell_DataType\TYPE_STRING.

+ Here is the call graph for this function:

Field Documentation

◆ $_styles

PHPExcel_Reader_OOCalc::$_styles = array()
private

Definition at line 52 of file OOCalc.php.


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