| Conditions | 347 | 
| Paths | > 20000 | 
| Total Lines | 1250 | 
| Code Lines | 764 | 
| Lines | 171 | 
| Ratio | 13.68 % | 
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php  | 
            ||
| 483 | public function load($pFilename)  | 
            ||
| 484 | 	{ | 
            ||
| 485 | // Check if file exists  | 
            ||
| 486 | 		if (!file_exists($pFilename)) { | 
            ||
| 487 | 			throw new Exception("Could not open " . $pFilename . " for reading! File does not exist."); | 
            ||
| 488 | }  | 
            ||
| 489 | |||
| 490 | // Initialisations  | 
            ||
| 491 | $excel = new PHPExcel;  | 
            ||
| 492 | $excel->removeSheetByIndex(0);  | 
            ||
| 493 | 		if (!$this->_readDataOnly) { | 
            ||
| 494 | $excel->removeCellStyleXfByIndex(0); // remove the default style  | 
            ||
| 495 | $excel->removeCellXfByIndex(0); // remove the default style  | 
            ||
| 496 | }  | 
            ||
| 497 | $zip = new ZipArchive;  | 
            ||
| 498 | $zip->open($pFilename);  | 
            ||
| 499 | |||
| 500 | // Read the theme first, because we need the colour scheme when reading the styles  | 
            ||
| 501 | $wbRels = simplexml_load_string($this->_getFromZipArchive($zip, "xl/_rels/workbook.xml.rels")); //~ http://schemas.openxmlformats.org/package/2006/relationships");  | 
            ||
| 502 | 		foreach ($wbRels->Relationship as $rel) { | 
            ||
| 503 | 			switch ($rel["Type"]) { | 
            ||
| 504 | case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme":  | 
            ||
| 505 | 					$themeOrderArray = array('lt1','dk1','lt2','dk2'); | 
            ||
| 506 | $themeOrderAdditional = count($themeOrderArray);  | 
            ||
| 507 | |||
| 508 | 					$xmlTheme = simplexml_load_string($this->_getFromZipArchive($zip, "xl/{$rel['Target']}")); | 
            ||
| 509 | 					if (is_object($xmlTheme)) { | 
            ||
| 510 | $xmlThemeName = $xmlTheme->attributes();  | 
            ||
| 511 | 						$xmlTheme = $xmlTheme->children("http://schemas.openxmlformats.org/drawingml/2006/main"); | 
            ||
| 512 | $themeName = (string)$xmlThemeName['name'];  | 
            ||
| 513 | |||
| 514 | $colourScheme = $xmlTheme->themeElements->clrScheme->attributes();  | 
            ||
| 515 | $colourSchemeName = (string)$colourScheme['name'];  | 
            ||
| 516 | 						$colourScheme = $xmlTheme->themeElements->clrScheme->children("http://schemas.openxmlformats.org/drawingml/2006/main"); | 
            ||
| 517 | |||
| 518 | $themeColours = array();  | 
            ||
| 519 | 						foreach ($colourScheme as $k => $xmlColour) { | 
            ||
| 520 | $themePos = array_search($k,$themeOrderArray);  | 
            ||
| 521 | 							if ($themePos === false) { | 
            ||
| 522 | $themePos = $themeOrderAdditional++;  | 
            ||
| 523 | }  | 
            ||
| 524 | 							if (isset($xmlColour->sysClr)) { | 
            ||
| 525 | $xmlColourData = $xmlColour->sysClr->attributes();  | 
            ||
| 526 | $themeColours[$themePos] = $xmlColourData['lastClr'];  | 
            ||
| 527 | 							} elseif (isset($xmlColour->srgbClr)) { | 
            ||
| 528 | $xmlColourData = $xmlColour->srgbClr->attributes();  | 
            ||
| 529 | $themeColours[$themePos] = $xmlColourData['val'];  | 
            ||
| 530 | }  | 
            ||
| 531 | }  | 
            ||
| 532 | self::$_theme = new PHPExcel_Reader_Excel2007_Theme($themeName,$colourSchemeName,$themeColours);  | 
            ||
| 533 | }  | 
            ||
| 534 | break;  | 
            ||
| 535 | }  | 
            ||
| 536 | }  | 
            ||
| 537 | |||
| 538 | $rels = simplexml_load_string($this->_getFromZipArchive($zip, "_rels/.rels")); //~ http://schemas.openxmlformats.org/package/2006/relationships");  | 
            ||
| 539 | 		foreach ($rels->Relationship as $rel) { | 
            ||
| 540 | 			switch ($rel["Type"]) { | 
            ||
| 541 | case "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties":  | 
            ||
| 542 | 					$xmlCore = simplexml_load_string($this->_getFromZipArchive($zip, "{$rel['Target']}")); | 
            ||
| 543 | 					if (is_object($xmlCore)) { | 
            ||
| 544 | 						$xmlCore->registerXPathNamespace("dc", "http://purl.org/dc/elements/1.1/"); | 
            ||
| 545 | 						$xmlCore->registerXPathNamespace("dcterms", "http://purl.org/dc/terms/"); | 
            ||
| 546 | 						$xmlCore->registerXPathNamespace("cp", "http://schemas.openxmlformats.org/package/2006/metadata/core-properties"); | 
            ||
| 547 | $docProps = $excel->getProperties();  | 
            ||
| 548 | 						$docProps->setCreator((string) self::array_item($xmlCore->xpath("dc:creator"))); | 
            ||
| 549 | 						$docProps->setLastModifiedBy((string) self::array_item($xmlCore->xpath("cp:lastModifiedBy"))); | 
            ||
| 550 | 						$docProps->setCreated(strtotime(self::array_item($xmlCore->xpath("dcterms:created")))); //! respect xsi:type | 
            ||
| 551 | 						$docProps->setModified(strtotime(self::array_item($xmlCore->xpath("dcterms:modified")))); //! respect xsi:type | 
            ||
| 552 | 						$docProps->setTitle((string) self::array_item($xmlCore->xpath("dc:title"))); | 
            ||
| 553 | 						$docProps->setDescription((string) self::array_item($xmlCore->xpath("dc:description"))); | 
            ||
| 554 | 						$docProps->setSubject((string) self::array_item($xmlCore->xpath("dc:subject"))); | 
            ||
| 555 | 						$docProps->setKeywords((string) self::array_item($xmlCore->xpath("cp:keywords"))); | 
            ||
| 556 | 						$docProps->setCategory((string) self::array_item($xmlCore->xpath("cp:category"))); | 
            ||
| 557 | }  | 
            ||
| 558 | break;  | 
            ||
| 559 | |||
| 560 | case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties":  | 
            ||
| 561 | 					$xmlCore = simplexml_load_string($this->_getFromZipArchive($zip, "{$rel['Target']}")); | 
            ||
| 562 | 					if (is_object($xmlCore)) { | 
            ||
| 563 | $docProps = $excel->getProperties();  | 
            ||
| 564 | if (isset($xmlCore->Company))  | 
            ||
| 565 | $docProps->setCompany((string) $xmlCore->Company);  | 
            ||
| 566 | if (isset($xmlCore->Manager))  | 
            ||
| 567 | $docProps->setManager((string) $xmlCore->Manager);  | 
            ||
| 568 | }  | 
            ||
| 569 | break;  | 
            ||
| 570 | |||
| 571 | case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties":  | 
            ||
| 572 | 					$xmlCore = simplexml_load_string($this->_getFromZipArchive($zip, "{$rel['Target']}")); | 
            ||
| 573 | 					if (is_object($xmlCore)) { | 
            ||
| 574 | $docProps = $excel->getProperties();  | 
            ||
| 575 | 						foreach ($xmlCore as $xmlProperty) { | 
            ||
| 576 | $cellDataOfficeAttributes = $xmlProperty->attributes();  | 
            ||
| 577 | 							if (isset($cellDataOfficeAttributes['name'])) { | 
            ||
| 578 | $propertyName = (string) $cellDataOfficeAttributes['name'];  | 
            ||
| 579 | 								$cellDataOfficeChildren = $xmlProperty->children('http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes'); | 
            ||
| 580 | $attributeType = $cellDataOfficeChildren->getName();  | 
            ||
| 581 | 								$attributeValue = (string) $cellDataOfficeChildren->{$attributeType}; | 
            ||
| 582 | $attributeValue = PHPExcel_DocumentProperties::convertProperty($attributeValue,$attributeType);  | 
            ||
| 583 | $attributeType = PHPExcel_DocumentProperties::convertPropertyType($attributeType);  | 
            ||
| 584 | $docProps->setCustomProperty($propertyName,$attributeValue,$attributeType);  | 
            ||
| 585 | }  | 
            ||
| 586 | }  | 
            ||
| 587 | }  | 
            ||
| 588 | break;  | 
            ||
| 589 | |||
| 590 | case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument":  | 
            ||
| 591 | $dir = dirname($rel["Target"]);  | 
            ||
| 592 | $relsWorkbook = simplexml_load_string($this->_getFromZipArchive($zip, "$dir/_rels/" . basename($rel["Target"]) . ".rels")); //~ http://schemas.openxmlformats.org/package/2006/relationships");  | 
            ||
| 593 | 					$relsWorkbook->registerXPathNamespace("rel", "http://schemas.openxmlformats.org/package/2006/relationships"); | 
            ||
| 594 | |||
| 595 | $sharedStrings = array();  | 
            ||
| 596 | 					$xpath = self::array_item($relsWorkbook->xpath("rel:Relationship[@Type='http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings']")); | 
            ||
| 597 | $xmlStrings = simplexml_load_string($this->_getFromZipArchive($zip, "$dir/$xpath[Target]")); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main");  | 
            ||
| 598 | 					if (isset($xmlStrings) && isset($xmlStrings->si)) { | 
            ||
| 599 | 						foreach ($xmlStrings->si as $val) { | 
            ||
| 600 | 							if (isset($val->t)) { | 
            ||
| 601 | $sharedStrings[] = PHPExcel_Shared_String::ControlCharacterOOXML2PHP( (string) $val->t );  | 
            ||
| 602 | 							} elseif (isset($val->r)) { | 
            ||
| 603 | $sharedStrings[] = $this->_parseRichText($val);  | 
            ||
| 604 | }  | 
            ||
| 605 | }  | 
            ||
| 606 | }  | 
            ||
| 607 | |||
| 608 | $worksheets = array();  | 
            ||
| 609 | View Code Duplication | 					foreach ($relsWorkbook->Relationship as $ele) { | 
            |
| 610 | 						if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet") { | 
            ||
| 611 | $worksheets[(string) $ele["Id"]] = $ele["Target"];  | 
            ||
| 612 | }  | 
            ||
| 613 | }  | 
            ||
| 614 | |||
| 615 | $styles = array();  | 
            ||
| 616 | $cellStyles = array();  | 
            ||
| 617 | 					$xpath = self::array_item($relsWorkbook->xpath("rel:Relationship[@Type='http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles']")); | 
            ||
| 618 | $xmlStyles = simplexml_load_string($this->_getFromZipArchive($zip, "$dir/$xpath[Target]")); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main");  | 
            ||
| 619 | $numFmts = null;  | 
            ||
| 620 | 					if ($xmlStyles && $xmlStyles->numFmts[0]) { | 
            ||
| 621 | $numFmts = $xmlStyles->numFmts[0];  | 
            ||
| 622 | }  | 
            ||
| 623 | 					if (isset($numFmts) && ($numFmts !== NULL)) { | 
            ||
| 624 | 						$numFmts->registerXPathNamespace("sml", "http://schemas.openxmlformats.org/spreadsheetml/2006/main"); | 
            ||
| 625 | }  | 
            ||
| 626 | 					if (!$this->_readDataOnly && $xmlStyles) { | 
            ||
| 627 | View Code Duplication | 						foreach ($xmlStyles->cellXfs->xf as $xf) { | 
            |
| 628 | $numFmt = PHPExcel_Style_NumberFormat::FORMAT_GENERAL;  | 
            ||
| 629 | |||
| 630 | 							if ($xf["numFmtId"]) { | 
            ||
| 631 | 								if (isset($numFmts)) { | 
            ||
| 632 | 									$tmpNumFmt = self::array_item($numFmts->xpath("sml:numFmt[@numFmtId=$xf[numFmtId]]")); | 
            ||
| 633 | |||
| 634 | 									if (isset($tmpNumFmt["formatCode"])) { | 
            ||
| 635 | $numFmt = (string) $tmpNumFmt["formatCode"];  | 
            ||
| 636 | }  | 
            ||
| 637 | }  | 
            ||
| 638 | |||
| 639 | 								if ((int)$xf["numFmtId"] < 164) { | 
            ||
| 640 | $numFmt = PHPExcel_Style_NumberFormat::builtInFormatCode((int)$xf["numFmtId"]);  | 
            ||
| 641 | }  | 
            ||
| 642 | }  | 
            ||
| 643 | 							//$numFmt = str_replace('mm', 'i', $numFmt); | 
            ||
| 644 | 							//$numFmt = str_replace('h', 'H', $numFmt); | 
            ||
| 645 | |||
| 646 | $style = (object) array(  | 
            ||
| 647 | "numFmt" => $numFmt,  | 
            ||
| 648 | "font" => $xmlStyles->fonts->font[intval($xf["fontId"])],  | 
            ||
| 649 | "fill" => $xmlStyles->fills->fill[intval($xf["fillId"])],  | 
            ||
| 650 | "border" => $xmlStyles->borders->border[intval($xf["borderId"])],  | 
            ||
| 651 | "alignment" => $xf->alignment,  | 
            ||
| 652 | "protection" => $xf->protection,  | 
            ||
| 653 | );  | 
            ||
| 654 | $styles[] = $style;  | 
            ||
| 655 | |||
| 656 | // add style to cellXf collection  | 
            ||
| 657 | $objStyle = new PHPExcel_Style;  | 
            ||
| 658 | self::_readStyle($objStyle, $style);  | 
            ||
| 659 | $excel->addCellXf($objStyle);  | 
            ||
| 660 | }  | 
            ||
| 661 | |||
| 662 | View Code Duplication | 						foreach ($xmlStyles->cellStyleXfs->xf as $xf) { | 
            |
| 663 | $numFmt = PHPExcel_Style_NumberFormat::FORMAT_GENERAL;  | 
            ||
| 664 | 							if ($numFmts && $xf["numFmtId"]) { | 
            ||
| 665 | 								$tmpNumFmt = self::array_item($numFmts->xpath("sml:numFmt[@numFmtId=$xf[numFmtId]]")); | 
            ||
| 666 | 								if (isset($tmpNumFmt["formatCode"])) { | 
            ||
| 667 | $numFmt = (string) $tmpNumFmt["formatCode"];  | 
            ||
| 668 | 								} else if ((int)$xf["numFmtId"] < 165) { | 
            ||
| 669 | $numFmt = PHPExcel_Style_NumberFormat::builtInFormatCode((int)$xf["numFmtId"]);  | 
            ||
| 670 | }  | 
            ||
| 671 | }  | 
            ||
| 672 | |||
| 673 | $cellStyle = (object) array(  | 
            ||
| 674 | "numFmt" => $numFmt,  | 
            ||
| 675 | "font" => $xmlStyles->fonts->font[intval($xf["fontId"])],  | 
            ||
| 676 | "fill" => $xmlStyles->fills->fill[intval($xf["fillId"])],  | 
            ||
| 677 | "border" => $xmlStyles->borders->border[intval($xf["borderId"])],  | 
            ||
| 678 | "alignment" => $xf->alignment,  | 
            ||
| 679 | "protection" => $xf->protection,  | 
            ||
| 680 | );  | 
            ||
| 681 | $cellStyles[] = $cellStyle;  | 
            ||
| 682 | |||
| 683 | // add style to cellStyleXf collection  | 
            ||
| 684 | $objStyle = new PHPExcel_Style;  | 
            ||
| 685 | self::_readStyle($objStyle, $cellStyle);  | 
            ||
| 686 | $excel->addCellStyleXf($objStyle);  | 
            ||
| 687 | }  | 
            ||
| 688 | }  | 
            ||
| 689 | |||
| 690 | $dxfs = array();  | 
            ||
| 691 | 					if (!$this->_readDataOnly && $xmlStyles) { | 
            ||
| 692 | 						if ($xmlStyles->dxfs) { | 
            ||
| 693 | 							foreach ($xmlStyles->dxfs->dxf as $dxf) { | 
            ||
| 694 | $style = new PHPExcel_Style;  | 
            ||
| 695 | self::_readStyle($style, $dxf);  | 
            ||
| 696 | $dxfs[] = $style;  | 
            ||
| 697 | }  | 
            ||
| 698 | }  | 
            ||
| 699 | |||
| 700 | if ($xmlStyles->cellStyles)  | 
            ||
| 701 | 						{ | 
            ||
| 702 | 							foreach ($xmlStyles->cellStyles->cellStyle as $cellStyle) { | 
            ||
| 703 | 								if (intval($cellStyle['builtinId']) == 0) { | 
            ||
| 704 | 									if (isset($cellStyles[intval($cellStyle['xfId'])])) { | 
            ||
| 705 | // Set default style  | 
            ||
| 706 | $style = new PHPExcel_Style;  | 
            ||
| 707 | self::_readStyle($style, $cellStyles[intval($cellStyle['xfId'])]);  | 
            ||
| 708 | |||
| 709 | // normal style, currently not using it for anything  | 
            ||
| 710 | }  | 
            ||
| 711 | }  | 
            ||
| 712 | }  | 
            ||
| 713 | }  | 
            ||
| 714 | }  | 
            ||
| 715 | |||
| 716 | 					$xmlWorkbook = simplexml_load_string($this->_getFromZipArchive($zip, "{$rel['Target']}"));  //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"); | 
            ||
| 717 | |||
| 718 | // Set base date  | 
            ||
| 719 | 					if ($xmlWorkbook->workbookPr) { | 
            ||
| 720 | PHPExcel_Shared_Date::setExcelCalendar(PHPExcel_Shared_Date::CALENDAR_WINDOWS_1900);  | 
            ||
| 721 | 						if (isset($xmlWorkbook->workbookPr['date1904'])) { | 
            ||
| 722 | $date1904 = (string)$xmlWorkbook->workbookPr['date1904'];  | 
            ||
| 723 | 							if ($date1904 == "true" || $date1904 == "1") { | 
            ||
| 724 | PHPExcel_Shared_Date::setExcelCalendar(PHPExcel_Shared_Date::CALENDAR_MAC_1904);  | 
            ||
| 725 | }  | 
            ||
| 726 | }  | 
            ||
| 727 | }  | 
            ||
| 728 | |||
| 729 | $sheetId = 0; // keep track of new sheet id in final workbook  | 
            ||
| 730 | $oldSheetId = -1; // keep track of old sheet id in final workbook  | 
            ||
| 731 | $countSkippedSheets = 0; // keep track of number of skipped sheets  | 
            ||
| 732 | $mapSheetId = array(); // mapping of sheet ids from old to new  | 
            ||
| 733 | |||
| 734 | |||
| 735 | $charts = $chartDetails = array();  | 
            ||
| 736 | |||
| 737 | 					if ($xmlWorkbook->sheets) { | 
            ||
| 738 | 						foreach ($xmlWorkbook->sheets->sheet as $eleSheet) { | 
            ||
| 739 | ++$oldSheetId;  | 
            ||
| 740 | |||
| 741 | // Check if sheet should be skipped  | 
            ||
| 742 | 							if (isset($this->_loadSheetsOnly) && !in_array((string) $eleSheet["name"], $this->_loadSheetsOnly)) { | 
            ||
| 743 | ++$countSkippedSheets;  | 
            ||
| 744 | $mapSheetId[$oldSheetId] = null;  | 
            ||
| 745 | continue;  | 
            ||
| 746 | }  | 
            ||
| 747 | |||
| 748 | // Map old sheet id in original workbook to new sheet id.  | 
            ||
| 749 | // They will differ if loadSheetsOnly() is being used  | 
            ||
| 750 | $mapSheetId[$oldSheetId] = $oldSheetId - $countSkippedSheets;  | 
            ||
| 751 | |||
| 752 | // Load sheet  | 
            ||
| 753 | $docSheet = $excel->createSheet();  | 
            ||
| 754 | // Use false for $updateFormulaCellReferences to prevent adjustment of worksheet  | 
            ||
| 755 | // references in formula cells... during the load, all formulae should be correct,  | 
            ||
| 756 | // and we're simply bringing the worksheet name in line with the formula, not the  | 
            ||
| 757 | // reverse  | 
            ||
| 758 | $docSheet->setTitle((string) $eleSheet["name"],false);  | 
            ||
| 759 | 							$fileWorksheet = $worksheets[(string) self::array_item($eleSheet->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "id")]; | 
            ||
| 760 | $xmlSheet = simplexml_load_string($this->_getFromZipArchive($zip, "$dir/$fileWorksheet")); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main");  | 
            ||
| 761 | |||
| 762 | $sharedFormulas = array();  | 
            ||
| 763 | |||
| 764 | 							if (isset($eleSheet["state"]) && (string) $eleSheet["state"] != '') { | 
            ||
| 765 | $docSheet->setSheetState( (string) $eleSheet["state"] );  | 
            ||
| 766 | }  | 
            ||
| 767 | |||
| 768 | 							if (isset($xmlSheet->sheetViews) && isset($xmlSheet->sheetViews->sheetView)) { | 
            ||
| 769 | View Code Duplication | 							    if (isset($xmlSheet->sheetViews->sheetView['zoomScale'])) { | 
            |
| 770 | $docSheet->getSheetView()->setZoomScale( intval($xmlSheet->sheetViews->sheetView['zoomScale']) );  | 
            ||
| 771 | }  | 
            ||
| 772 | |||
| 773 | View Code Duplication | 							    if (isset($xmlSheet->sheetViews->sheetView['zoomScaleNormal'])) { | 
            |
| 774 | $docSheet->getSheetView()->setZoomScaleNormal( intval($xmlSheet->sheetViews->sheetView['zoomScaleNormal']) );  | 
            ||
| 775 | }  | 
            ||
| 776 | |||
| 777 | 								if (isset($xmlSheet->sheetViews->sheetView['showGridLines'])) { | 
            ||
| 778 | $docSheet->setShowGridLines((string)$xmlSheet->sheetViews->sheetView['showGridLines'] ? true : false);  | 
            ||
| 779 | }  | 
            ||
| 780 | |||
| 781 | 								if (isset($xmlSheet->sheetViews->sheetView['showRowColHeaders'])) { | 
            ||
| 782 | $docSheet->setShowRowColHeaders((string)$xmlSheet->sheetViews->sheetView['showRowColHeaders'] ? true : false);  | 
            ||
| 783 | }  | 
            ||
| 784 | |||
| 785 | 								if (isset($xmlSheet->sheetViews->sheetView['rightToLeft'])) { | 
            ||
| 786 | $docSheet->setRightToLeft((string)$xmlSheet->sheetViews->sheetView['rightToLeft'] ? true : false);  | 
            ||
| 787 | }  | 
            ||
| 788 | |||
| 789 | 								if (isset($xmlSheet->sheetViews->sheetView->pane)) { | 
            ||
| 790 | 								    if (isset($xmlSheet->sheetViews->sheetView->pane['topLeftCell'])) { | 
            ||
| 791 | $docSheet->freezePane( (string)$xmlSheet->sheetViews->sheetView->pane['topLeftCell'] );  | 
            ||
| 792 | 								    } else { | 
            ||
| 793 | $xSplit = 0;  | 
            ||
| 794 | $ySplit = 0;  | 
            ||
| 795 | |||
| 796 | View Code Duplication | 								        if (isset($xmlSheet->sheetViews->sheetView->pane['xSplit'])) { | 
            |
| 797 | $xSplit = 1 + intval($xmlSheet->sheetViews->sheetView->pane['xSplit']);  | 
            ||
| 798 | }  | 
            ||
| 799 | |||
| 800 | View Code Duplication | 								    	if (isset($xmlSheet->sheetViews->sheetView->pane['ySplit'])) { | 
            |
| 801 | $ySplit = 1 + intval($xmlSheet->sheetViews->sheetView->pane['ySplit']);  | 
            ||
| 802 | }  | 
            ||
| 803 | |||
| 804 | $docSheet->freezePaneByColumnAndRow($xSplit, $ySplit);  | 
            ||
| 805 | }  | 
            ||
| 806 | }  | 
            ||
| 807 | |||
| 808 | 								if (isset($xmlSheet->sheetViews->sheetView->selection)) { | 
            ||
| 809 | 									if (isset($xmlSheet->sheetViews->sheetView->selection['sqref'])) { | 
            ||
| 810 | $sqref = (string)$xmlSheet->sheetViews->sheetView->selection['sqref'];  | 
            ||
| 811 | 										$sqref = explode(' ', $sqref); | 
            ||
| 812 | $sqref = $sqref[0];  | 
            ||
| 813 | $docSheet->setSelectedCells($sqref);  | 
            ||
| 814 | }  | 
            ||
| 815 | }  | 
            ||
| 816 | |||
| 817 | }  | 
            ||
| 818 | |||
| 819 | 							if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr->tabColor)) { | 
            ||
| 820 | 								if (isset($xmlSheet->sheetPr->tabColor['rgb'])) { | 
            ||
| 821 | $docSheet->getTabColor()->setARGB( (string)$xmlSheet->sheetPr->tabColor['rgb'] );  | 
            ||
| 822 | }  | 
            ||
| 823 | }  | 
            ||
| 824 | |||
| 825 | 							if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr->outlinePr)) { | 
            ||
| 826 | View Code Duplication | 								if (isset($xmlSheet->sheetPr->outlinePr['summaryRight']) && $xmlSheet->sheetPr->outlinePr['summaryRight'] == false) { | 
            |
| 827 | $docSheet->setShowSummaryRight(false);  | 
            ||
| 828 | 								} else { | 
            ||
| 829 | $docSheet->setShowSummaryRight(true);  | 
            ||
| 830 | }  | 
            ||
| 831 | |||
| 832 | View Code Duplication | 								if (isset($xmlSheet->sheetPr->outlinePr['summaryBelow']) && $xmlSheet->sheetPr->outlinePr['summaryBelow'] == false) { | 
            |
| 833 | $docSheet->setShowSummaryBelow(false);  | 
            ||
| 834 | 								} else { | 
            ||
| 835 | $docSheet->setShowSummaryBelow(true);  | 
            ||
| 836 | }  | 
            ||
| 837 | }  | 
            ||
