@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | /** |
| 190 | 190 | * Can the current PHPExcel_Reader_IReader read the file? |
| 191 | 191 | * |
| 192 | - * @param string $pFileName |
|
| 192 | + * @param string $pFilename |
|
| 193 | 193 | * @return boolean |
| 194 | 194 | * @throws Exception |
| 195 | 195 | */ |
@@ -268,6 +268,9 @@ discard block |
||
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | |
| 271 | + /** |
|
| 272 | + * @param string $filename |
|
| 273 | + */ |
|
| 271 | 274 | private function _gzfileGetContents($filename) { |
| 272 | 275 | $file = @gzopen($filename, 'rb'); |
| 273 | 276 | if ($file !== false) { |
@@ -363,7 +363,7 @@ |
||
| 363 | 363 | // Document Properties are held differently, depending on the version of Gnumeric |
| 364 | 364 | if (isset($namespacesMeta['office'])) { |
| 365 | 365 | $officeXML = $xml->children($namespacesMeta['office']); |
| 366 | - $officeDocXML = $officeXML->{'document-meta'}; |
|
| 366 | + $officeDocXML = $officeXML->{'document-meta'}; |
|
| 367 | 367 | $officeDocMetaXML = $officeDocXML->meta; |
| 368 | 368 | |
| 369 | 369 | foreach($officeDocMetaXML as $officePropertyData) { |
@@ -27,12 +27,12 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | |
| 29 | 29 | /** PHPExcel root directory */ |
| 30 | -if (!defined('PHPEXCEL_ROOT')) { |
|
| 30 | +if ( ! defined('PHPEXCEL_ROOT')) { |
|
| 31 | 31 | /** |
| 32 | 32 | * @ignore |
| 33 | 33 | */ |
| 34 | - define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../'); |
|
| 35 | - require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); |
|
| 34 | + define('PHPEXCEL_ROOT', dirname(__FILE__).'/../../'); |
|
| 35 | + require(PHPEXCEL_ROOT.'PHPExcel/Autoloader.php'); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | /** |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | * Create a new PHPExcel_Reader_Gnumeric |
| 90 | 90 | */ |
| 91 | 91 | public function __construct() { |
| 92 | - $this->_readFilter = new PHPExcel_Reader_DefaultReadFilter(); |
|
| 92 | + $this->_readFilter = new PHPExcel_Reader_DefaultReadFilter(); |
|
| 93 | 93 | $this->_referenceHelper = PHPExcel_ReferenceHelper::getInstance(); |
| 94 | 94 | } |
| 95 | 95 | |
@@ -196,12 +196,12 @@ discard block |
||
| 196 | 196 | public function canRead($pFilename) |
| 197 | 197 | { |
| 198 | 198 | // Check if file exists |
| 199 | - if (!file_exists($pFilename)) { |
|
| 200 | - throw new Exception("Could not open " . $pFilename . " for reading! File does not exist."); |
|
| 199 | + if ( ! file_exists($pFilename)) { |
|
| 200 | + throw new Exception("Could not open ".$pFilename." for reading! File does not exist."); |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | // Check if gzlib functions are available |
| 204 | - if (!function_exists('gzread')) { |
|
| 204 | + if ( ! function_exists('gzread')) { |
|
| 205 | 205 | throw new Exception("gzlib library is not enabled"); |
| 206 | 206 | } |
| 207 | 207 | |
@@ -227,8 +227,8 @@ discard block |
||
| 227 | 227 | public function listWorksheetInfo($pFilename) |
| 228 | 228 | { |
| 229 | 229 | // Check if file exists |
| 230 | - if (!file_exists($pFilename)) { |
|
| 231 | - throw new Exception("Could not open " . $pFilename . " for reading! File does not exist."); |
|
| 230 | + if ( ! file_exists($pFilename)) { |
|
| 231 | + throw new Exception("Could not open ".$pFilename." for reading! File does not exist."); |
|
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | $gFileData = $this->_gzfileGetContents($pFilename); |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | $file = @gzopen($filename, 'rb'); |
| 273 | 273 | if ($file !== false) { |
| 274 | 274 | $data = ''; |
| 275 | - while (!gzeof($file)) { |
|
| 275 | + while ( ! gzeof($file)) { |
|
| 276 | 276 | $data .= gzread($file, 1024); |
| 277 | 277 | } |
| 278 | 278 | gzclose($file); |
@@ -307,8 +307,8 @@ discard block |
||
| 307 | 307 | public function listWorksheetNames($pFilename) |
| 308 | 308 | { |
| 309 | 309 | // Check if file exists |
| 310 | - if (!file_exists($pFilename)) { |
|
| 311 | - throw new Exception("Could not open " . $pFilename . " for reading! File does not exist."); |
|
| 310 | + if ( ! file_exists($pFilename)) { |
|
| 311 | + throw new Exception("Could not open ".$pFilename." for reading! File does not exist."); |
|
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | $gFileData = $this->_gzfileGetContents($pFilename); |
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | |
| 321 | 321 | $worksheetNames = array(); |
| 322 | 322 | |
| 323 | - foreach($gnmXML->Sheets->Sheet as $sheet) { |
|
| 323 | + foreach ($gnmXML->Sheets->Sheet as $sheet) { |
|
| 324 | 324 | $worksheetNames[] = (string) $sheet->Name; |
| 325 | 325 | } |
| 326 | 326 | |
@@ -339,8 +339,8 @@ discard block |
||
| 339 | 339 | public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel) |
| 340 | 340 | { |
| 341 | 341 | // Check if file exists |
| 342 | - if (!file_exists($pFilename)) { |
|
| 343 | - throw new Exception("Could not open " . $pFilename . " for reading! File does not exist."); |
|
| 342 | + if ( ! file_exists($pFilename)) { |
|
| 343 | + throw new Exception("Could not open ".$pFilename." for reading! File does not exist."); |
|
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | $timezoneObj = new DateTimeZone('Europe/London'); |
@@ -366,13 +366,13 @@ discard block |
||
| 366 | 366 | $officeDocXML = $officeXML->{'document-meta'}; |
| 367 | 367 | $officeDocMetaXML = $officeDocXML->meta; |
| 368 | 368 | |
| 369 | - foreach($officeDocMetaXML as $officePropertyData) { |
|
| 369 | + foreach ($officeDocMetaXML as $officePropertyData) { |
|
| 370 | 370 | |
| 371 | 371 | $officePropertyDC = array(); |
| 372 | 372 | if (isset($namespacesMeta['dc'])) { |
| 373 | 373 | $officePropertyDC = $officePropertyData->children($namespacesMeta['dc']); |
| 374 | 374 | } |
| 375 | - foreach($officePropertyDC as $propertyName => $propertyValue) { |
|
| 375 | + foreach ($officePropertyDC as $propertyName => $propertyValue) { |
|
| 376 | 376 | $propertyValue = (string) $propertyValue; |
| 377 | 377 | switch ($propertyName) { |
| 378 | 378 | case 'title' : |
@@ -399,7 +399,7 @@ discard block |
||
| 399 | 399 | if (isset($namespacesMeta['meta'])) { |
| 400 | 400 | $officePropertyMeta = $officePropertyData->children($namespacesMeta['meta']); |
| 401 | 401 | } |
| 402 | - foreach($officePropertyMeta as $propertyName => $propertyValue) { |
|
| 402 | + foreach ($officePropertyMeta as $propertyName => $propertyValue) { |
|
| 403 | 403 | $attributes = $propertyValue->attributes($namespacesMeta['meta']); |
| 404 | 404 | $propertyValue = (string) $propertyValue; |
| 405 | 405 | switch ($propertyName) { |
@@ -416,7 +416,7 @@ discard block |
||
| 416 | 416 | $docProps->setModified($creationDate); |
| 417 | 417 | break; |
| 418 | 418 | case 'user-defined' : |
| 419 | - list(,$attrName) = explode(':',$attributes['name']); |
|
| 419 | + list(,$attrName) = explode(':', $attributes['name']); |
|
| 420 | 420 | switch ($attrName) { |
| 421 | 421 | case 'publisher' : |
| 422 | 422 | $docProps->setCompany(trim($propertyValue)); |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | } |
| 434 | 434 | } |
| 435 | 435 | } elseif (isset($gnmXML->Summary)) { |
| 436 | - foreach($gnmXML->Summary->Item as $summaryItem) { |
|
| 436 | + foreach ($gnmXML->Summary->Item as $summaryItem) { |
|
| 437 | 437 | $propertyName = $summaryItem->name; |
| 438 | 438 | $propertyValue = $summaryItem->{'val-string'}; |
| 439 | 439 | switch ($propertyName) { |
@@ -464,10 +464,10 @@ discard block |
||
| 464 | 464 | } |
| 465 | 465 | |
| 466 | 466 | $worksheetID = 0; |
| 467 | - foreach($gnmXML->Sheets->Sheet as $sheet) { |
|
| 467 | + foreach ($gnmXML->Sheets->Sheet as $sheet) { |
|
| 468 | 468 | $worksheetName = (string) $sheet->Name; |
| 469 | 469 | // echo '<b>Worksheet: ',$worksheetName,'</b><br />'; |
| 470 | - if ((isset($this->_loadSheetsOnly)) && (!in_array($worksheetName, $this->_loadSheetsOnly))) { |
|
| 470 | + if ((isset($this->_loadSheetsOnly)) && ( ! in_array($worksheetName, $this->_loadSheetsOnly))) { |
|
| 471 | 471 | continue; |
| 472 | 472 | } |
| 473 | 473 | |
@@ -479,19 +479,19 @@ discard block |
||
| 479 | 479 | // Use false for $updateFormulaCellReferences to prevent adjustment of worksheet references in formula |
| 480 | 480 | // cells... during the load, all formulae should be correct, and we're simply bringing the worksheet |
| 481 | 481 | // name in line with the formula, not the reverse |
| 482 | - $objPHPExcel->getActiveSheet()->setTitle($worksheetName,false); |
|
| 482 | + $objPHPExcel->getActiveSheet()->setTitle($worksheetName, false); |
|
| 483 | 483 | |
| 484 | - if ((!$this->_readDataOnly) && (isset($sheet->PrintInformation))) { |
|
| 484 | + if (( ! $this->_readDataOnly) && (isset($sheet->PrintInformation))) { |
|
| 485 | 485 | if (isset($sheet->PrintInformation->Margins)) { |
| 486 | - foreach($sheet->PrintInformation->Margins->children('gnm',TRUE) as $key => $margin) { |
|
| 486 | + foreach ($sheet->PrintInformation->Margins->children('gnm', TRUE) as $key => $margin) { |
|
| 487 | 487 | $marginAttributes = $margin->attributes(); |
| 488 | - $marginSize = 72 / 100; // Default |
|
| 489 | - switch($marginAttributes['PrefUnit']) { |
|
| 488 | + $marginSize = 72 / 100; // Default |
|
| 489 | + switch ($marginAttributes['PrefUnit']) { |
|
| 490 | 490 | case 'mm' : |
| 491 | 491 | $marginSize = intval($marginAttributes['Points']) / 100; |
| 492 | 492 | break; |
| 493 | 493 | } |
| 494 | - switch($key) { |
|
| 494 | + switch ($key) { |
|
| 495 | 495 | case 'top' : |
| 496 | 496 | $objPHPExcel->getActiveSheet()->getPageMargins()->setTop($marginSize); |
| 497 | 497 | break; |
@@ -515,7 +515,7 @@ discard block |
||
| 515 | 515 | } |
| 516 | 516 | } |
| 517 | 517 | |
| 518 | - foreach($sheet->Cells->Cell as $cell) { |
|
| 518 | + foreach ($sheet->Cells->Cell as $cell) { |
|
| 519 | 519 | $cellAttributes = $cell->attributes(); |
| 520 | 520 | $row = (int) $cellAttributes->Row + 1; |
| 521 | 521 | $column = (int) $cellAttributes->Col; |
@@ -527,7 +527,7 @@ discard block |
||
| 527 | 527 | |
| 528 | 528 | // Read cell? |
| 529 | 529 | if ($this->getReadFilter() !== NULL) { |
| 530 | - if (!$this->getReadFilter()->readCell($column, $row, $worksheetName)) { |
|
| 530 | + if ( ! $this->getReadFilter()->readCell($column, $row, $worksheetName)) { |
|
| 531 | 531 | continue; |
| 532 | 532 | } |
| 533 | 533 | } |
@@ -541,7 +541,7 @@ discard block |
||
| 541 | 541 | if ($ExprID > '') { |
| 542 | 542 | if (((string) $cell) > '') { |
| 543 | 543 | |
| 544 | - $this->_expressions[$ExprID] = array( 'column' => $cellAttributes->Col, |
|
| 544 | + $this->_expressions[$ExprID] = array('column' => $cellAttributes->Col, |
|
| 545 | 545 | 'row' => $cellAttributes->Row, |
| 546 | 546 | 'formula' => (string) $cell |
| 547 | 547 | ); |
@@ -549,7 +549,7 @@ discard block |
||
| 549 | 549 | } else { |
| 550 | 550 | $expression = $this->_expressions[$ExprID]; |
| 551 | 551 | |
| 552 | - $cell = $this->_referenceHelper->updateFormulaReferences( $expression['formula'], |
|
| 552 | + $cell = $this->_referenceHelper->updateFormulaReferences($expression['formula'], |
|
| 553 | 553 | 'A1', |
| 554 | 554 | $cellAttributes->Col - $expression['column'], |
| 555 | 555 | $cellAttributes->Row - $expression['row'], |
@@ -560,7 +560,7 @@ discard block |
||
| 560 | 560 | } |
| 561 | 561 | $type = PHPExcel_Cell_DataType::TYPE_FORMULA; |
| 562 | 562 | } else { |
| 563 | - switch($ValueType) { |
|
| 563 | + switch ($ValueType) { |
|
| 564 | 564 | case '10' : // NULL |
| 565 | 565 | $type = PHPExcel_Cell_DataType::TYPE_NULL; |
| 566 | 566 | break; |
@@ -583,23 +583,23 @@ discard block |
||
| 583 | 583 | case '80' : // Array |
| 584 | 584 | } |
| 585 | 585 | } |
| 586 | - $objPHPExcel->getActiveSheet()->getCell($column.$row)->setValueExplicit($cell,$type); |
|
| 586 | + $objPHPExcel->getActiveSheet()->getCell($column.$row)->setValueExplicit($cell, $type); |
|
| 587 | 587 | } |
| 588 | 588 | |
| 589 | - if ((!$this->_readDataOnly) && (isset($sheet->Objects))) { |
|
| 590 | - foreach($sheet->Objects->children('gnm',TRUE) as $key => $comment) { |
|
| 589 | + if (( ! $this->_readDataOnly) && (isset($sheet->Objects))) { |
|
| 590 | + foreach ($sheet->Objects->children('gnm', TRUE) as $key => $comment) { |
|
| 591 | 591 | $commentAttributes = $comment->attributes(); |
| 592 | 592 | // Only comment objects are handled at the moment |
| 593 | 593 | if ($commentAttributes->Text) { |
| 594 | - $objPHPExcel->getActiveSheet()->getComment( (string)$commentAttributes->ObjectBound ) |
|
| 595 | - ->setAuthor( (string)$commentAttributes->Author ) |
|
| 596 | - ->setText($this->_parseRichText((string)$commentAttributes->Text) ); |
|
| 594 | + $objPHPExcel->getActiveSheet()->getComment((string) $commentAttributes->ObjectBound) |
|
| 595 | + ->setAuthor((string) $commentAttributes->Author) |
|
| 596 | + ->setText($this->_parseRichText((string) $commentAttributes->Text)); |
|
| 597 | 597 | } |
| 598 | 598 | } |
| 599 | 599 | } |
| 600 | 600 | // echo '$maxCol=',$maxCol,'; $maxRow=',$maxRow,'<br />'; |
| 601 | 601 | // |
| 602 | - foreach($sheet->Styles->StyleRegion as $styleRegion) { |
|
| 602 | + foreach ($sheet->Styles->StyleRegion as $styleRegion) { |
|
| 603 | 603 | $styleAttributes = $styleRegion->attributes(); |
| 604 | 604 | if (($styleAttributes['startRow'] <= $maxRow) && |
| 605 | 605 | ($styleAttributes['startCol'] <= $maxCol)) { |
@@ -619,13 +619,13 @@ discard block |
||
| 619 | 619 | // echo '<br />'; |
| 620 | 620 | |
| 621 | 621 | // We still set the number format mask for date/time values, even if _readDataOnly is true |
| 622 | - if ((!$this->_readDataOnly) || |
|
| 622 | + if (( ! $this->_readDataOnly) || |
|
| 623 | 623 | (PHPExcel_Shared_Date::isDateTimeFormatCode($styleArray['numberformat']['code']))) { |
| 624 | 624 | $styleArray = array(); |
| 625 | 625 | $styleArray['numberformat']['code'] = (string) $styleAttributes['Format']; |
| 626 | 626 | // If _readDataOnly is false, we set all formatting information |
| 627 | - if (!$this->_readDataOnly) { |
|
| 628 | - switch($styleAttributes['HAlign']) { |
|
| 627 | + if ( ! $this->_readDataOnly) { |
|
| 628 | + switch ($styleAttributes['HAlign']) { |
|
| 629 | 629 | case '1' : |
| 630 | 630 | $styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL; |
| 631 | 631 | break; |
@@ -647,7 +647,7 @@ discard block |
||
| 647 | 647 | break; |
| 648 | 648 | } |
| 649 | 649 | |
| 650 | - switch($styleAttributes['VAlign']) { |
|
| 650 | + switch ($styleAttributes['VAlign']) { |
|
| 651 | 651 | case '1' : |
| 652 | 652 | $styleArray['alignment']['vertical'] = PHPExcel_Style_Alignment::VERTICAL_TOP; |
| 653 | 653 | break; |
@@ -674,7 +674,7 @@ discard block |
||
| 674 | 674 | $styleArray['fill']['color']['rgb'] = $styleArray['fill']['startcolor']['rgb'] = $RGB; |
| 675 | 675 | $RGB2 = self::_parseGnumericColour($styleAttributes["PatternColor"]); |
| 676 | 676 | $styleArray['fill']['endcolor']['rgb'] = $RGB2; |
| 677 | - switch($shade) { |
|
| 677 | + switch ($shade) { |
|
| 678 | 678 | case '1' : |
| 679 | 679 | $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_SOLID; |
| 680 | 680 | break; |
@@ -746,7 +746,7 @@ discard block |
||
| 746 | 746 | $styleArray['font']['bold'] = ($fontAttributes['Bold'] == '1') ? True : False; |
| 747 | 747 | $styleArray['font']['italic'] = ($fontAttributes['Italic'] == '1') ? True : False; |
| 748 | 748 | $styleArray['font']['strike'] = ($fontAttributes['StrikeThrough'] == '1') ? True : False; |
| 749 | - switch($fontAttributes['Underline']) { |
|
| 749 | + switch ($fontAttributes['Underline']) { |
|
| 750 | 750 | case '1' : |
| 751 | 751 | $styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_SINGLE; |
| 752 | 752 | break; |
@@ -763,7 +763,7 @@ discard block |
||
| 763 | 763 | $styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_NONE; |
| 764 | 764 | break; |
| 765 | 765 | } |
| 766 | - switch($fontAttributes['Script']) { |
|
| 766 | + switch ($fontAttributes['Script']) { |
|
| 767 | 767 | case '1' : |
| 768 | 768 | $styleArray['font']['superScript'] = True; |
| 769 | 769 | break; |
@@ -808,22 +808,22 @@ discard block |
||
| 808 | 808 | } |
| 809 | 809 | } |
| 810 | 810 | |
| 811 | - if ((!$this->_readDataOnly) && (isset($sheet->Cols))) { |
|
| 811 | + if (( ! $this->_readDataOnly) && (isset($sheet->Cols))) { |
|
| 812 | 812 | // Column Widths |
| 813 | 813 | $columnAttributes = $sheet->Cols->attributes(); |
| 814 | - $defaultWidth = $columnAttributes['DefaultSizePts'] / 5.4; |
|
| 814 | + $defaultWidth = $columnAttributes['DefaultSizePts'] / 5.4; |
|
| 815 | 815 | $c = 0; |
| 816 | - foreach($sheet->Cols->ColInfo as $columnOverride) { |
|
| 816 | + foreach ($sheet->Cols->ColInfo as $columnOverride) { |
|
| 817 | 817 | $columnAttributes = $columnOverride->attributes(); |
| 818 | 818 | $column = $columnAttributes['No']; |
| 819 | - $columnWidth = $columnAttributes['Unit'] / 5.4; |
|
| 819 | + $columnWidth = $columnAttributes['Unit'] / 5.4; |
|
| 820 | 820 | $hidden = ((isset($columnAttributes['Hidden'])) && ($columnAttributes['Hidden'] == '1')) ? true : false; |
| 821 | 821 | $columnCount = (isset($columnAttributes['Count'])) ? $columnAttributes['Count'] : 1; |
| 822 | 822 | while ($c < $column) { |
| 823 | 823 | $objPHPExcel->getActiveSheet()->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($c))->setWidth($defaultWidth); |
| 824 | 824 | ++$c; |
| 825 | 825 | } |
| 826 | - while (($c < ($column+$columnCount)) && ($c <= $maxCol)) { |
|
| 826 | + while (($c < ($column + $columnCount)) && ($c <= $maxCol)) { |
|
| 827 | 827 | $objPHPExcel->getActiveSheet()->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($c))->setWidth($columnWidth); |
| 828 | 828 | if ($hidden) { |
| 829 | 829 | $objPHPExcel->getActiveSheet()->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($c))->setVisible(false); |
@@ -837,13 +837,13 @@ discard block |
||
| 837 | 837 | } |
| 838 | 838 | } |
| 839 | 839 | |
| 840 | - if ((!$this->_readDataOnly) && (isset($sheet->Rows))) { |
|
| 840 | + if (( ! $this->_readDataOnly) && (isset($sheet->Rows))) { |
|
| 841 | 841 | // Row Heights |
| 842 | 842 | $rowAttributes = $sheet->Rows->attributes(); |
| 843 | 843 | $defaultHeight = $rowAttributes['DefaultSizePts']; |
| 844 | 844 | $r = 0; |
| 845 | 845 | |
| 846 | - foreach($sheet->Rows->RowInfo as $rowOverride) { |
|
| 846 | + foreach ($sheet->Rows->RowInfo as $rowOverride) { |
|
| 847 | 847 | $rowAttributes = $rowOverride->attributes(); |
| 848 | 848 | $row = $rowAttributes['No']; |
| 849 | 849 | $rowHeight = $rowAttributes['Unit']; |
@@ -853,7 +853,7 @@ discard block |
||
| 853 | 853 | ++$r; |
| 854 | 854 | $objPHPExcel->getActiveSheet()->getRowDimension($r)->setRowHeight($defaultHeight); |
| 855 | 855 | } |
| 856 | - while (($r < ($row+$rowCount)) && ($r < $maxRow)) { |
|
| 856 | + while (($r < ($row + $rowCount)) && ($r < $maxRow)) { |
|
| 857 | 857 | ++$r; |
| 858 | 858 | $objPHPExcel->getActiveSheet()->getRowDimension($r)->setRowHeight($rowHeight); |
| 859 | 859 | if ($hidden) { |
@@ -869,7 +869,7 @@ discard block |
||
| 869 | 869 | |
| 870 | 870 | // Handle Merged Cells in this worksheet |
| 871 | 871 | if (isset($sheet->MergedRegions)) { |
| 872 | - foreach($sheet->MergedRegions->Merge as $mergeCells) { |
|
| 872 | + foreach ($sheet->MergedRegions->Merge as $mergeCells) { |
|
| 873 | 873 | $objPHPExcel->getActiveSheet()->mergeCells($mergeCells); |
| 874 | 874 | } |
| 875 | 875 | } |
@@ -879,18 +879,18 @@ discard block |
||
| 879 | 879 | |
| 880 | 880 | // Loop through definedNames (global named ranges) |
| 881 | 881 | if (isset($gnmXML->Names)) { |
| 882 | - foreach($gnmXML->Names->Name as $namedRange) { |
|
| 882 | + foreach ($gnmXML->Names->Name as $namedRange) { |
|
| 883 | 883 | $name = (string) $namedRange->name; |
| 884 | 884 | $range = (string) $namedRange->value; |
| 885 | 885 | if (stripos($range, '#REF!') !== false) { |
| 886 | 886 | continue; |
| 887 | 887 | } |
| 888 | 888 | |
| 889 | - $range = explode('!',$range); |
|
| 890 | - $range[0] = trim($range[0],"'");; |
|
| 889 | + $range = explode('!', $range); |
|
| 890 | + $range[0] = trim($range[0], "'"); ; |
|
| 891 | 891 | if ($worksheet = $objPHPExcel->getSheetByName($range[0])) { |
| 892 | 892 | $extractedRange = str_replace('$', '', $range[1]); |
| 893 | - $objPHPExcel->addNamedRange( new PHPExcel_NamedRange($name, $worksheet, $extractedRange) ); |
|
| 893 | + $objPHPExcel->addNamedRange(new PHPExcel_NamedRange($name, $worksheet, $extractedRange)); |
|
| 894 | 894 | } |
| 895 | 895 | } |
| 896 | 896 | } |
@@ -967,10 +967,10 @@ discard block |
||
| 967 | 967 | |
| 968 | 968 | |
| 969 | 969 | private static function _parseGnumericColour($gnmColour) { |
| 970 | - list($gnmR,$gnmG,$gnmB) = explode(':',$gnmColour); |
|
| 971 | - $gnmR = substr(str_pad($gnmR,4,'0',STR_PAD_RIGHT),0,2); |
|
| 972 | - $gnmG = substr(str_pad($gnmG,4,'0',STR_PAD_RIGHT),0,2); |
|
| 973 | - $gnmB = substr(str_pad($gnmB,4,'0',STR_PAD_RIGHT),0,2); |
|
| 970 | + list($gnmR, $gnmG, $gnmB) = explode(':', $gnmColour); |
|
| 971 | + $gnmR = substr(str_pad($gnmR, 4, '0', STR_PAD_RIGHT), 0, 2); |
|
| 972 | + $gnmG = substr(str_pad($gnmG, 4, '0', STR_PAD_RIGHT), 0, 2); |
|
| 973 | + $gnmB = substr(str_pad($gnmB, 4, '0', STR_PAD_RIGHT), 0, 2); |
|
| 974 | 974 | $RGB = $gnmR.$gnmG.$gnmB; |
| 975 | 975 | // echo 'Excel Colour: ',$RGB,'<br />'; |
| 976 | 976 | return $RGB; |
@@ -520,8 +520,12 @@ |
||
| 520 | 520 | $row = (int) $cellAttributes->Row + 1; |
| 521 | 521 | $column = (int) $cellAttributes->Col; |
| 522 | 522 | |
| 523 | - if ($row > $maxRow) $maxRow = $row; |
|
| 524 | - if ($column > $maxCol) $maxCol = $column; |
|
| 523 | + if ($row > $maxRow) { |
|
| 524 | + $maxRow = $row; |
|
| 525 | + } |
|
| 526 | + if ($column > $maxCol) { |
|
| 527 | + $maxCol = $column; |
|
| 528 | + } |
|
| 525 | 529 | |
| 526 | 530 | $column = PHPExcel_Cell::stringFromColumnIndex($column); |
| 527 | 531 | |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | /** |
| 39 | 39 | * Can the current PHPExcel_Reader_IReader read the file? |
| 40 | 40 | * |
| 41 | - * @param string $pFileName |
|
| 41 | + * @param string $pFilename |
|
| 42 | 42 | * @return boolean |
| 43 | 43 | */ |
| 44 | 44 | public function canRead($pFilename); |
@@ -46,8 +46,9 @@ discard block |
||
| 46 | 46 | /** |
| 47 | 47 | * Loads PHPExcel from file |
| 48 | 48 | * |
| 49 | - * @param string $pFileName |
|
| 49 | + * @param string $pFilename |
|
| 50 | 50 | * @throws Exception |
| 51 | + * @return PHPExcel |
|
| 51 | 52 | */ |
| 52 | 53 | public function load($pFilename); |
| 53 | 54 | } |
@@ -178,7 +178,7 @@ |
||
| 178 | 178 | /** |
| 179 | 179 | * Can the current PHPExcel_Reader_IReader read the file? |
| 180 | 180 | * |
| 181 | - * @param string $pFileName |
|
| 181 | + * @param string $pFilename |
|
| 182 | 182 | * @return boolean |
| 183 | 183 | * @throws Exception |
| 184 | 184 | */ |
@@ -27,12 +27,12 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | |
| 29 | 29 | /** PHPExcel root directory */ |
| 30 | -if (!defined('PHPEXCEL_ROOT')) { |
|
| 30 | +if ( ! defined('PHPEXCEL_ROOT')) { |
|
| 31 | 31 | /** |
| 32 | 32 | * @ignore |
| 33 | 33 | */ |
| 34 | - define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../'); |
|
| 35 | - require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); |
|
| 34 | + define('PHPEXCEL_ROOT', dirname(__FILE__).'/../../'); |
|
| 35 | + require(PHPEXCEL_ROOT.'PHPExcel/Autoloader.php'); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | /** |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | * Create a new PHPExcel_Reader_OOCalc |
| 81 | 81 | */ |
| 82 | 82 | public function __construct() { |
| 83 | - $this->_readFilter = new PHPExcel_Reader_DefaultReadFilter(); |
|
| 83 | + $this->_readFilter = new PHPExcel_Reader_DefaultReadFilter(); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | |
@@ -185,12 +185,12 @@ discard block |
||
| 185 | 185 | public function canRead($pFilename) |
| 186 | 186 | { |
| 187 | 187 | // Check if file exists |
| 188 | - if (!file_exists($pFilename)) { |
|
| 189 | - throw new Exception("Could not open " . $pFilename . " for reading! File does not exist."); |
|
| 188 | + if ( ! file_exists($pFilename)) { |
|
| 189 | + throw new Exception("Could not open ".$pFilename." for reading! File does not exist."); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | // Check if zip class exists |
| 193 | - if (!class_exists('ZipArchive')) { |
|
| 193 | + if ( ! class_exists('ZipArchive')) { |
|
| 194 | 194 | throw new Exception("ZipArchive library is not enabled"); |
| 195 | 195 | } |
| 196 | 196 | |
@@ -218,8 +218,8 @@ discard block |
||
| 218 | 218 | public function listWorksheetNames($pFilename) |
| 219 | 219 | { |
| 220 | 220 | // Check if file exists |
| 221 | - if (!file_exists($pFilename)) { |
|
| 222 | - throw new Exception("Could not open " . $pFilename . " for reading! File does not exist."); |
|
| 221 | + if ( ! file_exists($pFilename)) { |
|
| 222 | + throw new Exception("Could not open ".$pFilename." for reading! File does not exist."); |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | $worksheetNames = array(); |
@@ -231,9 +231,9 @@ discard block |
||
| 231 | 231 | $namespacesContent = $xml->getNamespaces(true); |
| 232 | 232 | |
| 233 | 233 | $workbook = $xml->children($namespacesContent['office']); |
| 234 | - foreach($workbook->body->spreadsheet as $workbookData) { |
|
| 234 | + foreach ($workbook->body->spreadsheet as $workbookData) { |
|
| 235 | 235 | $workbookData = $workbookData->children($namespacesContent['table']); |
| 236 | - foreach($workbookData->table as $worksheetDataSet) { |
|
| 236 | + foreach ($workbookData->table as $worksheetDataSet) { |
|
| 237 | 237 | $worksheetDataAttributes = $worksheetDataSet->attributes($namespacesContent['table']); |
| 238 | 238 | |
| 239 | 239 | $worksheetNames[] = $worksheetDataAttributes['name']; |
@@ -262,9 +262,9 @@ discard block |
||
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | |
| 265 | - private static function identifyFixedStyleValue($styleList,&$styleAttributeValue) { |
|
| 265 | + private static function identifyFixedStyleValue($styleList, &$styleAttributeValue) { |
|
| 266 | 266 | $styleAttributeValue = strtolower($styleAttributeValue); |
| 267 | - foreach($styleList as $style) { |
|
| 267 | + foreach ($styleList as $style) { |
|
| 268 | 268 | if ($styleAttributeValue == strtolower($style)) { |
| 269 | 269 | $styleAttributeValue = $style; |
| 270 | 270 | return true; |
@@ -283,8 +283,8 @@ discard block |
||
| 283 | 283 | public function listWorksheetInfo($pFilename) |
| 284 | 284 | { |
| 285 | 285 | // Check if file exists |
| 286 | - if (!file_exists($pFilename)) { |
|
| 287 | - throw new Exception("Could not open " . $pFilename . " for reading! File does not exist."); |
|
| 286 | + if ( ! file_exists($pFilename)) { |
|
| 287 | + throw new Exception("Could not open ".$pFilename." for reading! File does not exist."); |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | $worksheetInfo = array(); |
@@ -296,9 +296,9 @@ discard block |
||
| 296 | 296 | $namespacesContent = $xml->getNamespaces(true); |
| 297 | 297 | |
| 298 | 298 | $workbook = $xml->children($namespacesContent['office']); |
| 299 | - foreach($workbook->body->spreadsheet as $workbookData) { |
|
| 299 | + foreach ($workbook->body->spreadsheet as $workbookData) { |
|
| 300 | 300 | $workbookData = $workbookData->children($namespacesContent['table']); |
| 301 | - foreach($workbookData->table as $worksheetDataSet) { |
|
| 301 | + foreach ($workbookData->table as $worksheetDataSet) { |
|
| 302 | 302 | $worksheetData = $worksheetDataSet->children($namespacesContent['table']); |
| 303 | 303 | $worksheetDataAttributes = $worksheetDataSet->attributes($namespacesContent['table']); |
| 304 | 304 | |
@@ -375,8 +375,8 @@ discard block |
||
| 375 | 375 | public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel) |
| 376 | 376 | { |
| 377 | 377 | // Check if file exists |
| 378 | - if (!file_exists($pFilename)) { |
|
| 379 | - throw new Exception("Could not open " . $pFilename . " for reading! File does not exist."); |
|
| 378 | + if ( ! file_exists($pFilename)) { |
|
| 379 | + throw new Exception("Could not open ".$pFilename." for reading! File does not exist."); |
|
| 380 | 380 | } |
| 381 | 381 | |
| 382 | 382 | $timezoneObj = new DateTimeZone('Europe/London'); |
@@ -393,12 +393,12 @@ discard block |
||
| 393 | 393 | |
| 394 | 394 | $docProps = $objPHPExcel->getProperties(); |
| 395 | 395 | $officeProperty = $xml->children($namespacesMeta['office']); |
| 396 | - foreach($officeProperty as $officePropertyData) { |
|
| 396 | + foreach ($officeProperty as $officePropertyData) { |
|
| 397 | 397 | $officePropertyDC = array(); |
| 398 | 398 | if (isset($namespacesMeta['dc'])) { |
| 399 | 399 | $officePropertyDC = $officePropertyData->children($namespacesMeta['dc']); |
| 400 | 400 | } |
| 401 | - foreach($officePropertyDC as $propertyName => $propertyValue) { |
|
| 401 | + foreach ($officePropertyDC as $propertyName => $propertyValue) { |
|
| 402 | 402 | switch ($propertyName) { |
| 403 | 403 | case 'title' : |
| 404 | 404 | $docProps->setTitle($propertyValue); |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | if (isset($namespacesMeta['dc'])) { |
| 425 | 425 | $officePropertyMeta = $officePropertyData->children($namespacesMeta['meta']); |
| 426 | 426 | } |
| 427 | - foreach($officePropertyMeta as $propertyName => $propertyValue) { |
|
| 427 | + foreach ($officePropertyMeta as $propertyName => $propertyValue) { |
|
| 428 | 428 | $propertyValueAttributes = $propertyValue->attributes($namespacesMeta['meta']); |
| 429 | 429 | switch ($propertyName) { |
| 430 | 430 | case 'initial-creator' : |
@@ -442,18 +442,18 @@ discard block |
||
| 442 | 442 | foreach ($propertyValueAttributes as $key => $value) { |
| 443 | 443 | if ($key == 'name') { |
| 444 | 444 | $propertyValueName = (string) $value; |
| 445 | - } elseif($key == 'value-type') { |
|
| 445 | + } elseif ($key == 'value-type') { |
|
| 446 | 446 | switch ($value) { |
| 447 | 447 | case 'date' : |
| 448 | - $propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue,'date'); |
|
| 448 | + $propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue, 'date'); |
|
| 449 | 449 | $propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_DATE; |
| 450 | 450 | break; |
| 451 | 451 | case 'boolean' : |
| 452 | - $propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue,'bool'); |
|
| 452 | + $propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue, 'bool'); |
|
| 453 | 453 | $propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_BOOLEAN; |
| 454 | 454 | break; |
| 455 | 455 | case 'float' : |
| 456 | - $propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue,'r4'); |
|
| 456 | + $propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue, 'r4'); |
|
| 457 | 457 | $propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_FLOAT; |
| 458 | 458 | break; |
| 459 | 459 | default : |
@@ -461,7 +461,7 @@ discard block |
||
| 461 | 461 | } |
| 462 | 462 | } |
| 463 | 463 | } |
| 464 | - $docProps->setCustomProperty($propertyValueName,$propertyValue,$propertyValueType); |
|
| 464 | + $docProps->setCustomProperty($propertyValueName, $propertyValue, $propertyValueType); |
|
| 465 | 465 | break; |
| 466 | 466 | } |
| 467 | 467 | } |
@@ -476,10 +476,10 @@ discard block |
||
| 476 | 476 | // echo '</pre><hr />'; |
| 477 | 477 | |
| 478 | 478 | $workbook = $xml->children($namespacesContent['office']); |
| 479 | - foreach($workbook->body->spreadsheet as $workbookData) { |
|
| 479 | + foreach ($workbook->body->spreadsheet as $workbookData) { |
|
| 480 | 480 | $workbookData = $workbookData->children($namespacesContent['table']); |
| 481 | 481 | $worksheetID = 0; |
| 482 | - foreach($workbookData->table as $worksheetDataSet) { |
|
| 482 | + foreach ($workbookData->table as $worksheetDataSet) { |
|
| 483 | 483 | $worksheetData = $worksheetDataSet->children($namespacesContent['table']); |
| 484 | 484 | // print_r($worksheetData); |
| 485 | 485 | // echo '<br />'; |
@@ -487,7 +487,7 @@ discard block |
||
| 487 | 487 | // print_r($worksheetDataAttributes); |
| 488 | 488 | // echo '<br />'; |
| 489 | 489 | if ((isset($this->_loadSheetsOnly)) && (isset($worksheetDataAttributes['name'])) && |
| 490 | - (!in_array($worksheetDataAttributes['name'], $this->_loadSheetsOnly))) { |
|
| 490 | + ( ! in_array($worksheetDataAttributes['name'], $this->_loadSheetsOnly))) { |
|
| 491 | 491 | continue; |
| 492 | 492 | } |
| 493 | 493 | |
@@ -500,11 +500,11 @@ discard block |
||
| 500 | 500 | // Use false for $updateFormulaCellReferences to prevent adjustment of worksheet references in |
| 501 | 501 | // formula cells... during the load, all formulae should be correct, and we're simply |
| 502 | 502 | // bringing the worksheet name in line with the formula, not the reverse |
| 503 | - $objPHPExcel->getActiveSheet()->setTitle($worksheetName,false); |
|
| 503 | + $objPHPExcel->getActiveSheet()->setTitle($worksheetName, false); |
|
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | $rowID = 1; |
| 507 | - foreach($worksheetData as $key => $rowData) { |
|
| 507 | + foreach ($worksheetData as $key => $rowData) { |
|
| 508 | 508 | // echo '<b>'.$key.'</b><br />'; |
| 509 | 509 | switch ($key) { |
| 510 | 510 | case 'table-header-rows': |
@@ -514,9 +514,9 @@ discard block |
||
| 514 | 514 | } |
| 515 | 515 | case 'table-row' : |
| 516 | 516 | $columnID = 'A'; |
| 517 | - foreach($rowData as $key => $cellData) { |
|
| 517 | + foreach ($rowData as $key => $cellData) { |
|
| 518 | 518 | if ($this->getReadFilter() !== NULL) { |
| 519 | - if (!$this->getReadFilter()->readCell($columnID, $rowID, $worksheetName)) { |
|
| 519 | + if ( ! $this->getReadFilter()->readCell($columnID, $rowID, $worksheetName)) { |
|
| 520 | 520 | continue; |
| 521 | 521 | } |
| 522 | 522 | } |
@@ -547,16 +547,16 @@ discard block |
||
| 547 | 547 | // echo 'Cell has comment<br />'; |
| 548 | 548 | $annotationText = $cellDataOffice->annotation->children($namespacesContent['text']); |
| 549 | 549 | $textArray = array(); |
| 550 | - foreach($annotationText as $t) { |
|
| 551 | - foreach($t->span as $text) { |
|
| 552 | - $textArray[] = (string)$text; |
|
| 550 | + foreach ($annotationText as $t) { |
|
| 551 | + foreach ($t->span as $text) { |
|
| 552 | + $textArray[] = (string) $text; |
|
| 553 | 553 | } |
| 554 | 554 | } |
| 555 | - $text = implode("\n",$textArray); |
|
| 555 | + $text = implode("\n", $textArray); |
|
| 556 | 556 | // echo $text,'<br />'; |
| 557 | - $objPHPExcel->getActiveSheet()->getComment( $columnID.$rowID ) |
|
| 557 | + $objPHPExcel->getActiveSheet()->getComment($columnID.$rowID) |
|
| 558 | 558 | // ->setAuthor( $author ) |
| 559 | - ->setText($this->_parseRichText($text) ); |
|
| 559 | + ->setText($this->_parseRichText($text)); |
|
| 560 | 560 | } |
| 561 | 561 | |
| 562 | 562 | if (isset($cellDataText->p)) { |
@@ -586,8 +586,8 @@ discard block |
||
| 586 | 586 | $type = PHPExcel_Cell_DataType::TYPE_NUMERIC; |
| 587 | 587 | $dateObj = new DateTime($cellDataOfficeAttributes['date-value'], $GMT); |
| 588 | 588 | $dateObj->setTimeZone($timezoneObj); |
| 589 | - list($year,$month,$day,$hour,$minute,$second) = explode(' ',$dateObj->format('Y m d H i s')); |
|
| 590 | - $dataValue = PHPExcel_Shared_Date::FormattedPHPToExcel($year,$month,$day,$hour,$minute,$second); |
|
| 589 | + list($year, $month, $day, $hour, $minute, $second) = explode(' ', $dateObj->format('Y m d H i s')); |
|
| 590 | + $dataValue = PHPExcel_Shared_Date::FormattedPHPToExcel($year, $month, $day, $hour, $minute, $second); |
|
| 591 | 591 | if ($dataValue != floor($dataValue)) { |
| 592 | 592 | $formatting = PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX15.' '.PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4; |
| 593 | 593 | } else { |
@@ -596,7 +596,7 @@ discard block |
||
| 596 | 596 | break; |
| 597 | 597 | case 'time' : |
| 598 | 598 | $type = PHPExcel_Cell_DataType::TYPE_NUMERIC; |
| 599 | - $dataValue = PHPExcel_Shared_Date::PHPToExcel(strtotime('01-01-1970 '.implode(':',sscanf($cellDataOfficeAttributes['time-value'],'PT%dH%dM%dS')))); |
|
| 599 | + $dataValue = PHPExcel_Shared_Date::PHPToExcel(strtotime('01-01-1970 '.implode(':', sscanf($cellDataOfficeAttributes['time-value'], 'PT%dH%dM%dS')))); |
|
| 600 | 600 | $formatting = PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4; |
| 601 | 601 | break; |
| 602 | 602 | } |
@@ -609,20 +609,20 @@ discard block |
||
| 609 | 609 | if ($hasCalculatedValue) { |
| 610 | 610 | $type = PHPExcel_Cell_DataType::TYPE_FORMULA; |
| 611 | 611 | // echo 'Formula: '.$cellDataFormula.'<br />'; |
| 612 | - $cellDataFormula = substr($cellDataFormula,strpos($cellDataFormula,':=')+1); |
|
| 613 | - $temp = explode('"',$cellDataFormula); |
|
| 612 | + $cellDataFormula = substr($cellDataFormula, strpos($cellDataFormula, ':=') + 1); |
|
| 613 | + $temp = explode('"', $cellDataFormula); |
|
| 614 | 614 | $tKey = false; |
| 615 | - foreach($temp as &$value) { |
|
| 615 | + foreach ($temp as &$value) { |
|
| 616 | 616 | // Only replace in alternate array entries (i.e. non-quoted blocks) |
| 617 | - if ($tKey = !$tKey) { |
|
| 618 | - $value = preg_replace('/\[\.(.*):\.(.*)\]/Ui','$1:$2',$value); |
|
| 619 | - $value = preg_replace('/\[\.(.*)\]/Ui','$1',$value); |
|
| 620 | - $value = PHPExcel_Calculation::_translateSeparator(';',',',$value,$inBraces); |
|
| 617 | + if ($tKey = ! $tKey) { |
|
| 618 | + $value = preg_replace('/\[\.(.*):\.(.*)\]/Ui', '$1:$2', $value); |
|
| 619 | + $value = preg_replace('/\[\.(.*)\]/Ui', '$1', $value); |
|
| 620 | + $value = PHPExcel_Calculation::_translateSeparator(';', ',', $value, $inBraces); |
|
| 621 | 621 | } |
| 622 | 622 | } |
| 623 | 623 | unset($value); |
| 624 | 624 | // Then rebuild the formula string |
| 625 | - $cellDataFormula = implode('"',$temp); |
|
| 625 | + $cellDataFormula = implode('"', $temp); |
|
| 626 | 626 | // echo 'Adjusted Formula: '.$cellDataFormula.'<br />'; |
| 627 | 627 | } |
| 628 | 628 | |
@@ -633,7 +633,7 @@ discard block |
||
| 633 | 633 | if ($i > 0) { |
| 634 | 634 | ++$columnID; |
| 635 | 635 | } |
| 636 | - $objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->setValueExplicit((($hasCalculatedValue) ? $cellDataFormula : $dataValue),$type); |
|
| 636 | + $objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->setValueExplicit((($hasCalculatedValue) ? $cellDataFormula : $dataValue), $type); |
|
| 637 | 637 | if ($hasCalculatedValue) { |
| 638 | 638 | // echo 'Forumla result is '.$dataValue.'<br />'; |
| 639 | 639 | $objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->setCalculatedValue($dataValue); |
@@ -652,7 +652,7 @@ discard block |
||
| 652 | 652 | if ((isset($cellDataTableAttributes['number-columns-spanned'])) || (isset($cellDataTableAttributes['number-rows-spanned']))) { |
| 653 | 653 | $columnTo = $columnID; |
| 654 | 654 | if (isset($cellDataTableAttributes['number-columns-spanned'])) { |
| 655 | - $columnTo = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($columnID) + $cellDataTableAttributes['number-columns-spanned'] -2); |
|
| 655 | + $columnTo = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($columnID) + $cellDataTableAttributes['number-columns-spanned'] - 2); |
|
| 656 | 656 | } |
| 657 | 657 | $rowTo = $rowID; |
| 658 | 658 | if (isset($cellDataTableAttributes['number-rows-spanned'])) { |
@@ -584,7 +584,7 @@ |
||
| 584 | 584 | break; |
| 585 | 585 | case 'date' : |
| 586 | 586 | $type = PHPExcel_Cell_DataType::TYPE_NUMERIC; |
| 587 | - $dateObj = new DateTime($cellDataOfficeAttributes['date-value'], $GMT); |
|
| 587 | + $dateObj = new DateTime($cellDataOfficeAttributes['date-value'], $GMT); |
|
| 588 | 588 | $dateObj->setTimeZone($timezoneObj); |
| 589 | 589 | list($year,$month,$day,$hour,$minute,$second) = explode(' ',$dateObj->format('Y m d H i s')); |
| 590 | 590 | $dataValue = PHPExcel_Shared_Date::FormattedPHPToExcel($year,$month,$day,$hour,$minute,$second); |
@@ -45,7 +45,6 @@ |
||
| 45 | 45 | /** |
| 46 | 46 | * Create a new PHPExcel_RichText instance |
| 47 | 47 | * |
| 48 | - * @param PHPExcel_Cell $pParent |
|
| 49 | 48 | * @throws Exception |
| 50 | 49 | */ |
| 51 | 50 | public function __construct(PHPExcel_Cell $pCell = null) |
@@ -42,126 +42,126 @@ discard block |
||
| 42 | 42 | */ |
| 43 | 43 | private $_richTextElements; |
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * Create a new PHPExcel_RichText instance |
|
| 47 | - * |
|
| 48 | - * @param PHPExcel_Cell $pParent |
|
| 49 | - * @throws Exception |
|
| 50 | - */ |
|
| 51 | - public function __construct(PHPExcel_Cell $pCell = null) |
|
| 52 | - { |
|
| 53 | - // Initialise variables |
|
| 54 | - $this->_richTextElements = array(); |
|
| 55 | - |
|
| 56 | - // Rich-Text string attached to cell? |
|
| 57 | - if ($pCell !== NULL) { |
|
| 58 | - // Add cell text and style |
|
| 59 | - if ($pCell->getValue() != "") { |
|
| 60 | - $objRun = new PHPExcel_RichText_Run($pCell->getValue()); |
|
| 61 | - $objRun->setFont(clone $pCell->getParent()->getStyle($pCell->getCoordinate())->getFont()); |
|
| 62 | - $this->addText($objRun); |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - // Set parent value |
|
| 66 | - $pCell->setValueExplicit($this, PHPExcel_Cell_DataType::TYPE_STRING); |
|
| 67 | - } |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * Add text |
|
| 72 | - * |
|
| 73 | - * @param PHPExcel_RichText_ITextElement $pText Rich text element |
|
| 74 | - * @throws Exception |
|
| 75 | - * @return PHPExcel_RichText |
|
| 76 | - */ |
|
| 77 | - public function addText(PHPExcel_RichText_ITextElement $pText = null) |
|
| 78 | - { |
|
| 79 | - $this->_richTextElements[] = $pText; |
|
| 80 | - return $this; |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - /** |
|
| 84 | - * Create text |
|
| 85 | - * |
|
| 86 | - * @param string $pText Text |
|
| 87 | - * @return PHPExcel_RichText_TextElement |
|
| 88 | - * @throws Exception |
|
| 89 | - */ |
|
| 90 | - public function createText($pText = '') |
|
| 91 | - { |
|
| 92 | - $objText = new PHPExcel_RichText_TextElement($pText); |
|
| 93 | - $this->addText($objText); |
|
| 94 | - return $objText; |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - /** |
|
| 98 | - * Create text run |
|
| 99 | - * |
|
| 100 | - * @param string $pText Text |
|
| 101 | - * @return PHPExcel_RichText_Run |
|
| 102 | - * @throws Exception |
|
| 103 | - */ |
|
| 104 | - public function createTextRun($pText = '') |
|
| 105 | - { |
|
| 106 | - $objText = new PHPExcel_RichText_Run($pText); |
|
| 107 | - $this->addText($objText); |
|
| 108 | - return $objText; |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - /** |
|
| 112 | - * Get plain text |
|
| 113 | - * |
|
| 114 | - * @return string |
|
| 115 | - */ |
|
| 116 | - public function getPlainText() |
|
| 117 | - { |
|
| 118 | - // Return value |
|
| 119 | - $returnValue = ''; |
|
| 120 | - |
|
| 121 | - // Loop through all PHPExcel_RichText_ITextElement |
|
| 122 | - foreach ($this->_richTextElements as $text) { |
|
| 123 | - $returnValue .= $text->getText(); |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - // Return |
|
| 127 | - return $returnValue; |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - /** |
|
| 131 | - * Convert to string |
|
| 132 | - * |
|
| 133 | - * @return string |
|
| 134 | - */ |
|
| 135 | - public function __toString() { |
|
| 136 | - return $this->getPlainText(); |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - /** |
|
| 140 | - * Get Rich Text elements |
|
| 141 | - * |
|
| 142 | - * @return PHPExcel_RichText_ITextElement[] |
|
| 143 | - */ |
|
| 144 | - public function getRichTextElements() |
|
| 145 | - { |
|
| 146 | - return $this->_richTextElements; |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - /** |
|
| 150 | - * Set Rich Text elements |
|
| 151 | - * |
|
| 152 | - * @param PHPExcel_RichText_ITextElement[] $pElements Array of elements |
|
| 153 | - * @throws Exception |
|
| 154 | - * @return PHPExcel_RichText |
|
| 155 | - */ |
|
| 156 | - public function setRichTextElements($pElements = null) |
|
| 157 | - { |
|
| 158 | - if (is_array($pElements)) { |
|
| 159 | - $this->_richTextElements = $pElements; |
|
| 160 | - } else { |
|
| 161 | - throw new Exception("Invalid PHPExcel_RichText_ITextElement[] array passed."); |
|
| 162 | - } |
|
| 163 | - return $this; |
|
| 164 | - } |
|
| 45 | + /** |
|
| 46 | + * Create a new PHPExcel_RichText instance |
|
| 47 | + * |
|
| 48 | + * @param PHPExcel_Cell $pParent |
|
| 49 | + * @throws Exception |
|
| 50 | + */ |
|
| 51 | + public function __construct(PHPExcel_Cell $pCell = null) |
|
| 52 | + { |
|
| 53 | + // Initialise variables |
|
| 54 | + $this->_richTextElements = array(); |
|
| 55 | + |
|
| 56 | + // Rich-Text string attached to cell? |
|
| 57 | + if ($pCell !== NULL) { |
|
| 58 | + // Add cell text and style |
|
| 59 | + if ($pCell->getValue() != "") { |
|
| 60 | + $objRun = new PHPExcel_RichText_Run($pCell->getValue()); |
|
| 61 | + $objRun->setFont(clone $pCell->getParent()->getStyle($pCell->getCoordinate())->getFont()); |
|
| 62 | + $this->addText($objRun); |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + // Set parent value |
|
| 66 | + $pCell->setValueExplicit($this, PHPExcel_Cell_DataType::TYPE_STRING); |
|
| 67 | + } |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * Add text |
|
| 72 | + * |
|
| 73 | + * @param PHPExcel_RichText_ITextElement $pText Rich text element |
|
| 74 | + * @throws Exception |
|
| 75 | + * @return PHPExcel_RichText |
|
| 76 | + */ |
|
| 77 | + public function addText(PHPExcel_RichText_ITextElement $pText = null) |
|
| 78 | + { |
|
| 79 | + $this->_richTextElements[] = $pText; |
|
| 80 | + return $this; |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + /** |
|
| 84 | + * Create text |
|
| 85 | + * |
|
| 86 | + * @param string $pText Text |
|
| 87 | + * @return PHPExcel_RichText_TextElement |
|
| 88 | + * @throws Exception |
|
| 89 | + */ |
|
| 90 | + public function createText($pText = '') |
|
| 91 | + { |
|
| 92 | + $objText = new PHPExcel_RichText_TextElement($pText); |
|
| 93 | + $this->addText($objText); |
|
| 94 | + return $objText; |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + /** |
|
| 98 | + * Create text run |
|
| 99 | + * |
|
| 100 | + * @param string $pText Text |
|
| 101 | + * @return PHPExcel_RichText_Run |
|
| 102 | + * @throws Exception |
|
| 103 | + */ |
|
| 104 | + public function createTextRun($pText = '') |
|
| 105 | + { |
|
| 106 | + $objText = new PHPExcel_RichText_Run($pText); |
|
| 107 | + $this->addText($objText); |
|
| 108 | + return $objText; |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + /** |
|
| 112 | + * Get plain text |
|
| 113 | + * |
|
| 114 | + * @return string |
|
| 115 | + */ |
|
| 116 | + public function getPlainText() |
|
| 117 | + { |
|
| 118 | + // Return value |
|
| 119 | + $returnValue = ''; |
|
| 120 | + |
|
| 121 | + // Loop through all PHPExcel_RichText_ITextElement |
|
| 122 | + foreach ($this->_richTextElements as $text) { |
|
| 123 | + $returnValue .= $text->getText(); |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + // Return |
|
| 127 | + return $returnValue; |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + /** |
|
| 131 | + * Convert to string |
|
| 132 | + * |
|
| 133 | + * @return string |
|
| 134 | + */ |
|
| 135 | + public function __toString() { |
|
| 136 | + return $this->getPlainText(); |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + /** |
|
| 140 | + * Get Rich Text elements |
|
| 141 | + * |
|
| 142 | + * @return PHPExcel_RichText_ITextElement[] |
|
| 143 | + */ |
|
| 144 | + public function getRichTextElements() |
|
| 145 | + { |
|
| 146 | + return $this->_richTextElements; |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + /** |
|
| 150 | + * Set Rich Text elements |
|
| 151 | + * |
|
| 152 | + * @param PHPExcel_RichText_ITextElement[] $pElements Array of elements |
|
| 153 | + * @throws Exception |
|
| 154 | + * @return PHPExcel_RichText |
|
| 155 | + */ |
|
| 156 | + public function setRichTextElements($pElements = null) |
|
| 157 | + { |
|
| 158 | + if (is_array($pElements)) { |
|
| 159 | + $this->_richTextElements = $pElements; |
|
| 160 | + } else { |
|
| 161 | + throw new Exception("Invalid PHPExcel_RichText_ITextElement[] array passed."); |
|
| 162 | + } |
|
| 163 | + return $this; |
|
| 164 | + } |
|
| 165 | 165 | |
| 166 | 166 | /** |
| 167 | 167 | * Get hash code |
@@ -174,11 +174,11 @@ discard block |
||
| 174 | 174 | $hashElements .= $element->getHashCode(); |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | - return md5( |
|
| 178 | - $hashElements |
|
| 179 | - . __CLASS__ |
|
| 180 | - ); |
|
| 181 | - } |
|
| 177 | + return md5( |
|
| 178 | + $hashElements |
|
| 179 | + . __CLASS__ |
|
| 180 | + ); |
|
| 181 | + } |
|
| 182 | 182 | |
| 183 | 183 | /** |
| 184 | 184 | * Implement PHP __clone to create a deep clone, not just a shallow copy. |
@@ -39,7 +39,6 @@ |
||
| 39 | 39 | * Convert Microsoft Code Page Identifier to Code Page Name which iconv |
| 40 | 40 | * and mbstring understands |
| 41 | 41 | * |
| 42 | - * @param int $number Microsoft Code Page Indentifier |
|
| 43 | 42 | * @return string Code Page Name |
| 44 | 43 | * @throws Exception |
| 45 | 44 | */ |
@@ -46,56 +46,56 @@ |
||
| 46 | 46 | public static function NumberToName($codePage = '1252') |
| 47 | 47 | { |
| 48 | 48 | switch ($codePage) { |
| 49 | - case 367: return 'ASCII'; break; // ASCII |
|
| 50 | - case 437: return 'CP437'; break; // OEM US |
|
| 49 | + case 367: return 'ASCII'; break; // ASCII |
|
| 50 | + case 437: return 'CP437'; break; // OEM US |
|
| 51 | 51 | case 720: throw new Exception('Code page 720 not supported.'); |
| 52 | - break; // OEM Arabic |
|
| 53 | - case 737: return 'CP737'; break; // OEM Greek |
|
| 54 | - case 775: return 'CP775'; break; // OEM Baltic |
|
| 55 | - case 850: return 'CP850'; break; // OEM Latin I |
|
| 56 | - case 852: return 'CP852'; break; // OEM Latin II (Central European) |
|
| 57 | - case 855: return 'CP855'; break; // OEM Cyrillic |
|
| 58 | - case 857: return 'CP857'; break; // OEM Turkish |
|
| 59 | - case 858: return 'CP858'; break; // OEM Multilingual Latin I with Euro |
|
| 60 | - case 860: return 'CP860'; break; // OEM Portugese |
|
| 61 | - case 861: return 'CP861'; break; // OEM Icelandic |
|
| 62 | - case 862: return 'CP862'; break; // OEM Hebrew |
|
| 63 | - case 863: return 'CP863'; break; // OEM Canadian (French) |
|
| 64 | - case 864: return 'CP864'; break; // OEM Arabic |
|
| 65 | - case 865: return 'CP865'; break; // OEM Nordic |
|
| 66 | - case 866: return 'CP866'; break; // OEM Cyrillic (Russian) |
|
| 67 | - case 869: return 'CP869'; break; // OEM Greek (Modern) |
|
| 68 | - case 874: return 'CP874'; break; // ANSI Thai |
|
| 69 | - case 932: return 'CP932'; break; // ANSI Japanese Shift-JIS |
|
| 70 | - case 936: return 'CP936'; break; // ANSI Chinese Simplified GBK |
|
| 71 | - case 949: return 'CP949'; break; // ANSI Korean (Wansung) |
|
| 72 | - case 950: return 'CP950'; break; // ANSI Chinese Traditional BIG5 |
|
| 73 | - case 1200: return 'UTF-16LE'; break; // UTF-16 (BIFF8) |
|
| 74 | - case 1250: return 'CP1250'; break; // ANSI Latin II (Central European) |
|
| 75 | - case 1251: return 'CP1251'; break; // ANSI Cyrillic |
|
| 52 | + break; // OEM Arabic |
|
| 53 | + case 737: return 'CP737'; break; // OEM Greek |
|
| 54 | + case 775: return 'CP775'; break; // OEM Baltic |
|
| 55 | + case 850: return 'CP850'; break; // OEM Latin I |
|
| 56 | + case 852: return 'CP852'; break; // OEM Latin II (Central European) |
|
| 57 | + case 855: return 'CP855'; break; // OEM Cyrillic |
|
| 58 | + case 857: return 'CP857'; break; // OEM Turkish |
|
| 59 | + case 858: return 'CP858'; break; // OEM Multilingual Latin I with Euro |
|
| 60 | + case 860: return 'CP860'; break; // OEM Portugese |
|
| 61 | + case 861: return 'CP861'; break; // OEM Icelandic |
|
| 62 | + case 862: return 'CP862'; break; // OEM Hebrew |
|
| 63 | + case 863: return 'CP863'; break; // OEM Canadian (French) |
|
| 64 | + case 864: return 'CP864'; break; // OEM Arabic |
|
| 65 | + case 865: return 'CP865'; break; // OEM Nordic |
|
| 66 | + case 866: return 'CP866'; break; // OEM Cyrillic (Russian) |
|
| 67 | + case 869: return 'CP869'; break; // OEM Greek (Modern) |
|
| 68 | + case 874: return 'CP874'; break; // ANSI Thai |
|
| 69 | + case 932: return 'CP932'; break; // ANSI Japanese Shift-JIS |
|
| 70 | + case 936: return 'CP936'; break; // ANSI Chinese Simplified GBK |
|
| 71 | + case 949: return 'CP949'; break; // ANSI Korean (Wansung) |
|
| 72 | + case 950: return 'CP950'; break; // ANSI Chinese Traditional BIG5 |
|
| 73 | + case 1200: return 'UTF-16LE'; break; // UTF-16 (BIFF8) |
|
| 74 | + case 1250: return 'CP1250'; break; // ANSI Latin II (Central European) |
|
| 75 | + case 1251: return 'CP1251'; break; // ANSI Cyrillic |
|
| 76 | 76 | case 0: // CodePage is not always correctly set when the xls file was saved by Apple's Numbers program |
| 77 | - case 1252: return 'CP1252'; break; // ANSI Latin I (BIFF4-BIFF7) |
|
| 78 | - case 1253: return 'CP1253'; break; // ANSI Greek |
|
| 79 | - case 1254: return 'CP1254'; break; // ANSI Turkish |
|
| 80 | - case 1255: return 'CP1255'; break; // ANSI Hebrew |
|
| 81 | - case 1256: return 'CP1256'; break; // ANSI Arabic |
|
| 82 | - case 1257: return 'CP1257'; break; // ANSI Baltic |
|
| 83 | - case 1258: return 'CP1258'; break; // ANSI Vietnamese |
|
| 84 | - case 1361: return 'CP1361'; break; // ANSI Korean (Johab) |
|
| 85 | - case 10000: return 'MAC'; break; // Apple Roman |
|
| 86 | - case 10006: return 'MACGREEK'; break; // Macintosh Greek |
|
| 87 | - case 10007: return 'MACCYRILLIC'; break; // Macintosh Cyrillic |
|
| 88 | - case 10029: return 'MACCENTRALEUROPE'; break; // Macintosh Central Europe |
|
| 89 | - case 10079: return 'MACICELAND'; break; // Macintosh Icelandic |
|
| 90 | - case 10081: return 'MACTURKISH'; break; // Macintosh Turkish |
|
| 91 | - case 32768: return 'MAC'; break; // Apple Roman |
|
| 77 | + case 1252: return 'CP1252'; break; // ANSI Latin I (BIFF4-BIFF7) |
|
| 78 | + case 1253: return 'CP1253'; break; // ANSI Greek |
|
| 79 | + case 1254: return 'CP1254'; break; // ANSI Turkish |
|
| 80 | + case 1255: return 'CP1255'; break; // ANSI Hebrew |
|
| 81 | + case 1256: return 'CP1256'; break; // ANSI Arabic |
|
| 82 | + case 1257: return 'CP1257'; break; // ANSI Baltic |
|
| 83 | + case 1258: return 'CP1258'; break; // ANSI Vietnamese |
|
| 84 | + case 1361: return 'CP1361'; break; // ANSI Korean (Johab) |
|
| 85 | + case 10000: return 'MAC'; break; // Apple Roman |
|
| 86 | + case 10006: return 'MACGREEK'; break; // Macintosh Greek |
|
| 87 | + case 10007: return 'MACCYRILLIC'; break; // Macintosh Cyrillic |
|
| 88 | + case 10029: return 'MACCENTRALEUROPE'; break; // Macintosh Central Europe |
|
| 89 | + case 10079: return 'MACICELAND'; break; // Macintosh Icelandic |
|
| 90 | + case 10081: return 'MACTURKISH'; break; // Macintosh Turkish |
|
| 91 | + case 32768: return 'MAC'; break; // Apple Roman |
|
| 92 | 92 | case 32769: throw new Exception('Code page 32769 not supported.'); |
| 93 | - break; // ANSI Latin I (BIFF2-BIFF3) |
|
| 94 | - case 65000: return 'UTF-7'; break; // Unicode (UTF-7) |
|
| 95 | - case 65001: return 'UTF-8'; break; // Unicode (UTF-8) |
|
| 93 | + break; // ANSI Latin I (BIFF2-BIFF3) |
|
| 94 | + case 65000: return 'UTF-7'; break; // Unicode (UTF-7) |
|
| 95 | + case 65001: return 'UTF-8'; break; // Unicode (UTF-8) |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - throw new Exception('Unknown codepage: ' . $codePage); |
|
| 98 | + throw new Exception('Unknown codepage: '.$codePage); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | } |
@@ -107,8 +107,8 @@ discard block |
||
| 107 | 107 | /** |
| 108 | 108 | * Convert a date from Excel to PHP |
| 109 | 109 | * |
| 110 | - * @param long $dateValue Excel date/time value |
|
| 111 | - * @return long PHP serialized date/time |
|
| 110 | + * @param integer $dateValue Excel date/time value |
|
| 111 | + * @return integer|null PHP serialized date/time |
|
| 112 | 112 | */ |
| 113 | 113 | public static function ExcelToPHP($dateValue = 0) { |
| 114 | 114 | if (self::$ExcelBaseDate == self::CALENDAR_WINDOWS_1900) { |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | /** |
| 144 | 144 | * Convert a date from Excel to a PHP Date/Time object |
| 145 | 145 | * |
| 146 | - * @param long $dateValue Excel date/time value |
|
| 146 | + * @param integer $dateValue Excel date/time value |
|
| 147 | 147 | * @return long PHP date/time object |
| 148 | 148 | */ |
| 149 | 149 | public static function ExcelToPHPObject($dateValue = 0) { |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | /** |
| 165 | 165 | * Convert a date from PHP to Excel |
| 166 | 166 | * |
| 167 | - * @param mixed $dateValue PHP serialized date/time or date object |
|
| 167 | + * @param integer $dateValue PHP serialized date/time or date object |
|
| 168 | 168 | * @return mixed Excel date/time value |
| 169 | 169 | * or boolean False on failure |
| 170 | 170 | */ |
@@ -193,10 +193,10 @@ discard block |
||
| 193 | 193 | * @param long $year |
| 194 | 194 | * @param long $month |
| 195 | 195 | * @param long $day |
| 196 | - * @param long $hours |
|
| 197 | - * @param long $minutes |
|
| 198 | - * @param long $seconds |
|
| 199 | - * @return long Excel date/time value |
|
| 196 | + * @param integer $hours |
|
| 197 | + * @param integer $minutes |
|
| 198 | + * @param integer $seconds |
|
| 199 | + * @return double Excel date/time value |
|
| 200 | 200 | */ |
| 201 | 201 | public static function FormattedPHPToExcel($year, $month, $day, $hours=0, $minutes=0, $seconds=0) { |
| 202 | 202 | if (self::$ExcelBaseDate == self::CALENDAR_WINDOWS_1900) { |
@@ -37,8 +37,8 @@ discard block |
||
| 37 | 37 | class PHPExcel_Shared_Date |
| 38 | 38 | { |
| 39 | 39 | /** constants */ |
| 40 | - const CALENDAR_WINDOWS_1900 = 1900; // Base date of 1st Jan 1900 = 1.0 |
|
| 41 | - const CALENDAR_MAC_1904 = 1904; // Base date of 2nd Jan 1904 = 1.0 |
|
| 40 | + const CALENDAR_WINDOWS_1900 = 1900; // Base date of 1st Jan 1900 = 1.0 |
|
| 41 | + const CALENDAR_MAC_1904 = 1904; // Base date of 2nd Jan 1904 = 1.0 |
|
| 42 | 42 | |
| 43 | 43 | /* |
| 44 | 44 | * Names of the months of the year, indexed by shortname |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | * @public |
| 48 | 48 | * @var string[] |
| 49 | 49 | */ |
| 50 | - public static $_monthNames = array( 'Jan' => 'January', |
|
| 50 | + public static $_monthNames = array('Jan' => 'January', |
|
| 51 | 51 | 'Feb' => 'February', |
| 52 | 52 | 'Mar' => 'March', |
| 53 | 53 | 'Apr' => 'April', |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | * @private |
| 68 | 68 | * @var int |
| 69 | 69 | */ |
| 70 | - private static $ExcelBaseDate = self::CALENDAR_WINDOWS_1900; |
|
| 70 | + private static $ExcelBaseDate = self::CALENDAR_WINDOWS_1900; |
|
| 71 | 71 | |
| 72 | 72 | /* |
| 73 | 73 | * Object type for PHP Date/Time values |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | * @private |
| 76 | 76 | * @var string |
| 77 | 77 | */ |
| 78 | - public static $dateTimeObjectType = 'DateTime'; |
|
| 78 | + public static $dateTimeObjectType = 'DateTime'; |
|
| 79 | 79 | |
| 80 | 80 | |
| 81 | 81 | /** |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | $seconds = round($time) - ($hours * 3600) - ($minutes * 60); |
| 156 | 156 | |
| 157 | 157 | $dateObj = date_create('1-Jan-1970+'.$days.' days'); |
| 158 | - $dateObj->setTime($hours,$minutes,$seconds); |
|
| 158 | + $dateObj->setTime($hours, $minutes, $seconds); |
|
| 159 | 159 | |
| 160 | 160 | return $dateObj; |
| 161 | 161 | } // function ExcelToPHPObject() |
@@ -173,12 +173,12 @@ discard block |
||
| 173 | 173 | date_default_timezone_set('UTC'); |
| 174 | 174 | $retValue = False; |
| 175 | 175 | if ((is_object($dateValue)) && ($dateValue instanceof self::$dateTimeObjectType)) { |
| 176 | - $retValue = self::FormattedPHPToExcel( $dateValue->format('Y'), $dateValue->format('m'), $dateValue->format('d'), |
|
| 176 | + $retValue = self::FormattedPHPToExcel($dateValue->format('Y'), $dateValue->format('m'), $dateValue->format('d'), |
|
| 177 | 177 | $dateValue->format('H'), $dateValue->format('i'), $dateValue->format('s') |
| 178 | 178 | ); |
| 179 | 179 | } elseif (is_numeric($dateValue)) { |
| 180 | - $retValue = self::FormattedPHPToExcel( date('Y',$dateValue), date('m',$dateValue), date('d',$dateValue), |
|
| 181 | - date('H',$dateValue), date('i',$dateValue), date('s',$dateValue) |
|
| 180 | + $retValue = self::FormattedPHPToExcel(date('Y', $dateValue), date('m', $dateValue), date('d', $dateValue), |
|
| 181 | + date('H', $dateValue), date('i', $dateValue), date('s', $dateValue) |
|
| 182 | 182 | ); |
| 183 | 183 | } |
| 184 | 184 | date_default_timezone_set($saveTimeZone); |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | * @param long $seconds |
| 199 | 199 | * @return long Excel date/time value |
| 200 | 200 | */ |
| 201 | - public static function FormattedPHPToExcel($year, $month, $day, $hours=0, $minutes=0, $seconds=0) { |
|
| 201 | + public static function FormattedPHPToExcel($year, $month, $day, $hours = 0, $minutes = 0, $seconds = 0) { |
|
| 202 | 202 | if (self::$ExcelBaseDate == self::CALENDAR_WINDOWS_1900) { |
| 203 | 203 | // |
| 204 | 204 | // Fudge factor for the erroneous fact that the year 1900 is treated as a Leap Year in MS Excel |
@@ -221,8 +221,8 @@ discard block |
||
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | // Calculate the Julian Date, then subtract the Excel base date (JD 2415020 = 31-Dec-1899 Giving Excel Date of 0) |
| 224 | - $century = substr($year,0,2); |
|
| 225 | - $decade = substr($year,2,2); |
|
| 224 | + $century = substr($year, 0, 2); |
|
| 225 | + $decade = substr($year, 2, 2); |
|
| 226 | 226 | $excelDate = floor((146097 * $century) / 4) + floor((1461 * $decade) / 4) + floor((153 * $month + 2) / 5) + $day + 1721119 - $myExcelBaseDate + $excel1900isLeapYear; |
| 227 | 227 | |
| 228 | 228 | $excelTime = (($hours * 3600) + ($minutes * 60) + $seconds) / 86400; |
@@ -290,18 +290,18 @@ discard block |
||
| 290 | 290 | } |
| 291 | 291 | |
| 292 | 292 | // Typically number, currency or accounting (or occasionally fraction) formats |
| 293 | - if ((substr($pFormatCode,0,1) == '_') || (substr($pFormatCode,0,2) == '0 ')) { |
|
| 293 | + if ((substr($pFormatCode, 0, 1) == '_') || (substr($pFormatCode, 0, 2) == '0 ')) { |
|
| 294 | 294 | return false; |
| 295 | 295 | } |
| 296 | 296 | // Try checking for any of the date formatting characters that don't appear within square braces |
| 297 | - if (preg_match('/(^|\])[^\[]*['.self::$possibleDateFormatCharacters.']/i',$pFormatCode)) { |
|
| 297 | + if (preg_match('/(^|\])[^\[]*['.self::$possibleDateFormatCharacters.']/i', $pFormatCode)) { |
|
| 298 | 298 | // We might also have a format mask containing quoted strings... |
| 299 | 299 | // we don't want to test for any of our characters within the quoted blocks |
| 300 | - if (strpos($pFormatCode,'"') !== false) { |
|
| 300 | + if (strpos($pFormatCode, '"') !== false) { |
|
| 301 | 301 | $i = false; |
| 302 | - foreach(explode('"',$pFormatCode) as $subVal) { |
|
| 302 | + foreach (explode('"', $pFormatCode) as $subVal) { |
|
| 303 | 303 | // Only test in alternate array entries (the non-quoted blocks) |
| 304 | - if (($i = !$i) && (preg_match('/(^|\])[^\[]*['.self::$possibleDateFormatCharacters.']/i',$subVal))) { |
|
| 304 | + if (($i = ! $i) && (preg_match('/(^|\])[^\[]*['.self::$possibleDateFormatCharacters.']/i', $subVal))) { |
|
| 305 | 305 | return true; |
| 306 | 306 | } |
| 307 | 307 | } |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | public static function stringToExcel($dateValue = '') { |
| 325 | 325 | if (strlen($dateValue) < 2) |
| 326 | 326 | return false; |
| 327 | - if (!preg_match('/^(\d{1,4}[ \.\/\-][A-Z]{3,9}([ \.\/\-]\d{1,4})?|[A-Z]{3,9}[ \.\/\-]\d{1,4}([ \.\/\-]\d{1,4})?|\d{1,4}[ \.\/\-]\d{1,4}([ \.\/\-]\d{1,4})?)( \d{1,2}:\d{1,2}(:\d{1,2})?)?$/iu', $dateValue)) |
|
| 327 | + if ( ! preg_match('/^(\d{1,4}[ \.\/\-][A-Z]{3,9}([ \.\/\-]\d{1,4})?|[A-Z]{3,9}[ \.\/\-]\d{1,4}([ \.\/\-]\d{1,4})?|\d{1,4}[ \.\/\-]\d{1,4}([ \.\/\-]\d{1,4})?)( \d{1,2}:\d{1,2}(:\d{1,2})?)?$/iu', $dateValue)) |
|
| 328 | 328 | return false; |
| 329 | 329 | |
| 330 | 330 | $dateValueNew = PHPExcel_Calculation_DateTime::DATEVALUE($dateValue); |
@@ -322,10 +322,12 @@ |
||
| 322 | 322 | * @return float|false Excel date/time serial value |
| 323 | 323 | */ |
| 324 | 324 | public static function stringToExcel($dateValue = '') { |
| 325 | - if (strlen($dateValue) < 2) |
|
| 326 | - return false; |
|
| 327 | - if (!preg_match('/^(\d{1,4}[ \.\/\-][A-Z]{3,9}([ \.\/\-]\d{1,4})?|[A-Z]{3,9}[ \.\/\-]\d{1,4}([ \.\/\-]\d{1,4})?|\d{1,4}[ \.\/\-]\d{1,4}([ \.\/\-]\d{1,4})?)( \d{1,2}:\d{1,2}(:\d{1,2})?)?$/iu', $dateValue)) |
|
| 328 | - return false; |
|
| 325 | + if (strlen($dateValue) < 2) { |
|
| 326 | + return false; |
|
| 327 | + } |
|
| 328 | + if (!preg_match('/^(\d{1,4}[ \.\/\-][A-Z]{3,9}([ \.\/\-]\d{1,4})?|[A-Z]{3,9}[ \.\/\-]\d{1,4}([ \.\/\-]\d{1,4})?|\d{1,4}[ \.\/\-]\d{1,4}([ \.\/\-]\d{1,4})?)( \d{1,2}:\d{1,2}(:\d{1,2})?)?$/iu', $dateValue)) { |
|
| 329 | + return false; |
|
| 330 | + } |
|
| 329 | 331 | |
| 330 | 332 | $dateValueNew = PHPExcel_Calculation_DateTime::DATEVALUE($dateValue); |
| 331 | 333 | |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | * Convert pixels to EMU |
| 40 | 40 | * |
| 41 | 41 | * @param int $pValue Value in pixels |
| 42 | - * @return int Value in EMU |
|
| 42 | + * @return double Value in EMU |
|
| 43 | 43 | */ |
| 44 | 44 | public static function pixelsToEMU($pValue = 0) { |
| 45 | 45 | return round($pValue * 9525); |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | /** |
| 93 | 93 | * Convert column width from (intrinsic) Excel units to pixels |
| 94 | 94 | * |
| 95 | - * @param float $pValue Value in cell dimension |
|
| 95 | + * @param integer $pValue Value in cell dimension |
|
| 96 | 96 | * @param PHPExcel_Style_Font $pDefaultFont Default font of the workbook |
| 97 | 97 | * @return int Value in pixels |
| 98 | 98 | */ |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | * Convert pixels to points |
| 126 | 126 | * |
| 127 | 127 | * @param int $pValue Value in pixels |
| 128 | - * @return int Value in points |
|
| 128 | + * @return double Value in points |
|
| 129 | 129 | */ |
| 130 | 130 | public static function pixelsToPoints($pValue = 0) { |
| 131 | 131 | return $pValue * 0.67777777; |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | * Create a new image from file. By alexander at alexauto dot nl |
| 174 | 174 | * |
| 175 | 175 | * @link http://www.php.net/manual/en/function.imagecreatefromwbmp.php#86214 |
| 176 | - * @param string $filename Path to Windows DIB (BMP) image |
|
| 176 | + * @param string $p_sFile |
|
| 177 | 177 | * @return resource |
| 178 | 178 | */ |
| 179 | 179 | public static function imagecreatefrombmp($p_sFile) |
@@ -178,95 +178,95 @@ |
||
| 178 | 178 | */ |
| 179 | 179 | public static function imagecreatefrombmp($p_sFile) |
| 180 | 180 | { |
| 181 | - // Load the image into a string |
|
| 182 | - $file = fopen($p_sFile,"rb"); |
|
| 183 | - $read = fread($file,10); |
|
| 184 | - while(!feof($file)&&($read<>"")) |
|
| 185 | - $read .= fread($file,1024); |
|
| 186 | - |
|
| 187 | - $temp = unpack("H*",$read); |
|
| 188 | - $hex = $temp[1]; |
|
| 189 | - $header = substr($hex,0,108); |
|
| 190 | - |
|
| 191 | - // Process the header |
|
| 192 | - // Structure: http://www.fastgraph.com/help/bmp_header_format.html |
|
| 193 | - if (substr($header,0,4)=="424d") |
|
| 194 | - { |
|
| 195 | - // Cut it in parts of 2 bytes |
|
| 196 | - $header_parts = str_split($header,2); |
|
| 197 | - |
|
| 198 | - // Get the width 4 bytes |
|
| 199 | - $width = hexdec($header_parts[19].$header_parts[18]); |
|
| 200 | - |
|
| 201 | - // Get the height 4 bytes |
|
| 202 | - $height = hexdec($header_parts[23].$header_parts[22]); |
|
| 203 | - |
|
| 204 | - // Unset the header params |
|
| 205 | - unset($header_parts); |
|
| 206 | - } |
|
| 207 | - |
|
| 208 | - // Define starting X and Y |
|
| 209 | - $x = 0; |
|
| 210 | - $y = 1; |
|
| 211 | - |
|
| 212 | - // Create newimage |
|
| 213 | - $image = imagecreatetruecolor($width,$height); |
|
| 214 | - |
|
| 215 | - // Grab the body from the image |
|
| 216 | - $body = substr($hex,108); |
|
| 217 | - |
|
| 218 | - // Calculate if padding at the end-line is needed |
|
| 219 | - // Divided by two to keep overview. |
|
| 220 | - // 1 byte = 2 HEX-chars |
|
| 221 | - $body_size = (strlen($body)/2); |
|
| 222 | - $header_size = ($width*$height); |
|
| 223 | - |
|
| 224 | - // Use end-line padding? Only when needed |
|
| 225 | - $usePadding = ($body_size>($header_size*3)+4); |
|
| 226 | - |
|
| 227 | - // Using a for-loop with index-calculation instaid of str_split to avoid large memory consumption |
|
| 228 | - // Calculate the next DWORD-position in the body |
|
| 229 | - for ($i=0;$i<$body_size;$i+=3) |
|
| 230 | - { |
|
| 231 | - // Calculate line-ending and padding |
|
| 232 | - if ($x>=$width) |
|
| 233 | - { |
|
| 234 | - // If padding needed, ignore image-padding |
|
| 235 | - // Shift i to the ending of the current 32-bit-block |
|
| 236 | - if ($usePadding) |
|
| 237 | - $i += $width%4; |
|
| 238 | - |
|
| 239 | - // Reset horizontal position |
|
| 240 | - $x = 0; |
|
| 241 | - |
|
| 242 | - // Raise the height-position (bottom-up) |
|
| 243 | - $y++; |
|
| 244 | - |
|
| 245 | - // Reached the image-height? Break the for-loop |
|
| 246 | - if ($y>$height) |
|
| 247 | - break; |
|
| 248 | - } |
|
| 249 | - |
|
| 250 | - // Calculation of the RGB-pixel (defined as BGR in image-data) |
|
| 251 | - // Define $i_pos as absolute position in the body |
|
| 252 | - $i_pos = $i*2; |
|
| 253 | - $r = hexdec($body[$i_pos+4].$body[$i_pos+5]); |
|
| 254 | - $g = hexdec($body[$i_pos+2].$body[$i_pos+3]); |
|
| 255 | - $b = hexdec($body[$i_pos].$body[$i_pos+1]); |
|
| 256 | - |
|
| 257 | - // Calculate and draw the pixel |
|
| 258 | - $color = imagecolorallocate($image,$r,$g,$b); |
|
| 259 | - imagesetpixel($image,$x,$height-$y,$color); |
|
| 260 | - |
|
| 261 | - // Raise the horizontal position |
|
| 262 | - $x++; |
|
| 263 | - } |
|
| 264 | - |
|
| 265 | - // Unset the body / free the memory |
|
| 266 | - unset($body); |
|
| 267 | - |
|
| 268 | - // Return image-object |
|
| 269 | - return $image; |
|
| 181 | + // Load the image into a string |
|
| 182 | + $file = fopen($p_sFile,"rb"); |
|
| 183 | + $read = fread($file,10); |
|
| 184 | + while(!feof($file)&&($read<>"")) |
|
| 185 | + $read .= fread($file,1024); |
|
| 186 | + |
|
| 187 | + $temp = unpack("H*",$read); |
|
| 188 | + $hex = $temp[1]; |
|
| 189 | + $header = substr($hex,0,108); |
|
| 190 | + |
|
| 191 | + // Process the header |
|
| 192 | + // Structure: http://www.fastgraph.com/help/bmp_header_format.html |
|
| 193 | + if (substr($header,0,4)=="424d") |
|
| 194 | + { |
|
| 195 | + // Cut it in parts of 2 bytes |
|
| 196 | + $header_parts = str_split($header,2); |
|
| 197 | + |
|
| 198 | + // Get the width 4 bytes |
|
| 199 | + $width = hexdec($header_parts[19].$header_parts[18]); |
|
| 200 | + |
|
| 201 | + // Get the height 4 bytes |
|
| 202 | + $height = hexdec($header_parts[23].$header_parts[22]); |
|
| 203 | + |
|
| 204 | + // Unset the header params |
|
| 205 | + unset($header_parts); |
|
| 206 | + } |
|
| 207 | + |
|
| 208 | + // Define starting X and Y |
|
| 209 | + $x = 0; |
|
| 210 | + $y = 1; |
|
| 211 | + |
|
| 212 | + // Create newimage |
|
| 213 | + $image = imagecreatetruecolor($width,$height); |
|
| 214 | + |
|
| 215 | + // Grab the body from the image |
|
| 216 | + $body = substr($hex,108); |
|
| 217 | + |
|
| 218 | + // Calculate if padding at the end-line is needed |
|
| 219 | + // Divided by two to keep overview. |
|
| 220 | + // 1 byte = 2 HEX-chars |
|
| 221 | + $body_size = (strlen($body)/2); |
|
| 222 | + $header_size = ($width*$height); |
|
| 223 | + |
|
| 224 | + // Use end-line padding? Only when needed |
|
| 225 | + $usePadding = ($body_size>($header_size*3)+4); |
|
| 226 | + |
|
| 227 | + // Using a for-loop with index-calculation instaid of str_split to avoid large memory consumption |
|
| 228 | + // Calculate the next DWORD-position in the body |
|
| 229 | + for ($i=0;$i<$body_size;$i+=3) |
|
| 230 | + { |
|
| 231 | + // Calculate line-ending and padding |
|
| 232 | + if ($x>=$width) |
|
| 233 | + { |
|
| 234 | + // If padding needed, ignore image-padding |
|
| 235 | + // Shift i to the ending of the current 32-bit-block |
|
| 236 | + if ($usePadding) |
|
| 237 | + $i += $width%4; |
|
| 238 | + |
|
| 239 | + // Reset horizontal position |
|
| 240 | + $x = 0; |
|
| 241 | + |
|
| 242 | + // Raise the height-position (bottom-up) |
|
| 243 | + $y++; |
|
| 244 | + |
|
| 245 | + // Reached the image-height? Break the for-loop |
|
| 246 | + if ($y>$height) |
|
| 247 | + break; |
|
| 248 | + } |
|
| 249 | + |
|
| 250 | + // Calculation of the RGB-pixel (defined as BGR in image-data) |
|
| 251 | + // Define $i_pos as absolute position in the body |
|
| 252 | + $i_pos = $i*2; |
|
| 253 | + $r = hexdec($body[$i_pos+4].$body[$i_pos+5]); |
|
| 254 | + $g = hexdec($body[$i_pos+2].$body[$i_pos+3]); |
|
| 255 | + $b = hexdec($body[$i_pos].$body[$i_pos+1]); |
|
| 256 | + |
|
| 257 | + // Calculate and draw the pixel |
|
| 258 | + $color = imagecolorallocate($image,$r,$g,$b); |
|
| 259 | + imagesetpixel($image,$x,$height-$y,$color); |
|
| 260 | + |
|
| 261 | + // Raise the horizontal position |
|
| 262 | + $x++; |
|
| 263 | + } |
|
| 264 | + |
|
| 265 | + // Unset the body / free the memory |
|
| 266 | + unset($body); |
|
| 267 | + |
|
| 268 | + // Return image-object |
|
| 269 | + return $image; |
|
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | } |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | * @return int Angle |
| 153 | 153 | */ |
| 154 | 154 | public static function degreesToAngle($pValue = 0) { |
| 155 | - return (int)round($pValue * 60000); |
|
| 155 | + return (int) round($pValue * 60000); |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | /** |
@@ -179,84 +179,84 @@ discard block |
||
| 179 | 179 | public static function imagecreatefrombmp($p_sFile) |
| 180 | 180 | { |
| 181 | 181 | // Load the image into a string |
| 182 | - $file = fopen($p_sFile,"rb"); |
|
| 183 | - $read = fread($file,10); |
|
| 184 | - while(!feof($file)&&($read<>"")) |
|
| 185 | - $read .= fread($file,1024); |
|
| 182 | + $file = fopen($p_sFile, "rb"); |
|
| 183 | + $read = fread($file, 10); |
|
| 184 | + while ( ! feof($file) && ($read <> "")) |
|
| 185 | + $read .= fread($file, 1024); |
|
| 186 | 186 | |
| 187 | - $temp = unpack("H*",$read); |
|
| 188 | - $hex = $temp[1]; |
|
| 189 | - $header = substr($hex,0,108); |
|
| 187 | + $temp = unpack("H*", $read); |
|
| 188 | + $hex = $temp[1]; |
|
| 189 | + $header = substr($hex, 0, 108); |
|
| 190 | 190 | |
| 191 | 191 | // Process the header |
| 192 | 192 | // Structure: http://www.fastgraph.com/help/bmp_header_format.html |
| 193 | - if (substr($header,0,4)=="424d") |
|
| 193 | + if (substr($header, 0, 4) == "424d") |
|
| 194 | 194 | { |
| 195 | 195 | // Cut it in parts of 2 bytes |
| 196 | - $header_parts = str_split($header,2); |
|
| 196 | + $header_parts = str_split($header, 2); |
|
| 197 | 197 | |
| 198 | 198 | // Get the width 4 bytes |
| 199 | - $width = hexdec($header_parts[19].$header_parts[18]); |
|
| 199 | + $width = hexdec($header_parts[19].$header_parts[18]); |
|
| 200 | 200 | |
| 201 | 201 | // Get the height 4 bytes |
| 202 | - $height = hexdec($header_parts[23].$header_parts[22]); |
|
| 202 | + $height = hexdec($header_parts[23].$header_parts[22]); |
|
| 203 | 203 | |
| 204 | 204 | // Unset the header params |
| 205 | 205 | unset($header_parts); |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | // Define starting X and Y |
| 209 | - $x = 0; |
|
| 210 | - $y = 1; |
|
| 209 | + $x = 0; |
|
| 210 | + $y = 1; |
|
| 211 | 211 | |
| 212 | 212 | // Create newimage |
| 213 | - $image = imagecreatetruecolor($width,$height); |
|
| 213 | + $image = imagecreatetruecolor($width, $height); |
|
| 214 | 214 | |
| 215 | 215 | // Grab the body from the image |
| 216 | - $body = substr($hex,108); |
|
| 216 | + $body = substr($hex, 108); |
|
| 217 | 217 | |
| 218 | 218 | // Calculate if padding at the end-line is needed |
| 219 | 219 | // Divided by two to keep overview. |
| 220 | 220 | // 1 byte = 2 HEX-chars |
| 221 | - $body_size = (strlen($body)/2); |
|
| 222 | - $header_size = ($width*$height); |
|
| 221 | + $body_size = (strlen($body) / 2); |
|
| 222 | + $header_size = ($width * $height); |
|
| 223 | 223 | |
| 224 | 224 | // Use end-line padding? Only when needed |
| 225 | - $usePadding = ($body_size>($header_size*3)+4); |
|
| 225 | + $usePadding = ($body_size > ($header_size * 3) + 4); |
|
| 226 | 226 | |
| 227 | 227 | // Using a for-loop with index-calculation instaid of str_split to avoid large memory consumption |
| 228 | 228 | // Calculate the next DWORD-position in the body |
| 229 | - for ($i=0;$i<$body_size;$i+=3) |
|
| 229 | + for ($i = 0; $i < $body_size; $i += 3) |
|
| 230 | 230 | { |
| 231 | 231 | // Calculate line-ending and padding |
| 232 | - if ($x>=$width) |
|
| 232 | + if ($x >= $width) |
|
| 233 | 233 | { |
| 234 | 234 | // If padding needed, ignore image-padding |
| 235 | 235 | // Shift i to the ending of the current 32-bit-block |
| 236 | 236 | if ($usePadding) |
| 237 | - $i += $width%4; |
|
| 237 | + $i += $width % 4; |
|
| 238 | 238 | |
| 239 | 239 | // Reset horizontal position |
| 240 | - $x = 0; |
|
| 240 | + $x = 0; |
|
| 241 | 241 | |
| 242 | 242 | // Raise the height-position (bottom-up) |
| 243 | 243 | $y++; |
| 244 | 244 | |
| 245 | 245 | // Reached the image-height? Break the for-loop |
| 246 | - if ($y>$height) |
|
| 246 | + if ($y > $height) |
|
| 247 | 247 | break; |
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | // Calculation of the RGB-pixel (defined as BGR in image-data) |
| 251 | 251 | // Define $i_pos as absolute position in the body |
| 252 | - $i_pos = $i*2; |
|
| 253 | - $r = hexdec($body[$i_pos+4].$body[$i_pos+5]); |
|
| 254 | - $g = hexdec($body[$i_pos+2].$body[$i_pos+3]); |
|
| 255 | - $b = hexdec($body[$i_pos].$body[$i_pos+1]); |
|
| 252 | + $i_pos = $i * 2; |
|
| 253 | + $r = hexdec($body[$i_pos + 4].$body[$i_pos + 5]); |
|
| 254 | + $g = hexdec($body[$i_pos + 2].$body[$i_pos + 3]); |
|
| 255 | + $b = hexdec($body[$i_pos].$body[$i_pos + 1]); |
|
| 256 | 256 | |
| 257 | 257 | // Calculate and draw the pixel |
| 258 | - $color = imagecolorallocate($image,$r,$g,$b); |
|
| 259 | - imagesetpixel($image,$x,$height-$y,$color); |
|
| 258 | + $color = imagecolorallocate($image, $r, $g, $b); |
|
| 259 | + imagesetpixel($image, $x, $height - $y, $color); |
|
| 260 | 260 | |
| 261 | 261 | // Raise the horizontal position |
| 262 | 262 | $x++; |
@@ -181,8 +181,9 @@ discard block |
||
| 181 | 181 | // Load the image into a string |
| 182 | 182 | $file = fopen($p_sFile,"rb"); |
| 183 | 183 | $read = fread($file,10); |
| 184 | - while(!feof($file)&&($read<>"")) |
|
| 185 | - $read .= fread($file,1024); |
|
| 184 | + while(!feof($file)&&($read<>"")) { |
|
| 185 | + $read .= fread($file,1024); |
|
| 186 | + } |
|
| 186 | 187 | |
| 187 | 188 | $temp = unpack("H*",$read); |
| 188 | 189 | $hex = $temp[1]; |
@@ -233,8 +234,9 @@ discard block |
||
| 233 | 234 | { |
| 234 | 235 | // If padding needed, ignore image-padding |
| 235 | 236 | // Shift i to the ending of the current 32-bit-block |
| 236 | - if ($usePadding) |
|
| 237 | - $i += $width%4; |
|
| 237 | + if ($usePadding) { |
|
| 238 | + $i += $width%4; |
|
| 239 | + } |
|
| 238 | 240 | |
| 239 | 241 | // Reset horizontal position |
| 240 | 242 | $x = 0; |
@@ -243,8 +245,9 @@ discard block |
||
| 243 | 245 | $y++; |
| 244 | 246 | |
| 245 | 247 | // Reached the image-height? Break the for-loop |
| 246 | - if ($y>$height) |
|
| 247 | - break; |
|
| 248 | + if ($y>$height) { |
|
| 249 | + break; |
|
| 250 | + } |
|
| 248 | 251 | } |
| 249 | 252 | |
| 250 | 253 | // Calculation of the RGB-pixel (defined as BGR in image-data) |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | /** |
| 185 | 185 | * Get the shape index |
| 186 | 186 | * |
| 187 | - * @return int |
|
| 187 | + * @return boolean |
|
| 188 | 188 | */ |
| 189 | 189 | public function getSpId() |
| 190 | 190 | { |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | * Set an option for the Shape Group Container |
| 196 | 196 | * |
| 197 | 197 | * @param int $property The number specifies the option |
| 198 | - * @param mixed $value |
|
| 198 | + * @param integer $value |
|
| 199 | 199 | */ |
| 200 | 200 | public function setOPT($property, $value) |
| 201 | 201 | { |
@@ -309,7 +309,6 @@ discard block |
||
| 309 | 309 | /** |
| 310 | 310 | * Set offset in x-direction of bottom-right corner of shape measured in 1/1024 of column width |
| 311 | 311 | * |
| 312 | - * @param int $startOffsetX |
|
| 313 | 312 | */ |
| 314 | 313 | public function setEndOffsetX($endOffsetX = 0) |
| 315 | 314 | { |
@@ -136,9 +136,9 @@ discard block |
||
| 136 | 136 | * |
| 137 | 137 | * @param PHPExcel_Worksheet $sheet |
| 138 | 138 | * @param string $startColumn |
| 139 | - * @param integer $startOffset Offset within start cell measured in 1/1024 of the cell width |
|
| 139 | + * @param integer $startOffsetX Offset within start cell measured in 1/1024 of the cell width |
|
| 140 | 140 | * @param string $endColumn |
| 141 | - * @param integer $endOffset Offset within end cell measured in 1/1024 of the cell width |
|
| 141 | + * @param integer $endOffsetX Offset within end cell measured in 1/1024 of the cell width |
|
| 142 | 142 | * @return integer Horizontal measured in pixels |
| 143 | 143 | */ |
| 144 | 144 | public static function getDistanceX(PHPExcel_Worksheet $sheet, $startColumn = 'A', $startOffsetX = 0, $endColumn = 'A', $endOffsetX = 0) |
@@ -166,10 +166,10 @@ discard block |
||
| 166 | 166 | * The distanceY is found as sum of all the spanning rows minus two offsets |
| 167 | 167 | * |
| 168 | 168 | * @param PHPExcel_Worksheet $sheet |
| 169 | - * @param string $startRow (1-based) |
|
| 170 | - * @param integer $startOffset Offset within start cell measured in 1/256 of the cell height |
|
| 171 | - * @param string $endRow (1-based) |
|
| 172 | - * @param integer $endOffset Offset within end cell measured in 1/256 of the cell height |
|
| 169 | + * @param integer $startRow (1-based) |
|
| 170 | + * @param integer $startOffsetY Offset within start cell measured in 1/256 of the cell height |
|
| 171 | + * @param integer $endRow (1-based) |
|
| 172 | + * @param integer $endOffsetY Offset within end cell measured in 1/256 of the cell height |
|
| 173 | 173 | * @return integer Vertical distance measured in pixels |
| 174 | 174 | */ |
| 175 | 175 | public static function getDistanceY(PHPExcel_Worksheet $sheet, $startRow = 1, $startOffsetY = 0, $endRow = 1, $endOffsetY = 0) |
@@ -42,7 +42,7 @@ |
||
| 42 | 42 | * @param PHPExcel_Worksheet $sheet The sheet |
| 43 | 43 | * @param integer $col The column |
| 44 | 44 | * @return integer The width in pixels |
| 45 | - */ |
|
| 45 | + */ |
|
| 46 | 46 | public static function sizeCol($sheet, $col = 'A') |
| 47 | 47 | { |
| 48 | 48 | // default font of the workbook |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | $columnDimensions = $sheet->getColumnDimensions(); |
| 52 | 52 | |
| 53 | 53 | // first find the true column width in pixels (uncollapsed and unhidden) |
| 54 | - if ( isset($columnDimensions[$col]) and $columnDimensions[$col]->getWidth() != -1 ) { |
|
| 54 | + if (isset($columnDimensions[$col]) and $columnDimensions[$col]->getWidth() != -1) { |
|
| 55 | 55 | |
| 56 | 56 | // then we have column dimension with explicit width |
| 57 | 57 | $columnDimension = $columnDimensions[$col]; |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | // now find the effective column width in pixels |
| 75 | - if (isset($columnDimensions[$col]) and !$columnDimensions[$col]->getVisible()) { |
|
| 75 | + if (isset($columnDimensions[$col]) and ! $columnDimensions[$col]->getVisible()) { |
|
| 76 | 76 | $effectivePixelWidth = 0; |
| 77 | 77 | } else { |
| 78 | 78 | $effectivePixelWidth = $pixelWidth; |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | $rowDimensions = $sheet->getRowDimensions(); |
| 99 | 99 | |
| 100 | 100 | // first find the true row height in pixels (uncollapsed and unhidden) |
| 101 | - if ( isset($rowDimensions[$row]) and $rowDimensions[$row]->getRowHeight() != -1) { |
|
| 101 | + if (isset($rowDimensions[$row]) and $rowDimensions[$row]->getRowHeight() != -1) { |
|
| 102 | 102 | |
| 103 | 103 | // then we have a row dimension |
| 104 | 104 | $rowDimension = $rowDimensions[$row]; |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | // now find the effective row height in pixels |
| 124 | - if ( isset($rowDimensions[$row]) and !$rowDimensions[$row]->getVisible() ) { |
|
| 124 | + if (isset($rowDimensions[$row]) and ! $rowDimensions[$row]->getVisible()) { |
|
| 125 | 125 | $effectivePixelRowHeight = 0; |
| 126 | 126 | } else { |
| 127 | 127 | $effectivePixelRowHeight = $pixelRowHeight; |
@@ -252,8 +252,8 @@ discard block |
||
| 252 | 252 | $y1 = $offsetY; |
| 253 | 253 | |
| 254 | 254 | // Initialise end cell to the same as the start cell |
| 255 | - $col_end = $col_start; // Col containing lower right corner of object |
|
| 256 | - $row_end = $row_start; // Row containing bottom right corner of object |
|
| 255 | + $col_end = $col_start; // Col containing lower right corner of object |
|
| 256 | + $row_end = $row_start; // Row containing bottom right corner of object |
|
| 257 | 257 | |
| 258 | 258 | // Zero the specified offset if greater than the cell dimensions |
| 259 | 259 | if ($x1 >= self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($col_start))) { |
@@ -263,8 +263,8 @@ discard block |
||
| 263 | 263 | $y1 = 0; |
| 264 | 264 | } |
| 265 | 265 | |
| 266 | - $width = $width + $x1 -1; |
|
| 267 | - $height = $height + $y1 -1; |
|
| 266 | + $width = $width + $x1 - 1; |
|
| 267 | + $height = $height + $y1 - 1; |
|
| 268 | 268 | |
| 269 | 269 | // Subtract the underlying cell widths to find the end cell of the image |
| 270 | 270 | while ($width >= self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($col_end))) { |
@@ -283,24 +283,24 @@ discard block |
||
| 283 | 283 | if (self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($col_start)) == 0) { |
| 284 | 284 | return; |
| 285 | 285 | } |
| 286 | - if (self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($col_end)) == 0) { |
|
| 286 | + if (self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($col_end)) == 0) { |
|
| 287 | 287 | return; |
| 288 | 288 | } |
| 289 | 289 | if (self::sizeRow($sheet, $row_start + 1) == 0) { |
| 290 | 290 | return; |
| 291 | 291 | } |
| 292 | - if (self::sizeRow($sheet, $row_end + 1) == 0) { |
|
| 292 | + if (self::sizeRow($sheet, $row_end + 1) == 0) { |
|
| 293 | 293 | return; |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | // Convert the pixel values to the percentage value expected by Excel |
| 297 | - $x1 = $x1 / self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($col_start)) * 1024; |
|
| 298 | - $y1 = $y1 / self::sizeRow($sheet, $row_start + 1) * 256; |
|
| 299 | - $x2 = ($width + 1) / self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($col_end)) * 1024; // Distance to right side of object |
|
| 300 | - $y2 = ($height + 1) / self::sizeRow($sheet, $row_end + 1) * 256; // Distance to bottom of object |
|
| 297 | + $x1 = $x1 / self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($col_start)) * 1024; |
|
| 298 | + $y1 = $y1 / self::sizeRow($sheet, $row_start + 1) * 256; |
|
| 299 | + $x2 = ($width + 1) / self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($col_end)) * 1024; // Distance to right side of object |
|
| 300 | + $y2 = ($height + 1) / self::sizeRow($sheet, $row_end + 1) * 256; // Distance to bottom of object |
|
| 301 | 301 | |
| 302 | - $startCoordinates = PHPExcel_Cell::stringFromColumnIndex($col_start) . ($row_start + 1); |
|
| 303 | - $endCoordinates = PHPExcel_Cell::stringFromColumnIndex($col_end) . ($row_end + 1); |
|
| 302 | + $startCoordinates = PHPExcel_Cell::stringFromColumnIndex($col_start).($row_start + 1); |
|
| 303 | + $endCoordinates = PHPExcel_Cell::stringFromColumnIndex($col_end).($row_end + 1); |
|
| 304 | 304 | |
| 305 | 305 | $twoAnchor = array( |
| 306 | 306 | 'startCoordinates' => $startCoordinates, |