| 838 | |||
| 839 | 							if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr->pageSetUpPr)) { | 
            ||
| 840 | 								if (isset($xmlSheet->sheetPr->pageSetUpPr['fitToPage']) && $xmlSheet->sheetPr->pageSetUpPr['fitToPage'] == false) { | 
            ||
| 841 | $docSheet->getPageSetup()->setFitToPage(false);  | 
            ||
| 842 | 								} else { | 
            ||
| 843 | $docSheet->getPageSetup()->setFitToPage(true);  | 
            ||
| 844 | }  | 
            ||
| 845 | }  | 
            ||
| 846 | |||
| 847 | 							if (isset($xmlSheet->sheetFormatPr)) { | 
            ||
| 848 | 								if (isset($xmlSheet->sheetFormatPr['customHeight']) && ((string)$xmlSheet->sheetFormatPr['customHeight'] == '1' || strtolower((string)$xmlSheet->sheetFormatPr['customHeight']) == 'true') && isset($xmlSheet->sheetFormatPr['defaultRowHeight'])) { | 
            ||
| 849 | $docSheet->getDefaultRowDimension()->setRowHeight( (float)$xmlSheet->sheetFormatPr['defaultRowHeight'] );  | 
            ||
| 850 | }  | 
            ||
| 851 | 								if (isset($xmlSheet->sheetFormatPr['defaultColWidth'])) { | 
            ||
| 852 | $docSheet->getDefaultColumnDimension()->setWidth( (float)$xmlSheet->sheetFormatPr['defaultColWidth'] );  | 
            ||
| 853 | }  | 
            ||
| 854 | }  | 
            ||
| 855 | |||
| 856 | 							if (isset($xmlSheet->cols) && !$this->_readDataOnly) { | 
            ||
| 857 | 								foreach ($xmlSheet->cols->col as $col) { | 
            ||
| 858 | 									for ($i = intval($col["min"]) - 1; $i < intval($col["max"]); ++$i) { | 
            ||
| 859 | 										if ($col["style"] && !$this->_readDataOnly) { | 
            ||
| 860 | $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setXfIndex(intval($col["style"]));  | 
            ||
| 861 | }  | 
            ||
| 862 | 										if ($col["bestFit"]) { | 
            ||
| 863 | //$docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setAutoSize(true);  | 
            ||
| 864 | }  | 
            ||
| 865 | 										if ($col["hidden"]) { | 
            ||
| 866 | $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setVisible(false);  | 
            ||
| 867 | }  | 
            ||
| 868 | 										if ($col["collapsed"]) { | 
            ||
| 869 | $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setCollapsed(true);  | 
            ||
| 870 | }  | 
            ||
| 871 | 										if ($col["outlineLevel"] > 0) { | 
            ||
| 872 | $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setOutlineLevel(intval($col["outlineLevel"]));  | 
            ||
| 873 | }  | 
            ||
| 874 | $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setWidth(floatval($col["width"]));  | 
            ||
| 875 | |||
| 876 | 										if (intval($col["max"]) == 16384) { | 
            ||
| 877 | break;  | 
            ||
| 878 | }  | 
            ||
| 879 | }  | 
            ||
| 880 | }  | 
            ||
| 881 | }  | 
            ||
| 882 | |||
| 883 | 							if (isset($xmlSheet->printOptions) && !$this->_readDataOnly) { | 
            ||
| 884 | 								if ($xmlSheet->printOptions['gridLinesSet'] == 'true' && $xmlSheet->printOptions['gridLinesSet'] == '1') { | 
            ||
| 885 | $docSheet->setShowGridlines(true);  | 
            ||
| 886 | }  | 
            ||
| 887 | |||
| 888 | 								if ($xmlSheet->printOptions['gridLines'] == 'true' || $xmlSheet->printOptions['gridLines'] == '1') { | 
            ||
| 889 | $docSheet->setPrintGridlines(true);  | 
            ||
| 890 | }  | 
            ||
| 891 | |||
| 892 | 								if ($xmlSheet->printOptions['horizontalCentered']) { | 
            ||
| 893 | $docSheet->getPageSetup()->setHorizontalCentered(true);  | 
            ||
| 894 | }  | 
            ||
| 895 | 								if ($xmlSheet->printOptions['verticalCentered']) { | 
            ||
| 896 | $docSheet->getPageSetup()->setVerticalCentered(true);  | 
            ||
| 897 | }  | 
            ||
| 898 | }  | 
            ||
| 899 | |||
| 900 | 							if ($xmlSheet && $xmlSheet->sheetData && $xmlSheet->sheetData->row) { | 
            ||
| 901 | 								foreach ($xmlSheet->sheetData->row as $row) { | 
            ||
| 902 | 									if ($row["ht"] && !$this->_readDataOnly) { | 
            ||
| 903 | $docSheet->getRowDimension(intval($row["r"]))->setRowHeight(floatval($row["ht"]));  | 
            ||
| 904 | }  | 
            ||
| 905 | 									if ($row["hidden"] && !$this->_readDataOnly) { | 
            ||
| 906 | $docSheet->getRowDimension(intval($row["r"]))->setVisible(false);  | 
            ||
| 907 | }  | 
            ||
| 908 | 									if ($row["collapsed"]) { | 
            ||
| 909 | $docSheet->getRowDimension(intval($row["r"]))->setCollapsed(true);  | 
            ||
| 910 | }  | 
            ||
| 911 | 									if ($row["outlineLevel"] > 0) { | 
            ||
| 912 | $docSheet->getRowDimension(intval($row["r"]))->setOutlineLevel(intval($row["outlineLevel"]));  | 
            ||
| 913 | }  | 
            ||
| 914 | View Code Duplication | 									if ($row["s"] && !$this->_readDataOnly) { | 
            |
| 915 | $docSheet->getRowDimension(intval($row["r"]))->setXfIndex(intval($row["s"]));  | 
            ||
| 916 | }  | 
            ||
| 917 | |||
| 918 | 									foreach ($row->c as $c) { | 
            ||
| 919 | $r = (string) $c["r"];  | 
            ||
| 920 | $cellDataType = (string) $c["t"];  | 
            ||
| 921 | $value = null;  | 
            ||
| 922 | $calculatedValue = null;  | 
            ||
| 923 | |||
| 924 | // Read cell?  | 
            ||
| 925 | 										if ($this->getReadFilter() !== NULL) { | 
            ||
| 926 | $coordinates = PHPExcel_Cell::coordinateFromString($r);  | 
            ||
| 927 | |||
| 928 | 											if (!$this->getReadFilter()->readCell($coordinates[0], $coordinates[1], $docSheet->getTitle())) { | 
            ||
| 929 | continue;  | 
            ||
| 930 | }  | 
            ||
| 931 | }  | 
            ||
| 932 | |||
| 933 | // echo '<b>Reading cell '.$coordinates[0].$coordinates[1].'</b><br />';  | 
            ||
| 934 | // print_r($c);  | 
            ||
| 935 | // echo '<br />';  | 
            ||
| 936 | // echo 'Cell Data Type is '.$cellDataType.': ';  | 
            ||
| 937 | //  | 
            ||
| 938 | // Read cell!  | 
            ||
| 939 | 										switch ($cellDataType) { | 
            ||
| 940 | case "s":  | 
            ||
| 941 | // echo 'String<br />';  | 
            ||
| 942 | 												if ((string)$c->v != '') { | 
            ||
| 943 | $value = $sharedStrings[intval($c->v)];  | 
            ||
| 944 | |||
| 945 | 													if ($value instanceof PHPExcel_RichText) { | 
            ||
| 946 | $value = clone $value;  | 
            ||
| 947 | }  | 
            ||
| 948 | 												} else { | 
            ||
| 949 | $value = '';  | 
            ||
| 950 | }  | 
            ||
| 951 | |||
| 952 | break;  | 
            ||
| 953 | case "b":  | 
            ||
| 954 | // echo 'Boolean<br />';  | 
            ||
| 955 | 												if (!isset($c->f)) { | 
            ||
| 956 | $value = self::_castToBool($c);  | 
            ||
| 957 | 												} else { | 
            ||
| 958 | // Formula  | 
            ||
| 959 | $this->_castToFormula($c,$r,$cellDataType,$value,$calculatedValue,$sharedFormulas,'_castToBool');  | 
            ||
| 960 | 													if (isset($c->f['t'])) { | 
            ||
| 961 | $att = array();  | 
            ||
| 962 | $att = $c->f;  | 
            ||
| 963 | $docSheet->getCell($r)->setFormulaAttributes($att);  | 
            ||
| 964 | }  | 
            ||
| 965 | // echo '$calculatedValue = '.$calculatedValue.'<br />';  | 
            ||
| 966 | }  | 
            ||
| 967 | break;  | 
            ||
| 968 | case "inlineStr":  | 
            ||
| 969 | // echo 'Inline String<br />';  | 
            ||
| 970 | $value = $this->_parseRichText($c->is);  | 
            ||
| 971 | |||
| 972 | break;  | 
            ||
| 973 | case "e":  | 
            ||
| 974 | // echo 'Error<br />';  | 
            ||
| 975 | View Code Duplication | 												if (!isset($c->f)) { | 
            |
| 976 | $value = self::_castToError($c);  | 
            ||
| 977 | 												} else { | 
            ||
| 978 | // Formula  | 
            ||
| 979 | $this->_castToFormula($c,$r,$cellDataType,$value,$calculatedValue,$sharedFormulas,'_castToError');  | 
            ||
| 980 | // echo '$calculatedValue = '.$calculatedValue.'<br />';  | 
            ||
| 981 | }  | 
            ||
| 982 | |||
| 983 | break;  | 
            ||
| 984 | |||
| 985 | default:  | 
            ||
| 986 | // echo 'Default<br />';  | 
            ||
| 987 | View Code Duplication | 												if (!isset($c->f)) { | 
            |
| 988 | // echo 'Not a Formula<br />';  | 
            ||
| 989 | $value = self::_castToString($c);  | 
            ||
| 990 | 												} else { | 
            ||
| 991 | // echo 'Treat as Formula<br />';  | 
            ||
| 992 | // Formula  | 
            ||
| 993 | $this->_castToFormula($c,$r,$cellDataType,$value,$calculatedValue,$sharedFormulas,'_castToString');  | 
            ||
| 994 | // echo '$calculatedValue = '.$calculatedValue.'<br />';  | 
            ||
| 995 | }  | 
            ||
| 996 | |||
| 997 | break;  | 
            ||
| 998 | }  | 
            ||
| 999 | // echo 'Value is '.$value.'<br />';  | 
            ||
| 1000 | |||
| 1001 | // Check for numeric values  | 
            ||
| 1002 | 										if (is_numeric($value) && $cellDataType != 's') { | 
            ||
| 1003 | if ($value == (int)$value) $value = (int)$value;  | 
            ||
| 1004 | elseif ($value == (float)$value) $value = (float)$value;  | 
            ||
| 1005 | elseif ($value == (double)$value) $value = (double)$value;  | 
            ||
| 1006 | }  | 
            ||
| 1007 | |||
| 1008 | // Rich text?  | 
            ||
| 1009 | 										if ($value instanceof PHPExcel_RichText && $this->_readDataOnly) { | 
            ||
| 1010 | $value = $value->getPlainText();  | 
            ||
| 1011 | }  | 
            ||
| 1012 | |||
| 1013 | $cell = $docSheet->getCell($r);  | 
            ||
| 1014 | // Assign value  | 
            ||
| 1015 | 										if ($cellDataType != '') { | 
            ||
| 1016 | $cell->setValueExplicit($value, $cellDataType);  | 
            ||
| 1017 | 										} else { | 
            ||
| 1018 | $cell->setValue($value);  | 
            ||
| 1019 | }  | 
            ||
| 1020 | 										if ($calculatedValue !== NULL) { | 
            ||
| 1021 | $cell->setCalculatedValue($calculatedValue);  | 
            ||
| 1022 | }  | 
            ||
| 1023 | |||
| 1024 | // Style information?  | 
            ||
| 1025 | View Code Duplication | 										if ($c["s"] && !$this->_readDataOnly) { | 
            |
| 1026 | // no style index means 0, it seems  | 
            ||
| 1027 | $cell->setXfIndex(isset($styles[intval($c["s"])]) ?  | 
            ||
| 1028 | intval($c["s"]) : 0);  | 
            ||
| 1029 | }  | 
            ||
| 1030 | }  | 
            ||
| 1031 | }  | 
            ||
| 1032 | }  | 
            ||
| 1033 | |||
| 1034 | $conditionals = array();  | 
            ||
| 1035 | 							if (!$this->_readDataOnly && $xmlSheet && $xmlSheet->conditionalFormatting) { | 
            ||
| 1036 | 								foreach ($xmlSheet->conditionalFormatting as $conditional) { | 
            ||
| 1037 | 									foreach ($conditional->cfRule as $cfRule) { | 
            ||
| 1038 | if (  | 
            ||
| 1039 | (  | 
            ||
| 1040 | (string)$cfRule["type"] == PHPExcel_Style_Conditional::CONDITION_NONE ||  | 
            ||
| 1041 | (string)$cfRule["type"] == PHPExcel_Style_Conditional::CONDITION_CELLIS ||  | 
            ||
| 1042 | (string)$cfRule["type"] == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT ||  | 
            ||
| 1043 | (string)$cfRule["type"] == PHPExcel_Style_Conditional::CONDITION_EXPRESSION  | 
            ||
| 1044 | ) && isset($dxfs[intval($cfRule["dxfId"])])  | 
            ||
| 1045 | 										) { | 
            ||
| 1046 | $conditionals[(string) $conditional["sqref"]][intval($cfRule["priority"])] = $cfRule;  | 
            ||
| 1047 | }  | 
            ||
| 1048 | }  | 
            ||
| 1049 | }  | 
            ||
| 1050 | |||
| 1051 | 								foreach ($conditionals as $ref => $cfRules) { | 
            ||
| 1052 | ksort($cfRules);  | 
            ||
| 1053 | $conditionalStyles = array();  | 
            ||
| 1054 | 									foreach ($cfRules as $cfRule) { | 
            ||
| 1055 | $objConditional = new PHPExcel_Style_Conditional();  | 
            ||
| 1056 | $objConditional->setConditionType((string)$cfRule["type"]);  | 
            ||
| 1057 | $objConditional->setOperatorType((string)$cfRule["operator"]);  | 
            ||
| 1058 | |||
| 1059 | 										if ((string)$cfRule["text"] != '') { | 
            ||
| 1060 | $objConditional->setText((string)$cfRule["text"]);  | 
            ||
| 1061 | }  | 
            ||
| 1062 | |||
| 1063 | 										if (count($cfRule->formula) > 1) { | 
            ||
| 1064 | 											foreach ($cfRule->formula as $formula) { | 
            ||
| 1065 | $objConditional->addCondition((string)$formula);  | 
            ||
| 1066 | }  | 
            ||
| 1067 | 										} else { | 
            ||
| 1068 | $objConditional->addCondition((string)$cfRule->formula);  | 
            ||
| 1069 | }  | 
            ||
| 1070 | $objConditional->setStyle(clone $dxfs[intval($cfRule["dxfId"])]);  | 
            ||
| 1071 | $conditionalStyles[] = $objConditional;  | 
            ||
| 1072 | }  | 
            ||
| 1073 | |||
| 1074 | // Extract all cell references in $ref  | 
            ||
| 1075 | $aReferences = PHPExcel_Cell::extractAllCellReferencesInRange($ref);  | 
            ||
| 1076 | 									foreach ($aReferences as $reference) { | 
            ||
| 1077 | $docSheet->getStyle($reference)->setConditionalStyles($conditionalStyles);  | 
            ||
| 1078 | }  | 
            ||
| 1079 | }  | 
            ||
| 1080 | }  | 
            ||
| 1081 | |||
| 1082 | 							$aKeys = array("sheet", "objects", "scenarios", "formatCells", "formatColumns", "formatRows", "insertColumns", "insertRows", "insertHyperlinks", "deleteColumns", "deleteRows", "selectLockedCells", "sort", "autoFilter", "pivotTables", "selectUnlockedCells"); | 
            ||
| 1083 | 							if (!$this->_readDataOnly && $xmlSheet && $xmlSheet->sheetProtection) { | 
            ||
| 1084 | 								foreach ($aKeys as $key) { | 
            ||
| 1085 | $method = "set" . ucfirst($key);  | 
            ||
| 1086 | $docSheet->getProtection()->$method($xmlSheet->sheetProtection[$key] == "true");  | 
            ||
| 1087 | }  | 
            ||
| 1088 | }  | 
            ||
| 1089 | |||
| 1090 | 							if (!$this->_readDataOnly && $xmlSheet && $xmlSheet->sheetProtection) { | 
            ||
| 1091 | $docSheet->getProtection()->setPassword((string) $xmlSheet->sheetProtection["password"], true);  | 
            ||
| 1092 | 								if ($xmlSheet->protectedRanges->protectedRange) { | 
            ||
| 1093 | 									foreach ($xmlSheet->protectedRanges->protectedRange as $protectedRange) { | 
            ||
| 1094 | $docSheet->protectCells((string) $protectedRange["sqref"], (string) $protectedRange["password"], true);  | 
            ||
| 1095 | }  | 
            ||
| 1096 | }  | 
            ||
| 1097 | }  | 
            ||
| 1098 | |||
| 1099 | 							if ($xmlSheet && $xmlSheet->autoFilter && !$this->_readDataOnly) { | 
            ||
| 1100 | $docSheet->setAutoFilter((string) $xmlSheet->autoFilter["ref"]);  | 
            ||
| 1101 | }  | 
            ||
| 1102 | |||
| 1103 | 							if ($xmlSheet && $xmlSheet->mergeCells && $xmlSheet->mergeCells->mergeCell && !$this->_readDataOnly) { | 
            ||
| 1104 | 								foreach ($xmlSheet->mergeCells->mergeCell as $mergeCell) { | 
            ||
| 1105 | $docSheet->mergeCells((string) $mergeCell["ref"]);  | 
            ||
| 1106 | }  | 
            ||
| 1107 | }  | 
            ||
| 1108 | |||
| 1109 | 							if ($xmlSheet && $xmlSheet->pageMargins && !$this->_readDataOnly) { | 
            ||
| 1110 | $docPageMargins = $docSheet->getPageMargins();  | 
            ||
| 1111 | $docPageMargins->setLeft(floatval($xmlSheet->pageMargins["left"]));  | 
            ||
| 1112 | $docPageMargins->setRight(floatval($xmlSheet->pageMargins["right"]));  | 
            ||
| 1113 | $docPageMargins->setTop(floatval($xmlSheet->pageMargins["top"]));  | 
            ||
| 1114 | $docPageMargins->setBottom(floatval($xmlSheet->pageMargins["bottom"]));  | 
            ||
| 1115 | $docPageMargins->setHeader(floatval($xmlSheet->pageMargins["header"]));  | 
            ||
| 1116 | $docPageMargins->setFooter(floatval($xmlSheet->pageMargins["footer"]));  | 
            ||
| 1117 | }  | 
            ||
| 1118 | |||
| 1119 | 							if ($xmlSheet && $xmlSheet->pageSetup && !$this->_readDataOnly) { | 
            ||
| 1120 | $docPageSetup = $docSheet->getPageSetup();  | 
            ||
| 1121 | |||
| 1122 | 								if (isset($xmlSheet->pageSetup["orientation"])) { | 
            ||
| 1123 | $docPageSetup->setOrientation((string) $xmlSheet->pageSetup["orientation"]);  | 
            ||
| 1124 | }  | 
            ||
| 1125 | 								if (isset($xmlSheet->pageSetup["paperSize"])) { | 
            ||
| 1126 | $docPageSetup->setPaperSize(intval($xmlSheet->pageSetup["paperSize"]));  | 
            ||
| 1127 | }  | 
            ||
| 1128 | 								if (isset($xmlSheet->pageSetup["scale"])) { | 
            ||
| 1129 | $docPageSetup->setScale(intval($xmlSheet->pageSetup["scale"]), false);  | 
            ||
| 1130 | }  | 
            ||
| 1131 | View Code Duplication | 								if (isset($xmlSheet->pageSetup["fitToHeight"]) && intval($xmlSheet->pageSetup["fitToHeight"]) >= 0) { | 
            |
| 1132 | $docPageSetup->setFitToHeight(intval($xmlSheet->pageSetup["fitToHeight"]), false);  | 
            ||
| 1133 | }  | 
            ||
| 1134 | View Code Duplication | 								if (isset($xmlSheet->pageSetup["fitToWidth"]) && intval($xmlSheet->pageSetup["fitToWidth"]) >= 0) { | 
            |
| 1135 | $docPageSetup->setFitToWidth(intval($xmlSheet->pageSetup["fitToWidth"]), false);  | 
            ||
| 1136 | }  | 
            ||
| 1137 | if (isset($xmlSheet->pageSetup["firstPageNumber"]) && isset($xmlSheet->pageSetup["useFirstPageNumber"]) &&  | 
            ||
| 1138 | 									((string)$xmlSheet->pageSetup["useFirstPageNumber"] == 'true' || (string)$xmlSheet->pageSetup["useFirstPageNumber"] == '1')) { | 
            ||
| 1139 | $docPageSetup->setFirstPageNumber(intval($xmlSheet->pageSetup["firstPageNumber"]));  | 
            ||
| 1140 | }  | 
            ||
| 1141 | }  | 
            ||
| 1142 | |||
| 1143 | 							if ($xmlSheet && $xmlSheet->headerFooter && !$this->_readDataOnly) { | 
            ||
| 1144 | $docHeaderFooter = $docSheet->getHeaderFooter();  | 
            ||
| 1145 | |||
| 1146 | View Code Duplication | if (isset($xmlSheet->headerFooter["differentOddEven"]) &&  | 
            |
| 1147 | 									((string)$xmlSheet->headerFooter["differentOddEven"] == 'true' || (string)$xmlSheet->headerFooter["differentOddEven"] == '1')) { | 
            ||
| 1148 | $docHeaderFooter->setDifferentOddEven(true);  | 
            ||
| 1149 | 								} else { | 
            ||
| 1150 | $docHeaderFooter->setDifferentOddEven(false);  | 
            ||
| 1151 | }  | 
            ||
| 1152 | View Code Duplication | if (isset($xmlSheet->headerFooter["differentFirst"]) &&  | 
            |
| 1153 | 									((string)$xmlSheet->headerFooter["differentFirst"] == 'true' || (string)$xmlSheet->headerFooter["differentFirst"] == '1')) { | 
            ||
| 1154 | $docHeaderFooter->setDifferentFirst(true);  | 
            ||
| 1155 | 								} else { | 
            ||
| 1156 | $docHeaderFooter->setDifferentFirst(false);  | 
            ||
| 1157 | }  | 
            ||
| 1158 | View Code Duplication | if (isset($xmlSheet->headerFooter["scaleWithDoc"]) &&  | 
            |
| 1159 | 									((string)$xmlSheet->headerFooter["scaleWithDoc"] == 'false' || (string)$xmlSheet->headerFooter["scaleWithDoc"] == '0')) { | 
            ||
| 1160 | $docHeaderFooter->setScaleWithDocument(false);  | 
            ||
| 1161 | 								} else { | 
            ||
| 1162 | $docHeaderFooter->setScaleWithDocument(true);  | 
            ||
| 1163 | }  | 
            ||
| 1164 | View Code Duplication | if (isset($xmlSheet->headerFooter["alignWithMargins"]) &&  | 
            |
| 1165 | 									((string)$xmlSheet->headerFooter["alignWithMargins"] == 'false' || (string)$xmlSheet->headerFooter["alignWithMargins"] == '0')) { | 
            ||
| 1166 | $docHeaderFooter->setAlignWithMargins(false);  | 
            ||
| 1167 | 								} else { | 
            ||
| 1168 | $docHeaderFooter->setAlignWithMargins(true);  | 
            ||
| 1169 | }  | 
            ||
| 1170 | |||
| 1171 | $docHeaderFooter->setOddHeader((string) $xmlSheet->headerFooter->oddHeader);  | 
            ||
| 1172 | $docHeaderFooter->setOddFooter((string) $xmlSheet->headerFooter->oddFooter);  | 
            ||
| 1173 | $docHeaderFooter->setEvenHeader((string) $xmlSheet->headerFooter->evenHeader);  | 
            ||
| 1174 | $docHeaderFooter->setEvenFooter((string) $xmlSheet->headerFooter->evenFooter);  | 
            ||
| 1175 | $docHeaderFooter->setFirstHeader((string) $xmlSheet->headerFooter->firstHeader);  | 
            ||
| 1176 | $docHeaderFooter->setFirstFooter((string) $xmlSheet->headerFooter->firstFooter);  | 
            ||
| 1177 | }  | 
            ||
| 1178 | |||
| 1179 | 							if ($xmlSheet && $xmlSheet->rowBreaks && $xmlSheet->rowBreaks->brk && !$this->_readDataOnly) { | 
            ||
| 1180 | 								foreach ($xmlSheet->rowBreaks->brk as $brk) { | 
            ||
| 1181 | 									if ($brk["man"]) { | 
            ||
| 1182 | 										$docSheet->setBreak("A$brk[id]", PHPExcel_Worksheet::BREAK_ROW); | 
            ||
| 1183 | }  | 
            ||
| 1184 | }  | 
            ||
| 1185 | }  | 
            ||
| 1186 | 							if ($xmlSheet && $xmlSheet->colBreaks && $xmlSheet->colBreaks->brk && !$this->_readDataOnly) { | 
            ||
| 1187 | 								foreach ($xmlSheet->colBreaks->brk as $brk) { | 
            ||
| 1188 | 									if ($brk["man"]) { | 
            ||
| 1189 | $docSheet->setBreak(PHPExcel_Cell::stringFromColumnIndex($brk["id"]) . "1", PHPExcel_Worksheet::BREAK_COLUMN);  | 
            ||
| 1190 | }  | 
            ||
| 1191 | }  | 
            ||
| 1192 | }  | 
            ||
| 1193 | |||
| 1194 | 							if ($xmlSheet && $xmlSheet->dataValidations && !$this->_readDataOnly) { | 
            ||
| 1195 | 								foreach ($xmlSheet->dataValidations->dataValidation as $dataValidation) { | 
            ||
| 1196 | // Uppercase coordinate  | 
            ||
| 1197 | $range = strtoupper($dataValidation["sqref"]);  | 
            ||
| 1198 | 									$rangeSet = explode(' ',$range); | 
            ||
| 1199 | 									foreach($rangeSet as $range) { | 
            ||
| 1200 | $stRange = $docSheet->shrinkRangeToFit($range);  | 
            ||
| 1201 | |||
| 1202 | // Extract all cell references in $range  | 
            ||
| 1203 | $aReferences = PHPExcel_Cell::extractAllCellReferencesInRange($stRange);  | 
            ||
| 1204 | 										foreach ($aReferences as $reference) { | 
            ||
| 1205 | // Create validation  | 
            ||
| 1206 | $docValidation = $docSheet->getCell($reference)->getDataValidation();  | 
            ||
| 1207 | $docValidation->setType((string) $dataValidation["type"]);  | 
            ||
| 1208 | $docValidation->setErrorStyle((string) $dataValidation["errorStyle"]);  | 
            ||
| 1209 | $docValidation->setOperator((string) $dataValidation["operator"]);  | 
            ||
| 1210 | $docValidation->setAllowBlank($dataValidation["allowBlank"] != 0);  | 
            ||
| 1211 | $docValidation->setShowDropDown($dataValidation["showDropDown"] == 0);  | 
            ||
| 1212 | $docValidation->setShowInputMessage($dataValidation["showInputMessage"] != 0);  | 
            ||
| 1213 | $docValidation->setShowErrorMessage($dataValidation["showErrorMessage"] != 0);  | 
            ||
| 1214 | $docValidation->setErrorTitle((string) $dataValidation["errorTitle"]);  | 
            ||
| 1215 | $docValidation->setError((string) $dataValidation["error"]);  | 
            ||
| 1216 | $docValidation->setPromptTitle((string) $dataValidation["promptTitle"]);  | 
            ||
| 1217 | $docValidation->setPrompt((string) $dataValidation["prompt"]);  | 
            ||
| 1218 | $docValidation->setFormula1((string) $dataValidation->formula1);  | 
            ||
| 1219 | $docValidation->setFormula2((string) $dataValidation->formula2);  | 
            ||
| 1220 | }  | 
            ||
| 1221 | }  | 
            ||
| 1222 | }  | 
            ||
| 1223 | }  | 
            ||
| 1224 | |||
| 1225 | // Add hyperlinks  | 
            ||
| 1226 | $hyperlinks = array();  | 
            ||
| 1227 | 							if (!$this->_readDataOnly) { | 
            ||
| 1228 | // Locate hyperlink relations  | 
            ||
| 1229 | 								if ($zip->locateName(dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")) { | 
            ||
| 1230 | 									$relsWorksheet = simplexml_load_string($this->_getFromZipArchive($zip,  dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels") ); //~ http://schemas.openxmlformats.org/package/2006/relationships"); | 
            ||
| 1231 | 									foreach ($relsWorksheet->Relationship as $ele) { | 
            ||
| 1232 | 										if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink") { | 
            ||
| 1233 | $hyperlinks[(string)$ele["Id"]] = (string)$ele["Target"];  | 
            ||
| 1234 | }  | 
            ||
| 1235 | }  | 
            ||
| 1236 | }  | 
            ||
| 1237 | |||
| 1238 | // Loop through hyperlinks  | 
            ||
| 1239 | 								if ($xmlSheet && $xmlSheet->hyperlinks) { | 
            ||
| 1240 | 									foreach ($xmlSheet->hyperlinks->hyperlink as $hyperlink) { | 
            ||
| 1241 | // Link url  | 
            ||
| 1242 | 										$linkRel = $hyperlink->attributes('http://schemas.openxmlformats.org/officeDocument/2006/relationships'); | 
            ||
| 1243 | |||
| 1244 | 										foreach (PHPExcel_Cell::extractAllCellReferencesInRange($hyperlink['ref']) as $cellReference) { | 
            ||
| 1245 | $cell = $docSheet->getCell( $cellReference );  | 
            ||
| 1246 | 											if (isset($linkRel['id'])) { | 
            ||
| 1247 | $cell->getHyperlink()->setUrl( $hyperlinks[ (string)$linkRel['id'] ] );  | 
            ||
| 1248 | }  | 
            ||
| 1249 | 											if (isset($hyperlink['location'])) { | 
            ||
| 1250 | $cell->getHyperlink()->setUrl( 'sheet://' . (string)$hyperlink['location'] );  | 
            ||
| 1251 | }  | 
            ||
| 1252 | |||
| 1253 | // Tooltip  | 
            ||
| 1254 | 											if (isset($hyperlink['tooltip'])) { | 
            ||
| 1255 | $cell->getHyperlink()->setTooltip( (string)$hyperlink['tooltip'] );  | 
            ||
| 1256 | }  | 
            ||
| 1257 | }  | 
            ||
| 1258 | }  | 
            ||
| 1259 | }  | 
            ||
| 1260 | }  | 
            ||
| 1261 | |||
| 1262 | // Add comments  | 
            ||
| 1263 | $comments = array();  | 
            ||
| 1264 | $vmlComments = array();  | 
            ||
| 1265 | 							if (!$this->_readDataOnly) { | 
            ||
| 1266 | // Locate comment relations  | 
            ||
| 1267 | 								if ($zip->locateName(dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")) { | 
            ||
| 1268 | 									$relsWorksheet = simplexml_load_string($this->_getFromZipArchive($zip,  dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels") ); //~ http://schemas.openxmlformats.org/package/2006/relationships"); | 
            ||
| 1269 | 									foreach ($relsWorksheet->Relationship as $ele) { | 
            ||
| 1270 | 									    if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments") { | 
            ||
| 1271 | $comments[(string)$ele["Id"]] = (string)$ele["Target"];  | 
            ||
| 1272 | }  | 
            ||
| 1273 | 									    if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing") { | 
            ||
| 1274 | $vmlComments[(string)$ele["Id"]] = (string)$ele["Target"];  | 
            ||
| 1275 | }  | 
            ||
| 1276 | }  | 
            ||
| 1277 | }  | 
            ||
| 1278 | |||
| 1279 | // Loop through comments  | 
            ||
| 1280 | 								foreach ($comments as $relName => $relPath) { | 
            ||
| 1281 | // Load comments file  | 
            ||
| 1282 | 									$relPath = PHPExcel_Shared_File::realpath(dirname("$dir/$fileWorksheet") . "/" . $relPath); | 
            ||
| 1283 | $commentsFile = simplexml_load_string($this->_getFromZipArchive($zip, $relPath) );  | 
            ||
| 1284 | |||
| 1285 | // Utility variables  | 
            ||
| 1286 | $authors = array();  | 
            ||
| 1287 | |||
| 1288 | // Loop through authors  | 
            ||
| 1289 | 									foreach ($commentsFile->authors->author as $author) { | 
            ||
| 1290 | $authors[] = (string)$author;  | 
            ||
| 1291 | }  | 
            ||
| 1292 | |||
| 1293 | // Loop through contents  | 
            ||
| 1294 | 									foreach ($commentsFile->commentList->comment as $comment) { | 
            ||
| 1295 | $docSheet->getComment( (string)$comment['ref'] )->setAuthor( $authors[(string)$comment['authorId']] );  | 
            ||
| 1296 | $docSheet->getComment( (string)$comment['ref'] )->setText( $this->_parseRichText($comment->text) );  | 
            ||
| 1297 | }  | 
            ||
| 1298 | }  | 
            ||
| 1299 | |||
| 1300 | // Loop through VML comments  | 
            ||
| 1301 | 							    foreach ($vmlComments as $relName => $relPath) { | 
            ||
| 1302 | // Load VML comments file  | 
            ||
| 1303 | 									$relPath = PHPExcel_Shared_File::realpath(dirname("$dir/$fileWorksheet") . "/" . $relPath); | 
            ||
| 1304 | $vmlCommentsFile = simplexml_load_string( $this->_getFromZipArchive($zip, $relPath) );  | 
            ||
| 1305 | 									$vmlCommentsFile->registerXPathNamespace('v', 'urn:schemas-microsoft-com:vml'); | 
            ||
| 1306 | |||
| 1307 | 									$shapes = $vmlCommentsFile->xpath('//v:shape'); | 
            ||
| 1308 | 									foreach ($shapes as $shape) { | 
            ||
| 1309 | 										$shape->registerXPathNamespace('v', 'urn:schemas-microsoft-com:vml'); | 
            ||
| 1310 | |||
| 1311 | 										if (isset($shape['style'])) { | 
            ||
| 1312 | $style = (string)$shape['style'];  | 
            ||
| 1313 | $fillColor = strtoupper( substr( (string)$shape['fillcolor'], 1 ) );  | 
            ||
| 1314 | $column = null;  | 
            ||
| 1315 | $row = null;  | 
            ||
| 1316 | |||
| 1317 | 	    									$clientData   = $shape->xpath('.//x:ClientData'); | 
            ||
| 1318 | 	    									if (is_array($clientData) && !empty($clientData)) { | 
            ||
| 1319 | $clientData = $clientData[0];  | 
            ||
| 1320 | |||
| 1321 | 	        									if ( isset($clientData['ObjectType']) && (string)$clientData['ObjectType'] == 'Note' ) { | 
            ||
| 1322 | 	        									    $temp = $clientData->xpath('.//x:Row'); | 
            ||
| 1323 | if (is_array($temp)) $row = $temp[0];  | 
            ||
| 1324 | |||
| 1325 | 	        									    $temp = $clientData->xpath('.//x:Column'); | 
            ||
| 1326 | if (is_array($temp)) $column = $temp[0];  | 
            ||
| 1327 | }  | 
            ||
| 1328 | }  | 
            ||
| 1329 | |||
| 1330 | 	    									if (($column !== NULL) && ($row !== NULL)) { | 
            ||
| 1331 | // Set comment properties  | 
            ||
| 1332 | $comment = $docSheet->getCommentByColumnAndRow((string) $column, $row + 1);  | 
            ||
| 1333 | $comment->getFillColor()->setRGB( $fillColor );  | 
            ||
| 1334 | |||
| 1335 | // Parse style  | 
            ||
| 1336 | 	    									    $styleArray = explode(';', str_replace(' ', '', $style)); | 
            ||
| 1337 | 	    									    foreach ($styleArray as $stylePair) { | 
            ||
| 1338 | 	    									        $stylePair = explode(':', $stylePair); | 
            ||
| 1339 | |||
| 1340 | if ($stylePair[0] == 'margin-left') $comment->setMarginLeft($stylePair[1]);  | 
            ||
| 1341 | if ($stylePair[0] == 'margin-top') $comment->setMarginTop($stylePair[1]);  | 
            ||
| 1342 | if ($stylePair[0] == 'width') $comment->setWidth($stylePair[1]);  | 
            ||
| 1343 | if ($stylePair[0] == 'height') $comment->setHeight($stylePair[1]);  | 
            ||
| 1344 | if ($stylePair[0] == 'visibility') $comment->setVisible( $stylePair[1] == 'visible' );  | 
            ||
| 1345 | |||
| 1346 | }  | 
            ||
| 1347 | }  | 
            ||
| 1348 | }  | 
            ||
| 1349 | }  | 
            ||
| 1350 | }  | 
            ||
| 1351 | |||
| 1352 | // Header/footer images  | 
            ||
| 1353 | 								if ($xmlSheet && $xmlSheet->legacyDrawingHF && !$this->_readDataOnly) { | 
            ||
| 1354 | 									if ($zip->locateName(dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")) { | 
            ||
| 1355 | 										$relsWorksheet = simplexml_load_string($this->_getFromZipArchive($zip,  dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels") ); //~ http://schemas.openxmlformats.org/package/2006/relationships"); | 
            ||
| 1356 | $vmlRelationship = '';  | 
            ||
| 1357 | |||
| 1358 | 										foreach ($relsWorksheet->Relationship as $ele) { | 
            ||
| 1359 | 											if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing") { | 
            ||
| 1360 | 												$vmlRelationship = self::dir_add("$dir/$fileWorksheet", $ele["Target"]); | 
            ||
| 1361 | }  | 
            ||
| 1362 | }  | 
            ||
| 1363 | |||
| 1364 | 										if ($vmlRelationship != '') { | 
            ||
| 1365 | // Fetch linked images  | 
            ||
| 1366 | $relsVML = simplexml_load_string($this->_getFromZipArchive($zip, dirname($vmlRelationship) . '/_rels/' . basename($vmlRelationship) . '.rels' )); //~ http://schemas.openxmlformats.org/package/2006/relationships");  | 
            ||
| 1367 | $drawings = array();  | 
            ||
| 1368 | View Code Duplication | 											foreach ($relsVML->Relationship as $ele) { | 
            |
| 1369 | 												if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image") { | 
            ||
| 1370 | $drawings[(string) $ele["Id"]] = self::dir_add($vmlRelationship, $ele["Target"]);  | 
            ||
| 1371 | }  | 
            ||
| 1372 | }  | 
            ||
| 1373 | |||
| 1374 | // Fetch VML document  | 
            ||
| 1375 | $vmlDrawing = simplexml_load_string($this->_getFromZipArchive($zip, $vmlRelationship));  | 
            ||
| 1376 | 											$vmlDrawing->registerXPathNamespace('v', 'urn:schemas-microsoft-com:vml'); | 
            ||
| 1377 | |||
| 1378 | $hfImages = array();  | 
            ||
| 1379 | |||
| 1380 | 											$shapes = $vmlDrawing->xpath('//v:shape'); | 
            ||
| 1381 | 											foreach ($shapes as $shape) { | 
            ||
| 1382 | 												$shape->registerXPathNamespace('v', 'urn:schemas-microsoft-com:vml'); | 
            ||
| 1383 | 												$imageData = $shape->xpath('//v:imagedata'); | 
            ||
| 1384 | $imageData = $imageData[0];  | 
            ||
| 1385 | |||
| 1386 | 												$imageData = $imageData->attributes('urn:schemas-microsoft-com:office:office'); | 
            ||
| 1387 | $style = self::toCSSArray( (string)$shape['style'] );  | 
            ||
| 1388 | |||
| 1389 | $hfImages[ (string)$shape['id'] ] = new PHPExcel_Worksheet_HeaderFooterDrawing();  | 
            ||
| 1390 | 												if (isset($imageData['title'])) { | 
            ||
| 1391 | $hfImages[ (string)$shape['id'] ]->setName( (string)$imageData['title'] );  | 
            ||
| 1392 | }  | 
            ||
| 1393 | |||
| 1394 | 												$hfImages[ (string)$shape['id'] ]->setPath("zip://$pFilename#" . $drawings[(string)$imageData['relid']], false); | 
            ||
| 1395 | $hfImages[ (string)$shape['id'] ]->setResizeProportional(false);  | 
            ||
| 1396 | $hfImages[ (string)$shape['id'] ]->setWidth($style['width']);  | 
            ||
| 1397 | $hfImages[ (string)$shape['id'] ]->setHeight($style['height']);  | 
            ||
| 1398 | $hfImages[ (string)$shape['id'] ]->setOffsetX($style['margin-left']);  | 
            ||
| 1399 | $hfImages[ (string)$shape['id'] ]->setOffsetY($style['margin-top']);  | 
            ||
| 1400 | $hfImages[ (string)$shape['id'] ]->setResizeProportional(true);  | 
            ||
| 1401 | }  | 
            ||
| 1402 | |||
| 1403 | $docSheet->getHeaderFooter()->setImages($hfImages);  | 
            ||
| 1404 | }  | 
            ||
| 1405 | }  | 
            ||
| 1406 | }  | 
            ||
| 1407 | |||
| 1408 | }  | 
            ||
| 1409 | |||
| 1410 | // TODO: Make sure drawings and graph are loaded differently!  | 
            ||
| 1411 | 							if ($zip->locateName(dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")) { | 
            ||
| 1412 | 								$relsWorksheet = simplexml_load_string($this->_getFromZipArchive($zip,  dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels") ); //~ http://schemas.openxmlformats.org/package/2006/relationships"); | 
            ||
| 1413 | $drawings = array();  | 
            ||
| 1414 | View Code Duplication | 								foreach ($relsWorksheet->Relationship as $ele) { | 
            |
| 1415 | 									if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing") { | 
            ||
| 1416 | 										$drawings[(string) $ele["Id"]] = self::dir_add("$dir/$fileWorksheet", $ele["Target"]); | 
            ||
| 1417 | }  | 
            ||
| 1418 | }  | 
            ||
| 1419 | 								if ($xmlSheet->drawing && !$this->_readDataOnly) { | 
            ||
| 1420 | 									foreach ($xmlSheet->drawing as $drawing) { | 
            ||
| 1421 | 										$fileDrawing = $drawings[(string) self::array_item($drawing->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "id")]; | 
            ||
| 1422 | $relsDrawing = simplexml_load_string($this->_getFromZipArchive($zip, dirname($fileDrawing) . "/_rels/" . basename($fileDrawing) . ".rels") ); //~ http://schemas.openxmlformats.org/package/2006/relationships");  | 
            ||
| 1423 | $images = array();  | 
            ||
| 1424 | |||
| 1425 | 										if ($relsDrawing && $relsDrawing->Relationship) { | 
            ||
| 1426 | 											foreach ($relsDrawing->Relationship as $ele) { | 
            ||
| 1427 | 												if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image") { | 
            ||
| 1428 | $images[(string) $ele["Id"]] = self::dir_add($fileDrawing, $ele["Target"]);  | 
            ||
| 1429 | 												} elseif ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart") { | 
            ||
| 1430 | 													if ($this->_includeCharts) { | 
            ||
| 1431 | 														$charts[self::dir_add($fileDrawing, $ele["Target"])] = array('id'		=> (string) $ele["Id"], | 
            ||
| 1432 | 'sheet' => $docSheet->getTitle()  | 
            ||
| 1433 | );  | 
            ||
| 1434 | }  | 
            ||
| 1435 | }  | 
            ||
| 1436 | }  | 
            ||
| 1437 | }  | 
            ||
| 1438 | 										$xmlDrawing = simplexml_load_string($this->_getFromZipArchive($zip, $fileDrawing))->children("http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing"); | 
            ||
| 1439 | |||
| 1440 | 										if ($xmlDrawing->oneCellAnchor) { | 
            ||
| 1441 | 											foreach ($xmlDrawing->oneCellAnchor as $oneCellAnchor) { | 
            ||
| 1442 | 												if ($oneCellAnchor->pic->blipFill) { | 
            ||
| 1443 | 													$blip = $oneCellAnchor->pic->blipFill->children("http://schemas.openxmlformats.org/drawingml/2006/main")->blip; | 
            ||
| 1444 | 													$xfrm = $oneCellAnchor->pic->spPr->children("http://schemas.openxmlformats.org/drawingml/2006/main")->xfrm; | 
            ||
| 1445 | 													$outerShdw = $oneCellAnchor->pic->spPr->children("http://schemas.openxmlformats.org/drawingml/2006/main")->effectLst->outerShdw; | 
            ||
| 1446 | $objDrawing = new PHPExcel_Worksheet_Drawing;  | 
            ||
| 1447 | $objDrawing->setName((string) self::array_item($oneCellAnchor->pic->nvPicPr->cNvPr->attributes(), "name"));  | 
            ||
| 1448 | $objDrawing->setDescription((string) self::array_item($oneCellAnchor->pic->nvPicPr->cNvPr->attributes(), "descr"));  | 
            ||
| 1449 | 													$objDrawing->setPath("zip://$pFilename#" . $images[(string) self::array_item($blip->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "embed")], false); | 
            ||
| 1450 | $objDrawing->setCoordinates(PHPExcel_Cell::stringFromColumnIndex((string) $oneCellAnchor->from->col) . ($oneCellAnchor->from->row + 1));  | 
            ||
| 1451 | $objDrawing->setOffsetX(PHPExcel_Shared_Drawing::EMUToPixels($oneCellAnchor->from->colOff));  | 
            ||
| 1452 | $objDrawing->setOffsetY(PHPExcel_Shared_Drawing::EMUToPixels($oneCellAnchor->from->rowOff));  | 
            ||
| 1453 | $objDrawing->setResizeProportional(false);  | 
            ||
| 1454 | $objDrawing->setWidth(PHPExcel_Shared_Drawing::EMUToPixels(self::array_item($oneCellAnchor->ext->attributes(), "cx")));  | 
            ||
| 1455 | $objDrawing->setHeight(PHPExcel_Shared_Drawing::EMUToPixels(self::array_item($oneCellAnchor->ext->attributes(), "cy")));  | 
            ||
| 1456 | 													if ($xfrm) { | 
            ||
| 1457 | $objDrawing->setRotation(PHPExcel_Shared_Drawing::angleToDegrees(self::array_item($xfrm->attributes(), "rot")));  | 
            ||
| 1458 | }  | 
            ||
| 1459 | View Code Duplication | 													if ($outerShdw) { | 
            |
| 1460 | $shadow = $objDrawing->getShadow();  | 
            ||
| 1461 | $shadow->setVisible(true);  | 
            ||
| 1462 | $shadow->setBlurRadius(PHPExcel_Shared_Drawing::EMUTopixels(self::array_item($outerShdw->attributes(), "blurRad")));  | 
            ||
| 1463 | $shadow->setDistance(PHPExcel_Shared_Drawing::EMUTopixels(self::array_item($outerShdw->attributes(), "dist")));  | 
            ||
| 1464 | $shadow->setDirection(PHPExcel_Shared_Drawing::angleToDegrees(self::array_item($outerShdw->attributes(), "dir")));  | 
            ||
| 1465 | $shadow->setAlignment((string) self::array_item($outerShdw->attributes(), "algn"));  | 
            ||
| 1466 | $shadow->getColor()->setRGB(self::array_item($outerShdw->srgbClr->attributes(), "val"));  | 
            ||
| 1467 | $shadow->setAlpha(self::array_item($outerShdw->srgbClr->alpha->attributes(), "val") / 1000);  | 
            ||
| 1468 | }  | 
            ||
| 1469 | $objDrawing->setWorksheet($docSheet);  | 
            ||
| 1470 | 												} else { | 
            ||
| 1471 | $coordinates = PHPExcel_Cell::stringFromColumnIndex((string) $oneCellAnchor->from->col) . ($oneCellAnchor->from->row + 1);  | 
            ||
| 1472 | $offsetX = PHPExcel_Shared_Drawing::EMUToPixels($oneCellAnchor->from->colOff);  | 
            ||
| 1473 | $offsetY = PHPExcel_Shared_Drawing::EMUToPixels($oneCellAnchor->from->rowOff);  | 
            ||
| 1474 | $width = PHPExcel_Shared_Drawing::EMUToPixels(self::array_item($oneCellAnchor->ext->attributes(), "cx"));  | 
            ||
| 1475 | $height = PHPExcel_Shared_Drawing::EMUToPixels(self::array_item($oneCellAnchor->ext->attributes(), "cy"));  | 
            ||
| 1476 | }  | 
            ||
| 1477 | }  | 
            ||
| 1478 | }  | 
            ||
| 1479 | 										if ($xmlDrawing->twoCellAnchor) { | 
            ||
| 1480 | 											foreach ($xmlDrawing->twoCellAnchor as $twoCellAnchor) { | 
            ||
| 1481 | 												if ($twoCellAnchor->pic->blipFill) { | 
            ||
| 1482 | 													$blip = $twoCellAnchor->pic->blipFill->children("http://schemas.openxmlformats.org/drawingml/2006/main")->blip; | 
            ||
| 1483 | 													$xfrm = $twoCellAnchor->pic->spPr->children("http://schemas.openxmlformats.org/drawingml/2006/main")->xfrm; | 
            ||
| 1484 | 													$outerShdw = $twoCellAnchor->pic->spPr->children("http://schemas.openxmlformats.org/drawingml/2006/main")->effectLst->outerShdw; | 
            ||
| 1485 | $objDrawing = new PHPExcel_Worksheet_Drawing;  | 
            ||
| 1486 | $objDrawing->setName((string) self::array_item($twoCellAnchor->pic->nvPicPr->cNvPr->attributes(), "name"));  | 
            ||
| 1487 | $objDrawing->setDescription((string) self::array_item($twoCellAnchor->pic->nvPicPr->cNvPr->attributes(), "descr"));  | 
            ||
| 1488 | 													$objDrawing->setPath("zip://$pFilename#" . $images[(string) self::array_item($blip->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "embed")], false); | 
            ||
| 1489 | $objDrawing->setCoordinates(PHPExcel_Cell::stringFromColumnIndex((string) $twoCellAnchor->from->col) . ($twoCellAnchor->from->row + 1));  | 
            ||
| 1490 | $objDrawing->setOffsetX(PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->colOff));  | 
            ||
| 1491 | $objDrawing->setOffsetY(PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->rowOff));  | 
            ||
| 1492 | $objDrawing->setResizeProportional(false);  | 
            ||
| 1493 | |||
| 1494 | $objDrawing->setWidth(PHPExcel_Shared_Drawing::EMUToPixels(self::array_item($xfrm->ext->attributes(), "cx")));  | 
            ||
| 1495 | $objDrawing->setHeight(PHPExcel_Shared_Drawing::EMUToPixels(self::array_item($xfrm->ext->attributes(), "cy")));  | 
            ||
| 1496 | |||
| 1497 | 													if ($xfrm) { | 
            ||
| 1498 | $objDrawing->setRotation(PHPExcel_Shared_Drawing::angleToDegrees(self::array_item($xfrm->attributes(), "rot")));  | 
            ||
| 1499 | }  | 
            ||
| 1500 | View Code Duplication | 													if ($outerShdw) { | 
            |
| 1501 | $shadow = $objDrawing->getShadow();  | 
            ||
| 1502 | $shadow->setVisible(true);  | 
            ||
| 1503 | $shadow->setBlurRadius(PHPExcel_Shared_Drawing::EMUTopixels(self::array_item($outerShdw->attributes(), "blurRad")));  | 
            ||
| 1504 | $shadow->setDistance(PHPExcel_Shared_Drawing::EMUTopixels(self::array_item($outerShdw->attributes(), "dist")));  | 
            ||
| 1505 | $shadow->setDirection(PHPExcel_Shared_Drawing::angleToDegrees(self::array_item($outerShdw->attributes(), "dir")));  | 
            ||
| 1506 | $shadow->setAlignment((string) self::array_item($outerShdw->attributes(), "algn"));  | 
            ||
| 1507 | $shadow->getColor()->setRGB(self::array_item($outerShdw->srgbClr->attributes(), "val"));  | 
            ||
| 1508 | $shadow->setAlpha(self::array_item($outerShdw->srgbClr->alpha->attributes(), "val") / 1000);  | 
            ||
| 1509 | }  | 
            ||
| 1510 | $objDrawing->setWorksheet($docSheet);  | 
            ||
| 1511 | 												} elseif($this->_includeCharts) { | 
            ||
| 1512 | $fromCoordinate = PHPExcel_Cell::stringFromColumnIndex((string) $twoCellAnchor->from->col) . ($twoCellAnchor->from->row + 1);  | 
            ||
| 1513 | $fromOffsetX = PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->colOff);  | 
            ||
| 1514 | $fromOffsetY = PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->rowOff);  | 
            ||
| 1515 | $toCoordinate = PHPExcel_Cell::stringFromColumnIndex((string) $twoCellAnchor->to->col) . ($twoCellAnchor->to->row + 1);  | 
            ||
| 1516 | $toOffsetX = PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->to->colOff);  | 
            ||
| 1517 | $toOffsetY = PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->to->rowOff);  | 
            ||
| 1518 | 													$graphic		= $twoCellAnchor->graphicFrame->children("http://schemas.openxmlformats.org/drawingml/2006/main")->graphic; | 
            ||
| 1519 | 													$chartRef		= $graphic->graphicData->children("http://schemas.openxmlformats.org/drawingml/2006/chart")->chart; | 
            ||
| 1520 | 													$thisChart		= (string) $chartRef->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"); | 
            ||
| 1521 | |||
| 1522 | $chartDetails[$docSheet->getTitle().'!'.$thisChart] =  | 
            ||
| 1523 | array( 'fromCoordinate' => $fromCoordinate,  | 
            ||
| 1524 | 'fromOffsetX' => $fromOffsetX,  | 
            ||
| 1525 | 'fromOffsetY' => $fromOffsetY,  | 
            ||
| 1526 | 'toCoordinate' => $toCoordinate,  | 
            ||
| 1527 | 'toOffsetX' => $toOffsetX,  | 
            ||
| 1528 | 'toOffsetY' => $toOffsetY,  | 
            ||
| 1529 | 'worksheetTitle' => $docSheet->getTitle()  | 
            ||
| 1530 | );  | 
            ||
| 1531 | }  | 
            ||
| 1532 | }  | 
            ||
| 1533 | }  | 
            ||
| 1534 | |||
| 1535 | }  | 
            ||
| 1536 | }  | 
            ||
| 1537 | }  | 
            ||
| 1538 | |||
| 1539 | // Loop through definedNames  | 
            ||
| 1540 | 							if ($xmlWorkbook->definedNames) { | 
            ||
| 1541 | 								foreach ($xmlWorkbook->definedNames->definedName as $definedName) { | 
            ||
| 1542 | // Extract range  | 
            ||
| 1543 | $extractedRange = (string)$definedName;  | 
            ||
| 1544 | 									$extractedRange = preg_replace('/\'(\w+)\'\!/', '', $extractedRange); | 
            ||
| 1545 | 									if (($spos = strpos($extractedRange,'!')) !== false) { | 
            ||
| 1546 | 										$extractedRange = substr($extractedRange,0,$spos).str_replace('$', '', substr($extractedRange,$spos)); | 
            ||
| 1547 | 									} else { | 
            ||
| 1548 | 										$extractedRange = str_replace('$', '', $extractedRange); | 
            ||
| 1549 | }  | 
            ||
| 1550 | |||
| 1551 | // Valid range?  | 
            ||
| 1552 | 									if (stripos((string)$definedName, '#REF!') !== false || $extractedRange == '') { | 
            ||
| 1553 | continue;  | 
            ||
| 1554 | }  | 
            ||
| 1555 | |||
| 1556 | // Some definedNames are only applicable if we are on the same sheet...  | 
            ||
| 1557 | 									if ((string)$definedName['localSheetId'] != '' && (string)$definedName['localSheetId'] == $sheetId) { | 
            ||
| 1558 | // Switch on type  | 
            ||
| 1559 | 										switch ((string)$definedName['name']) { | 
            ||
| 1560 | |||
| 1561 | case '_xlnm._FilterDatabase':  | 
            ||
| 1562 | $docSheet->setAutoFilter($extractedRange);  | 
            ||
| 1563 | break;  | 
            ||
| 1564 | |||
| 1565 | case '_xlnm.Print_Titles':  | 
            ||
| 1566 | // Split $extractedRange  | 
            ||
| 1567 | 												$extractedRange = explode(',', $extractedRange); | 
            ||
| 1568 | |||
| 1569 | // Set print titles  | 
            ||
| 1570 | 												foreach ($extractedRange as $range) { | 
            ||
| 1571 | $matches = array();  | 
            ||
| 1572 | |||
| 1573 | // check for repeating columns, e g. 'A:A' or 'A:D'  | 
            ||
| 1574 | 													if (preg_match('/^([A-Z]+)\:([A-Z]+)$/', $range, $matches)) { | 
            ||
| 1575 | $docSheet->getPageSetup()->setColumnsToRepeatAtLeft(array($matches[1], $matches[2]));  | 
            ||
| 1576 | }  | 
            ||
| 1577 | // check for repeating rows, e.g. '1:1' or '1:5'  | 
            ||
| 1578 | 													elseif (preg_match('/^(\d+)\:(\d+)$/', $range, $matches)) { | 
            ||
| 1579 | $docSheet->getPageSetup()->setRowsToRepeatAtTop(array($matches[1], $matches[2]));  | 
            ||
| 1580 | }  | 
            ||
| 1581 | }  | 
            ||
| 1582 | break;  | 
            ||
| 1583 | |||
| 1584 | case '_xlnm.Print_Area':  | 
            ||
| 1585 | 												$rangeSets = explode(',', $extractedRange);		// FIXME: what if sheetname contains comma? | 
            ||
| 1586 | $newRangeSets = array();  | 
            ||
| 1587 | 												foreach($rangeSets as $rangeSet) { | 
            ||
| 1588 | 													$range = explode('!', $rangeSet);	// FIXME: what if sheetname contains exclamation mark? | 
            ||
| 1589 | $rangeSet = isset($range[1]) ? $range[1] : $range[0];  | 
            ||
| 1590 | 													$newRangeSets[] = str_replace('$', '', $rangeSet); | 
            ||
| 1591 | }  | 
            ||
| 1592 | 												$docSheet->getPageSetup()->setPrintArea(implode(',',$newRangeSets)); | 
            ||
| 1593 | break;  | 
            ||
| 1594 | |||
| 1595 | default:  | 
            ||
| 1596 | break;  | 
            ||
| 1597 | }  | 
            ||
| 1598 | }  | 
            ||
| 1599 | }  | 
            ||
| 1600 | }  | 
            ||
| 1601 | |||
| 1602 | // Next sheet id  | 
            ||
| 1603 | ++$sheetId;  | 
            ||
| 1604 | }  | 
            ||
| 1605 | |||
| 1606 | // Loop through definedNames  | 
            ||
| 1607 | 						if ($xmlWorkbook->definedNames) { | 
            ||
| 1608 | 							foreach ($xmlWorkbook->definedNames->definedName as $definedName) { | 
            ||
| 1609 | // Extract range  | 
            ||
| 1610 | $extractedRange = (string)$definedName;  | 
            ||
| 1611 | 								$extractedRange = preg_replace('/\'(\w+)\'\!/', '', $extractedRange); | 
            ||
| 1612 | 								if (($spos = strpos($extractedRange,'!')) !== false) { | 
            ||
| 1613 | 									$extractedRange = substr($extractedRange,0,$spos).str_replace('$', '', substr($extractedRange,$spos)); | 
            ||
| 1614 | 								} else { | 
            ||
| 1615 | 									$extractedRange = str_replace('$', '', $extractedRange); | 
            ||
| 1616 | }  | 
            ||
| 1617 | |||
| 1618 | // Valid range?  | 
            ||
| 1619 | 								if (stripos((string)$definedName, '#REF!') !== false || $extractedRange == '') { | 
            ||
| 1620 | continue;  | 
            ||
| 1621 | }  | 
            ||
| 1622 | |||
| 1623 | // Some definedNames are only applicable if we are on the same sheet...  | 
            ||
| 1624 | 								if ((string)$definedName['localSheetId'] != '') { | 
            ||
| 1625 | // Local defined name  | 
            ||
| 1626 | // Switch on type  | 
            ||
| 1627 | 									switch ((string)$definedName['name']) { | 
            ||
| 1628 | |||
| 1629 | case '_xlnm._FilterDatabase':  | 
            ||
| 1630 | case '_xlnm.Print_Titles':  | 
            ||
| 1631 | case '_xlnm.Print_Area':  | 
            ||
| 1632 | break;  | 
            ||
| 1633 | |||
| 1634 | default:  | 
            ||
| 1635 | 											$range = explode('!', (string)$definedName); | 
            ||
| 1636 | 											if (count($range) == 2) { | 
            ||
| 1637 | 												$range[0] = str_replace("''", "'", $range[0]); | 
            ||
| 1638 | 												$range[0] = str_replace("'", "", $range[0]); | 
            ||
| 1639 | 												if ($worksheet = $docSheet->getParent()->getSheetByName($range[0])) { | 
            ||
| 1640 | 													$extractedRange = str_replace('$', '', $range[1]); | 
            ||
| 1641 | $scope = $docSheet->getParent()->getSheet((string)$definedName['localSheetId']);  | 
            ||
| 1642 | |||
| 1643 | $excel->addNamedRange( new PHPExcel_NamedRange((string)$definedName['name'], $worksheet, $extractedRange, true, $scope) );  | 
            ||
| 1644 | }  | 
            ||
| 1645 | }  | 
            ||
| 1646 | break;  | 
            ||
| 1647 | }  | 
            ||
| 1648 | 								} else if (!isset($definedName['localSheetId'])) { | 
            ||
| 1649 | // "Global" definedNames  | 
            ||
| 1650 | $locatedSheet = null;  | 
            ||
| 1651 | $extractedSheetName = '';  | 
            ||
| 1652 | 									if (strpos( (string)$definedName, '!' ) !== false) { | 
            ||
| 1653 | // Extract sheet name  | 
            ||
| 1654 | $extractedSheetName = PHPExcel_Worksheet::extractSheetTitle( (string)$definedName, true );  | 
            ||
| 1655 | $extractedSheetName = $extractedSheetName[0];  | 
            ||
| 1656 | |||
| 1657 | // Locate sheet  | 
            ||
| 1658 | $locatedSheet = $excel->getSheetByName($extractedSheetName);  | 
            ||
| 1659 | |||
| 1660 | // Modify range  | 
            ||
| 1661 | 										$range = explode('!', $extractedRange); | 
            ||
| 1662 | $extractedRange = isset($range[1]) ? $range[1] : $range[0];  | 
            ||
| 1663 | }  | 
            ||
| 1664 | |||
| 1665 | 									if ($locatedSheet !== NULL) { | 
            ||
| 1666 | $excel->addNamedRange( new PHPExcel_NamedRange((string)$definedName['name'], $locatedSheet, $extractedRange, false) );  | 
            ||
| 1667 | }  | 
            ||
| 1668 | }  | 
            ||
| 1669 | }  | 
            ||
| 1670 | }  | 
            ||
| 1671 | }  | 
            ||
| 1672 | |||
| 1673 | 					if (!$this->_readDataOnly) { | 
            ||
| 1674 | // active sheet index  | 
            ||
| 1675 | $activeTab = intval($xmlWorkbook->bookViews->workbookView["activeTab"]); // refers to old sheet index  | 
            ||
| 1676 | |||
| 1677 | // keep active sheet index if sheet is still loaded, else first sheet is set as the active  | 
            ||
| 1678 | 						if (isset($mapSheetId[$activeTab]) && $mapSheetId[$activeTab] !== null) { | 
            ||
| 1679 | $excel->setActiveSheetIndex($mapSheetId[$activeTab]);  | 
            ||
| 1680 | 						} else { | 
            ||
| 1681 | 							if ($excel->getSheetCount() == 0) { | 
            ||
| 1682 | $excel->createSheet();  | 
            ||
| 1683 | }  | 
            ||
| 1684 | $excel->setActiveSheetIndex(0);  | 
            ||
| 1685 | }  | 
            ||
| 1686 | }  | 
            ||
| 1687 | break;  | 
            ||
| 1688 | }  | 
            ||
| 1689 | |||
| 1690 | }  | 
            ||
| 1691 | |||
| 1692 | |||
| 1693 | 		if (!$this->_readDataOnly) { | 
            ||
| 1694 | $contentTypes = simplexml_load_string($this->_getFromZipArchive($zip, "[Content_Types].xml"));  | 
            ||
| 1695 | 			foreach ($contentTypes->Override as $contentType) { | 
            ||
| 1696 | 				switch ($contentType["ContentType"]) { | 
            ||
| 1697 | case "application/vnd.openxmlformats-officedocument.drawingml.chart+xml":  | 
            ||
| 1698 | 						if ($this->_includeCharts) { | 
            ||
| 1699 | $chartEntryRef = ltrim($contentType['PartName'],'/');  | 
            ||
| 1700 | $chartElements = simplexml_load_string($this->_getFromZipArchive($zip, $chartEntryRef));  | 
            ||
| 1701 | $objChart = PHPExcel_Reader_Excel2007_Chart::readChart($chartElements,basename($chartEntryRef,'.xml'));  | 
            ||
| 1702 | |||
| 1703 | // echo 'Chart ',$chartEntryRef,'<br />';  | 
            ||
| 1704 | // var_dump($charts[$chartEntryRef]);  | 
            ||
| 1705 | //  | 
            ||
| 1706 | 							if (isset($charts[$chartEntryRef])) { | 
            ||
| 1707 | $chartPositionRef = $charts[$chartEntryRef]['sheet'].'!'.$charts[$chartEntryRef]['id'];  | 
            ||
| 1708 | // echo 'Position Ref ',$chartPositionRef,'<br />';  | 
            ||
| 1709 | 								if (isset($chartDetails[$chartPositionRef])) { | 
            ||
| 1710 | // var_dump($chartDetails[$chartPositionRef]);  | 
            ||
| 1711 | |||
| 1712 | $excel->getSheetByName($charts[$chartEntryRef]['sheet'])->addChart($objChart);  | 
            ||
| 1713 | $objChart->setWorksheet($excel->getSheetByName($charts[$chartEntryRef]['sheet']));  | 
            ||
| 1714 | $objChart->setTopLeftPosition( $chartDetails[$chartPositionRef]['fromCoordinate'],  | 
            ||
| 1715 | $chartDetails[$chartPositionRef]['fromOffsetX'],  | 
            ||
| 1716 | $chartDetails[$chartPositionRef]['fromOffsetY']  | 
            ||
| 1717 | );  | 
            ||
| 1718 | $objChart->setBottomRightPosition( $chartDetails[$chartPositionRef]['toCoordinate'],  | 
            ||
| 1719 | $chartDetails[$chartPositionRef]['toOffsetX'],  | 
            ||
| 1720 | $chartDetails[$chartPositionRef]['toOffsetY']  | 
            ||
| 1721 | );  | 
            ||
| 1722 | }  | 
            ||
| 1723 | }  | 
            ||
| 1724 | }  | 
            ||
| 1725 | }  | 
            ||
| 1726 | }  | 
            ||
| 1727 | }  | 
            ||
| 1728 | |||
| 1729 | $zip->close();  | 
            ||
| 1730 | |||
| 1731 | return $excel;  | 
            ||
| 1732 | }  | 
            ||
| 1733 | |||
| 1999 | 
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..