347 if (!file_exists($pFilename)) {
353 $excel->removeSheetByIndex(0);
354 if (!$this->_readDataOnly) {
355 $excel->removeCellStyleXfByIndex(0);
356 $excel->removeCellXfByIndex(0);
361 $zip =
new $zipClass;
362 $zip->open($pFilename);
366 foreach ($wbRels->Relationship as $rel) {
367 switch ($rel[
"Type"]) {
368 case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme":
369 $themeOrderArray =
array(
'lt1',
'dk1',
'lt2',
'dk2');
370 $themeOrderAdditional = count($themeOrderArray);
373 if (is_object($xmlTheme)) {
374 $xmlThemeName = $xmlTheme->attributes();
375 $xmlTheme = $xmlTheme->children(
"http://schemas.openxmlformats.org/drawingml/2006/main");
376 $themeName = (
string)$xmlThemeName[
'name'];
378 $colourScheme = $xmlTheme->themeElements->clrScheme->attributes();
379 $colourSchemeName = (
string)$colourScheme[
'name'];
380 $colourScheme = $xmlTheme->themeElements->clrScheme->children(
"http://schemas.openxmlformats.org/drawingml/2006/main");
382 $themeColours =
array();
383 foreach ($colourScheme as $k => $xmlColour) {
384 $themePos = array_search($k,$themeOrderArray);
385 if ($themePos ===
false) {
386 $themePos = $themeOrderAdditional++;
388 if (isset($xmlColour->sysClr)) {
389 $xmlColourData = $xmlColour->sysClr->attributes();
390 $themeColours[$themePos] = $xmlColourData[
'lastClr'];
391 } elseif (isset($xmlColour->srgbClr)) {
392 $xmlColourData = $xmlColour->srgbClr->attributes();
393 $themeColours[$themePos] = $xmlColourData[
'val'];
403 foreach ($rels->Relationship as $rel) {
404 switch ($rel[
"Type"]) {
405 case "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties":
407 if (is_object($xmlCore)) {
408 $xmlCore->registerXPathNamespace(
"dc",
"http://purl.org/dc/elements/1.1/");
409 $xmlCore->registerXPathNamespace(
"dcterms",
"http://purl.org/dc/terms/");
410 $xmlCore->registerXPathNamespace(
"cp",
"http://schemas.openxmlformats.org/package/2006/metadata/core-properties");
411 $docProps = $excel->getProperties();
412 $docProps->setCreator((
string) self::array_item($xmlCore->xpath(
"dc:creator")));
413 $docProps->setLastModifiedBy((
string) self::array_item($xmlCore->xpath(
"cp:lastModifiedBy")));
414 $docProps->setCreated(strtotime(self::array_item($xmlCore->xpath(
"dcterms:created"))));
415 $docProps->setModified(strtotime(self::array_item($xmlCore->xpath(
"dcterms:modified"))));
416 $docProps->setTitle((
string) self::array_item($xmlCore->xpath(
"dc:title")));
417 $docProps->setDescription((
string) self::array_item($xmlCore->xpath(
"dc:description")));
418 $docProps->setSubject((
string) self::array_item($xmlCore->xpath(
"dc:subject")));
419 $docProps->setKeywords((
string) self::array_item($xmlCore->xpath(
"cp:keywords")));
420 $docProps->setCategory((
string) self::array_item($xmlCore->xpath(
"cp:category")));
424 case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties":
426 if (is_object($xmlCore)) {
427 $docProps = $excel->getProperties();
428 if (isset($xmlCore->Company))
429 $docProps->setCompany((
string) $xmlCore->Company);
430 if (isset($xmlCore->Manager))
431 $docProps->setManager((
string) $xmlCore->Manager);
435 case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties":
437 if (is_object($xmlCore)) {
438 $docProps = $excel->getProperties();
439 foreach ($xmlCore as $xmlProperty) {
440 $cellDataOfficeAttributes = $xmlProperty->attributes();
441 if (isset($cellDataOfficeAttributes[
'name'])) {
442 $propertyName = (
string) $cellDataOfficeAttributes[
'name'];
443 $cellDataOfficeChildren = $xmlProperty->children(
'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes');
444 $attributeType = $cellDataOfficeChildren->getName();
445 $attributeValue = (
string) $cellDataOfficeChildren->{$attributeType};
448 $docProps->setCustomProperty($propertyName,$attributeValue,$attributeType);
454 case "http://schemas.microsoft.com/office/2006/relationships/ui/extensibility":
455 $customUI = $rel[
'Target'];
456 if(!is_null($customUI)){
460 case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument":
461 $dir = dirname($rel[
"Target"]);
463 $relsWorkbook->registerXPathNamespace(
"rel",
"http://schemas.openxmlformats.org/package/2006/relationships");
465 $sharedStrings =
array();
466 $xpath = self::array_item($relsWorkbook->xpath(
"rel:Relationship[@Type='http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings']"));
468 if (isset($xmlStrings) && isset($xmlStrings->si)) {
469 foreach ($xmlStrings->si as $val) {
470 if (isset($val->t)) {
472 } elseif (isset($val->r)) {
478 $worksheets =
array();
479 $macros = $customUI = NULL;
480 foreach ($relsWorkbook->Relationship as $ele) {
481 switch($ele[
'Type']){
482 case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet":
483 $worksheets[(
string) $ele[
"Id"]] = $ele[
"Target"];
486 case "http://schemas.microsoft.com/office/2006/relationships/vbaProject":
487 $macros = $ele[
"Target"];
492 if(!is_null($macros)){
494 if($macrosCode !==
false){
495 $excel->setMacrosCode($macrosCode);
496 $excel->setHasMacros(
true);
499 if($Certificate !==
false)
500 $excel->setMacrosCertificate($Certificate);
504 $cellStyles =
array();
505 $xpath = self::array_item($relsWorkbook->xpath(
"rel:Relationship[@Type='http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles']"));
508 if ($xmlStyles && $xmlStyles->numFmts[0]) {
509 $numFmts = $xmlStyles->numFmts[0];
511 if (isset($numFmts) && ($numFmts !== NULL)) {
512 $numFmts->registerXPathNamespace(
"sml",
"http://schemas.openxmlformats.org/spreadsheetml/2006/main");
514 if (!$this->_readDataOnly && $xmlStyles) {
515 foreach ($xmlStyles->cellXfs->xf as $xf) {
518 if ($xf[
"numFmtId"]) {
519 if (isset($numFmts)) {
520 $tmpNumFmt = self::array_item($numFmts->xpath(
"sml:numFmt[@numFmtId=$xf[numFmtId]]"));
522 if (isset($tmpNumFmt[
"formatCode"])) {
523 $numFmt = (
string) $tmpNumFmt[
"formatCode"];
527 if ((
int)$xf[
"numFmtId"] < 164) {
531 $quotePrefix =
false;
532 if (isset($xf[
"quotePrefix"])) {
533 $quotePrefix = (
boolean) $xf[
"quotePrefix"];
540 "font" => $xmlStyles->fonts->font[intval($xf[
"fontId"])],
541 "fill" => $xmlStyles->fills->fill[intval($xf[
"fillId"])],
542 "border" => $xmlStyles->borders->border[intval($xf[
"borderId"])],
543 "alignment" => $xf->alignment,
544 "protection" => $xf->protection,
545 "quotePrefix" => $quotePrefix,
551 self::_readStyle($objStyle,
$style);
552 $excel->addCellXf($objStyle);
555 foreach ($xmlStyles->cellStyleXfs->xf as $xf) {
557 if ($numFmts && $xf[
"numFmtId"]) {
558 $tmpNumFmt = self::array_item($numFmts->xpath(
"sml:numFmt[@numFmtId=$xf[numFmtId]]"));
559 if (isset($tmpNumFmt[
"formatCode"])) {
560 $numFmt = (
string) $tmpNumFmt[
"formatCode"];
561 }
else if ((
int)$xf[
"numFmtId"] < 165) {
568 "font" => $xmlStyles->fonts->font[intval($xf[
"fontId"])],
569 "fill" => $xmlStyles->fills->fill[intval($xf[
"fillId"])],
570 "border" => $xmlStyles->borders->border[intval($xf[
"borderId"])],
571 "alignment" => $xf->alignment,
572 "protection" => $xf->protection,
573 "quotePrefix" => $quotePrefix,
575 $cellStyles[] = $cellStyle;
579 self::_readStyle($objStyle, $cellStyle);
580 $excel->addCellStyleXf($objStyle);
585 if (!$this->_readDataOnly && $xmlStyles) {
587 if ($xmlStyles->dxfs) {
588 foreach ($xmlStyles->dxfs->dxf as $dxf) {
590 self::_readStyle(
$style, $dxf);
595 if ($xmlStyles->cellStyles) {
596 foreach ($xmlStyles->cellStyles->cellStyle as $cellStyle) {
597 if (intval($cellStyle[
'builtinId']) == 0) {
598 if (isset($cellStyles[intval($cellStyle[
'xfId'])])) {
601 self::_readStyle(
$style, $cellStyles[intval($cellStyle[
'xfId'])]);
613 if ($xmlWorkbook->workbookPr) {
615 if (isset($xmlWorkbook->workbookPr[
'date1904'])) {
616 if (self::boolean((
string) $xmlWorkbook->workbookPr[
'date1904'])) {
624 $countSkippedSheets = 0;
625 $mapSheetId =
array();
628 $charts = $chartDetails =
array();
630 if ($xmlWorkbook->sheets) {
631 foreach ($xmlWorkbook->sheets->sheet as $eleSheet) {
635 if (isset($this->_loadSheetsOnly) && !in_array((
string) $eleSheet[
"name"], $this->_loadSheetsOnly)) {
636 ++$countSkippedSheets;
637 $mapSheetId[$oldSheetId] = null;
643 $mapSheetId[$oldSheetId] = $oldSheetId - $countSkippedSheets;
646 $docSheet = $excel->createSheet();
651 $docSheet->setTitle((
string) $eleSheet[
"name"],
false);
652 $fileWorksheet = $worksheets[(
string) self::array_item($eleSheet->attributes(
"http://schemas.openxmlformats.org/officeDocument/2006/relationships"),
"id")];
655 $sharedFormulas =
array();
657 if (isset($eleSheet[
"state"]) && (
string) $eleSheet[
"state"] !=
'') {
658 $docSheet->setSheetState( (
string) $eleSheet[
"state"] );
661 if (isset($xmlSheet->sheetViews) && isset($xmlSheet->sheetViews->sheetView)) {
662 if (isset($xmlSheet->sheetViews->sheetView[
'zoomScale'])) {
663 $docSheet->getSheetView()->setZoomScale( intval($xmlSheet->sheetViews->sheetView[
'zoomScale']) );
666 if (isset($xmlSheet->sheetViews->sheetView[
'zoomScaleNormal'])) {
667 $docSheet->getSheetView()->setZoomScaleNormal( intval($xmlSheet->sheetViews->sheetView[
'zoomScaleNormal']) );
670 if (isset($xmlSheet->sheetViews->sheetView[
'view'])) {
671 $docSheet->getSheetView()->setView((
string) $xmlSheet->sheetViews->sheetView[
'view']);
674 if (isset($xmlSheet->sheetViews->sheetView[
'showGridLines'])) {
675 $docSheet->setShowGridLines(self::boolean((
string)$xmlSheet->sheetViews->sheetView[
'showGridLines']));
678 if (isset($xmlSheet->sheetViews->sheetView[
'showRowColHeaders'])) {
679 $docSheet->setShowRowColHeaders(self::boolean((
string)$xmlSheet->sheetViews->sheetView[
'showRowColHeaders']));
682 if (isset($xmlSheet->sheetViews->sheetView[
'rightToLeft'])) {
683 $docSheet->setRightToLeft(self::boolean((
string)$xmlSheet->sheetViews->sheetView[
'rightToLeft']));
686 if (isset($xmlSheet->sheetViews->sheetView->pane)) {
687 if (isset($xmlSheet->sheetViews->sheetView->pane[
'topLeftCell'])) {
688 $docSheet->freezePane( (
string)$xmlSheet->sheetViews->sheetView->pane[
'topLeftCell'] );
693 if (isset($xmlSheet->sheetViews->sheetView->pane[
'xSplit'])) {
694 $xSplit = 1 + intval($xmlSheet->sheetViews->sheetView->pane[
'xSplit']);
697 if (isset($xmlSheet->sheetViews->sheetView->pane[
'ySplit'])) {
698 $ySplit = 1 + intval($xmlSheet->sheetViews->sheetView->pane[
'ySplit']);
701 $docSheet->freezePaneByColumnAndRow($xSplit, $ySplit);
705 if (isset($xmlSheet->sheetViews->sheetView->selection)) {
706 if (isset($xmlSheet->sheetViews->sheetView->selection[
'sqref'])) {
707 $sqref = (
string)$xmlSheet->sheetViews->sheetView->selection[
'sqref'];
708 $sqref = explode(
' ', $sqref);
710 $docSheet->setSelectedCells($sqref);
716 if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr->tabColor)) {
717 if (isset($xmlSheet->sheetPr->tabColor[
'rgb'])) {
718 $docSheet->getTabColor()->setARGB( (
string)$xmlSheet->sheetPr->tabColor[
'rgb'] );
721 if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr[
'codeName'])) {
722 $docSheet->setCodeName((
string) $xmlSheet->sheetPr[
'codeName']);
724 if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr->outlinePr)) {
725 if (isset($xmlSheet->sheetPr->outlinePr[
'summaryRight']) &&
726 !self::boolean((
string) $xmlSheet->sheetPr->outlinePr[
'summaryRight'])) {
727 $docSheet->setShowSummaryRight(FALSE);
729 $docSheet->setShowSummaryRight(TRUE);
732 if (isset($xmlSheet->sheetPr->outlinePr[
'summaryBelow']) &&
733 !self::boolean((
string) $xmlSheet->sheetPr->outlinePr[
'summaryBelow'])) {
734 $docSheet->setShowSummaryBelow(FALSE);
736 $docSheet->setShowSummaryBelow(TRUE);
740 if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr->pageSetUpPr)) {
741 if (isset($xmlSheet->sheetPr->pageSetUpPr[
'fitToPage']) &&
742 !self::boolean((
string) $xmlSheet->sheetPr->pageSetUpPr[
'fitToPage'])) {
743 $docSheet->getPageSetup()->setFitToPage(FALSE);
745 $docSheet->getPageSetup()->setFitToPage(TRUE);
749 if (isset($xmlSheet->sheetFormatPr)) {
750 if (isset($xmlSheet->sheetFormatPr[
'customHeight']) &&
751 self::boolean((
string) $xmlSheet->sheetFormatPr[
'customHeight']) &&
752 isset($xmlSheet->sheetFormatPr[
'defaultRowHeight'])) {
753 $docSheet->getDefaultRowDimension()->setRowHeight( (
float)$xmlSheet->sheetFormatPr[
'defaultRowHeight'] );
755 if (isset($xmlSheet->sheetFormatPr[
'defaultColWidth'])) {
756 $docSheet->getDefaultColumnDimension()->setWidth( (
float)$xmlSheet->sheetFormatPr[
'defaultColWidth'] );
758 if (isset($xmlSheet->sheetFormatPr[
'zeroHeight']) &&
759 ((
string)$xmlSheet->sheetFormatPr[
'zeroHeight'] ==
'1')) {
760 $docSheet->getDefaultRowDimension()->setZeroHeight(
true);
764 if (isset($xmlSheet->cols) && !$this->_readDataOnly) {
765 foreach ($xmlSheet->cols->col as $col) {
766 for ($i = intval($col[
"min"]) - 1; $i < intval($col[
"max"]); ++$i) {
767 if ($col[
"style"] && !$this->_readDataOnly) {
770 if (self::boolean($col[
"bestFit"])) {
773 if (self::boolean($col[
"hidden"])) {
777 if (self::boolean($col[
"collapsed"])) {
780 if ($col[
"outlineLevel"] > 0) {
785 if (intval($col[
"max"]) == 16384) {
792 if (isset($xmlSheet->printOptions) && !$this->_readDataOnly) {
793 if (self::boolean((
string) $xmlSheet->printOptions[
'gridLinesSet'])) {
794 $docSheet->setShowGridlines(TRUE);
797 if (self::boolean((
string) $xmlSheet->printOptions[
'gridLines'])) {
798 $docSheet->setPrintGridlines(TRUE);
801 if (self::boolean((
string) $xmlSheet->printOptions[
'horizontalCentered'])) {
802 $docSheet->getPageSetup()->setHorizontalCentered(TRUE);
804 if (self::boolean((
string) $xmlSheet->printOptions[
'verticalCentered'])) {
805 $docSheet->getPageSetup()->setVerticalCentered(TRUE);
809 if ($xmlSheet && $xmlSheet->sheetData && $xmlSheet->sheetData->row) {
810 foreach ($xmlSheet->sheetData->row as
$row) {
811 if ($row[
"ht"] && !$this->_readDataOnly) {
812 $docSheet->getRowDimension(intval($row[
"r"]))->setRowHeight(floatval($row[
"ht"]));
814 if (self::boolean($row[
"hidden"]) && !$this->_readDataOnly) {
815 $docSheet->getRowDimension(intval($row[
"r"]))->setVisible(FALSE);
817 if (self::boolean($row[
"collapsed"])) {
818 $docSheet->getRowDimension(intval($row[
"r"]))->setCollapsed(TRUE);
820 if ($row[
"outlineLevel"] > 0) {
821 $docSheet->getRowDimension(intval($row[
"r"]))->setOutlineLevel(intval($row[
"outlineLevel"]));
823 if ($row[
"s"] && !$this->_readDataOnly) {
824 $docSheet->getRowDimension(intval($row[
"r"]))->setXfIndex(intval($row[
"s"]));
827 foreach ($row->c as $c) {
829 $cellDataType = (
string) $c[
"t"];
831 $calculatedValue = null;
837 if (!$this->
getReadFilter()->readCell($coordinates[0], $coordinates[1], $docSheet->getTitle())) {
848 switch ($cellDataType) {
851 if ((
string)$c->v !=
'') {
852 $value = $sharedStrings[intval($c->v)];
855 $value = clone $value;
865 $value = self::_castToBool($c);
868 $this->
_castToFormula($c,
$r,$cellDataType,$value,$calculatedValue,$sharedFormulas,
'_castToBool');
869 if (isset($c->f[
't'])) {
872 $docSheet->getCell(
$r)->setFormulaAttributes($att);
885 $value = self::_castToError($c);
888 $this->
_castToFormula($c,
$r,$cellDataType,$value,$calculatedValue,$sharedFormulas,
'_castToError');
898 $value = self::_castToString($c);
902 $this->
_castToFormula($c,
$r,$cellDataType,$value,$calculatedValue,$sharedFormulas,
'_castToString');
911 if (is_numeric($value) && $cellDataType !=
's') {
912 if ($value == (
int)$value) $value = (int)$value;
913 elseif ($value == (
float)$value) $value = (float)$value;
914 elseif ($value == (
double)$value) $value = (double)$value;
919 $value = $value->getPlainText();
922 $cell = $docSheet->getCell(
$r);
924 if ($cellDataType !=
'') {
925 $cell->setValueExplicit($value, $cellDataType);
927 $cell->setValue($value);
929 if ($calculatedValue !== NULL) {
930 $cell->setCalculatedValue($calculatedValue);
934 if ($c[
"s"] && !$this->_readDataOnly) {
936 $cell->setXfIndex(isset(
$styles[intval($c[
"s"])]) ?
937 intval($c[
"s"]) : 0);
943 $conditionals =
array();
944 if (!$this->_readDataOnly && $xmlSheet && $xmlSheet->conditionalFormatting) {
945 foreach ($xmlSheet->conditionalFormatting as $conditional) {
946 foreach ($conditional->cfRule as $cfRule) {
953 ) && isset($dxfs[intval($cfRule[
"dxfId"])])
955 $conditionals[(
string) $conditional[
"sqref"]][intval($cfRule[
"priority"])] = $cfRule;
960 foreach ($conditionals as $ref => $cfRules) {
963 foreach ($cfRules as $cfRule) {
965 $objConditional->setConditionType((
string)$cfRule[
"type"]);
966 $objConditional->setOperatorType((
string)$cfRule[
"operator"]);
968 if ((
string)$cfRule[
"text"] !=
'') {
969 $objConditional->setText((
string)$cfRule[
"text"]);
972 if (count($cfRule->formula) > 1) {
973 foreach ($cfRule->formula as $formula) {
974 $objConditional->addCondition((
string)$formula);
977 $objConditional->addCondition((
string)$cfRule->formula);
979 $objConditional->setStyle(clone $dxfs[intval($cfRule[
"dxfId"])]);
985 foreach ($aReferences as $reference) {
991 $aKeys =
array(
"sheet",
"objects",
"scenarios",
"formatCells",
"formatColumns",
"formatRows",
"insertColumns",
"insertRows",
"insertHyperlinks",
"deleteColumns",
"deleteRows",
"selectLockedCells",
"sort",
"autoFilter",
"pivotTables",
"selectUnlockedCells");
992 if (!$this->_readDataOnly && $xmlSheet && $xmlSheet->sheetProtection) {
993 foreach ($aKeys as $key) {
994 $method =
"set" . ucfirst($key);
995 $docSheet->getProtection()->$method(self::boolean((
string) $xmlSheet->sheetProtection[$key]));
999 if (!$this->_readDataOnly && $xmlSheet && $xmlSheet->sheetProtection) {
1000 $docSheet->getProtection()->setPassword((
string) $xmlSheet->sheetProtection[
"password"], TRUE);
1001 if ($xmlSheet->protectedRanges->protectedRange) {
1002 foreach ($xmlSheet->protectedRanges->protectedRange as $protectedRange) {
1003 $docSheet->protectCells((
string) $protectedRange[
"sqref"], (
string) $protectedRange[
"password"],
true);
1008 if ($xmlSheet && $xmlSheet->autoFilter && !$this->_readDataOnly) {
1009 $autoFilterRange = (
string) $xmlSheet->autoFilter[
"ref"];
1010 if (strpos($autoFilterRange,
':') !==
false) {
1014 foreach ($xmlSheet->autoFilter->filterColumn as $filterColumn) {
1017 if ($filterColumn->filters) {
1019 $filters = $filterColumn->filters;
1020 if ((isset($filters[
"blank"])) && ($filters[
"blank"] == 1)) {
1021 $column->createRule()->setRule(
1029 foreach ($filters->filter as $filterRule) {
1030 $column->createRule()->setRule(
1032 (
string) $filterRule[
"val"]
1037 foreach ($filters->dateGroupItem as $dateGroupItem) {
1038 $column->createRule()->setRule(
1041 'year' => (
string) $dateGroupItem[
"year"],
1042 'month' => (
string) $dateGroupItem[
"month"],
1043 'day' => (
string) $dateGroupItem[
"day"],
1044 'hour' => (
string) $dateGroupItem[
"hour"],
1045 'minute' => (
string) $dateGroupItem[
"minute"],
1046 'second' => (
string) $dateGroupItem[
"second"],
1048 (
string) $dateGroupItem[
"dateTimeGrouping"]
1054 if ($filterColumn->customFilters) {
1056 $customFilters = $filterColumn->customFilters;
1059 if ((isset($customFilters[
"and"])) && ($customFilters[
"and"] == 1)) {
1062 foreach ($customFilters->customFilter as $filterRule) {
1063 $column->createRule()->setRule(
1064 (
string) $filterRule[
"operator"],
1065 (
string) $filterRule[
"val"]
1071 if ($filterColumn->dynamicFilter) {
1074 foreach ($filterColumn->dynamicFilter as $filterRule) {
1075 $column->createRule()->setRule(
1077 (
string) $filterRule[
"val"],
1078 (
string) $filterRule[
"type"]
1081 if (isset($filterRule[
"val"])) {
1082 $column->setAttribute(
'val',(
string) $filterRule[
"val"]);
1084 if (isset($filterRule[
"maxVal"])) {
1085 $column->setAttribute(
'maxVal',(
string) $filterRule[
"maxVal"]);
1090 if ($filterColumn->top10) {
1093 foreach ($filterColumn->top10 as $filterRule) {
1094 $column->createRule()->setRule(
1095 (((isset($filterRule[
"percent"])) && ($filterRule[
"percent"] == 1))
1099 (
string) $filterRule[
"val"],
1100 (((isset($filterRule[
"top"])) && ($filterRule[
"top"] == 1))
1112 if ($xmlSheet && $xmlSheet->mergeCells && $xmlSheet->mergeCells->mergeCell && !$this->_readDataOnly) {
1113 foreach ($xmlSheet->mergeCells->mergeCell as $mergeCell) {
1114 $mergeRef = (
string) $mergeCell[
"ref"];
1115 if (strpos($mergeRef,
':') !== FALSE) {
1116 $docSheet->mergeCells((
string) $mergeCell[
"ref"]);
1121 if ($xmlSheet && $xmlSheet->pageMargins && !$this->_readDataOnly) {
1122 $docPageMargins = $docSheet->getPageMargins();
1123 $docPageMargins->setLeft(floatval($xmlSheet->pageMargins[
"left"]));
1124 $docPageMargins->setRight(floatval($xmlSheet->pageMargins[
"right"]));
1125 $docPageMargins->setTop(floatval($xmlSheet->pageMargins[
"top"]));
1126 $docPageMargins->setBottom(floatval($xmlSheet->pageMargins[
"bottom"]));
1127 $docPageMargins->setHeader(floatval($xmlSheet->pageMargins[
"header"]));
1128 $docPageMargins->setFooter(floatval($xmlSheet->pageMargins[
"footer"]));
1131 if ($xmlSheet && $xmlSheet->pageSetup && !$this->_readDataOnly) {
1132 $docPageSetup = $docSheet->getPageSetup();
1134 if (isset($xmlSheet->pageSetup[
"orientation"])) {
1135 $docPageSetup->setOrientation((
string) $xmlSheet->pageSetup[
"orientation"]);
1137 if (isset($xmlSheet->pageSetup[
"paperSize"])) {
1138 $docPageSetup->setPaperSize(intval($xmlSheet->pageSetup[
"paperSize"]));
1140 if (isset($xmlSheet->pageSetup[
"scale"])) {
1141 $docPageSetup->setScale(intval($xmlSheet->pageSetup[
"scale"]), FALSE);
1143 if (isset($xmlSheet->pageSetup[
"fitToHeight"]) && intval($xmlSheet->pageSetup[
"fitToHeight"]) >= 0) {
1144 $docPageSetup->setFitToHeight(intval($xmlSheet->pageSetup[
"fitToHeight"]), FALSE);
1146 if (isset($xmlSheet->pageSetup[
"fitToWidth"]) && intval($xmlSheet->pageSetup[
"fitToWidth"]) >= 0) {
1147 $docPageSetup->setFitToWidth(intval($xmlSheet->pageSetup[
"fitToWidth"]), FALSE);
1149 if (isset($xmlSheet->pageSetup[
"firstPageNumber"]) && isset($xmlSheet->pageSetup[
"useFirstPageNumber"]) &&
1150 self::boolean((
string) $xmlSheet->pageSetup[
"useFirstPageNumber"])) {
1151 $docPageSetup->setFirstPageNumber(intval($xmlSheet->pageSetup[
"firstPageNumber"]));
1155 if ($xmlSheet && $xmlSheet->headerFooter && !$this->_readDataOnly) {
1156 $docHeaderFooter = $docSheet->getHeaderFooter();
1158 if (isset($xmlSheet->headerFooter[
"differentOddEven"]) &&
1159 self::boolean((
string)$xmlSheet->headerFooter[
"differentOddEven"])) {
1160 $docHeaderFooter->setDifferentOddEven(TRUE);
1162 $docHeaderFooter->setDifferentOddEven(FALSE);
1164 if (isset($xmlSheet->headerFooter[
"differentFirst"]) &&
1165 self::boolean((
string)$xmlSheet->headerFooter[
"differentFirst"])) {
1166 $docHeaderFooter->setDifferentFirst(TRUE);
1168 $docHeaderFooter->setDifferentFirst(FALSE);
1170 if (isset($xmlSheet->headerFooter[
"scaleWithDoc"]) &&
1171 !self::boolean((
string)$xmlSheet->headerFooter[
"scaleWithDoc"])) {
1172 $docHeaderFooter->setScaleWithDocument(FALSE);
1174 $docHeaderFooter->setScaleWithDocument(TRUE);
1176 if (isset($xmlSheet->headerFooter[
"alignWithMargins"]) &&
1177 !self::boolean((
string)$xmlSheet->headerFooter[
"alignWithMargins"])) {
1178 $docHeaderFooter->setAlignWithMargins(FALSE);
1180 $docHeaderFooter->setAlignWithMargins(TRUE);
1183 $docHeaderFooter->setOddHeader((
string) $xmlSheet->headerFooter->oddHeader);
1184 $docHeaderFooter->setOddFooter((
string) $xmlSheet->headerFooter->oddFooter);
1185 $docHeaderFooter->setEvenHeader((
string) $xmlSheet->headerFooter->evenHeader);
1186 $docHeaderFooter->setEvenFooter((
string) $xmlSheet->headerFooter->evenFooter);
1187 $docHeaderFooter->setFirstHeader((
string) $xmlSheet->headerFooter->firstHeader);
1188 $docHeaderFooter->setFirstFooter((
string) $xmlSheet->headerFooter->firstFooter);
1191 if ($xmlSheet && $xmlSheet->rowBreaks && $xmlSheet->rowBreaks->brk && !$this->_readDataOnly) {
1192 foreach ($xmlSheet->rowBreaks->brk as $brk) {
1198 if ($xmlSheet && $xmlSheet->colBreaks && $xmlSheet->colBreaks->brk && !$this->_readDataOnly) {
1199 foreach ($xmlSheet->colBreaks->brk as $brk) {
1206 if ($xmlSheet && $xmlSheet->dataValidations && !$this->_readDataOnly) {
1207 foreach ($xmlSheet->dataValidations->dataValidation as $dataValidation) {
1209 $range = strtoupper($dataValidation[
"sqref"]);
1210 $rangeSet = explode(
' ',$range);
1211 foreach($rangeSet as $range) {
1212 $stRange = $docSheet->shrinkRangeToFit($range);
1216 foreach ($aReferences as $reference) {
1218 $docValidation = $docSheet->getCell($reference)->getDataValidation();
1219 $docValidation->setType((
string) $dataValidation[
"type"]);
1220 $docValidation->setErrorStyle((
string) $dataValidation[
"errorStyle"]);
1221 $docValidation->setOperator((
string) $dataValidation[
"operator"]);
1222 $docValidation->setAllowBlank($dataValidation[
"allowBlank"] != 0);
1223 $docValidation->setShowDropDown($dataValidation[
"showDropDown"] == 0);
1224 $docValidation->setShowInputMessage($dataValidation[
"showInputMessage"] != 0);
1225 $docValidation->setShowErrorMessage($dataValidation[
"showErrorMessage"] != 0);
1226 $docValidation->setErrorTitle((
string) $dataValidation[
"errorTitle"]);
1227 $docValidation->setError((
string) $dataValidation[
"error"]);
1228 $docValidation->setPromptTitle((
string) $dataValidation[
"promptTitle"]);
1229 $docValidation->setPrompt((
string) $dataValidation[
"prompt"]);
1230 $docValidation->setFormula1((
string) $dataValidation->formula1);
1231 $docValidation->setFormula2((
string) $dataValidation->formula2);
1238 $hyperlinks =
array();
1239 if (!$this->_readDataOnly) {
1241 if ($zip->locateName(dirname(
"$dir/$fileWorksheet") .
"/_rels/" . basename($fileWorksheet) .
".rels")) {
1243 foreach ($relsWorksheet->Relationship as $ele) {
1244 if ($ele[
"Type"] ==
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink") {
1245 $hyperlinks[(
string)$ele[
"Id"]] = (
string)$ele[
"Target"];
1251 if ($xmlSheet && $xmlSheet->hyperlinks) {
1252 foreach ($xmlSheet->hyperlinks->hyperlink as $hyperlink) {
1254 $linkRel = $hyperlink->attributes(
'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
1257 $cell = $docSheet->getCell( $cellReference );
1258 if (isset($linkRel[
'id'])) {
1259 $hyperlinkUrl = $hyperlinks[ (
string)$linkRel[
'id'] ];
1260 if (isset($hyperlink[
'location'])) {
1261 $hyperlinkUrl .=
'#' . (
string) $hyperlink[
'location'];
1263 $cell->getHyperlink()->setUrl($hyperlinkUrl);
1264 } elseif (isset($hyperlink[
'location'])) {
1265 $cell->getHyperlink()->setUrl(
'sheet://' . (
string)$hyperlink[
'location'] );
1269 if (isset($hyperlink[
'tooltip'])) {
1270 $cell->getHyperlink()->setTooltip( (
string)$hyperlink[
'tooltip'] );
1278 $comments =
array();
1279 $vmlComments =
array();
1280 if (!$this->_readDataOnly) {
1282 if ($zip->locateName(dirname(
"$dir/$fileWorksheet") .
"/_rels/" . basename($fileWorksheet) .
".rels")) {
1284 foreach ($relsWorksheet->Relationship as $ele) {
1285 if ($ele[
"Type"] ==
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments") {
1286 $comments[(
string)$ele[
"Id"]] = (
string)$ele[
"Target"];
1288 if ($ele[
"Type"] ==
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing") {
1289 $vmlComments[(
string)$ele[
"Id"]] = (
string)$ele[
"Target"];
1295 foreach ($comments as $relName => $relPath) {
1304 foreach ($commentsFile->authors->author as $author) {
1305 $authors[] = (
string)$author;
1309 foreach ($commentsFile->commentList->comment as
$comment) {
1310 if(!empty($comment[
'authorId']))
1311 $docSheet->getComment( (
string)$comment[
'ref'] )->setAuthor( $authors[(
string)$comment[
'authorId']] );
1312 $docSheet->getComment( (
string)$comment[
'ref'] )->setText( $this->
_parseRichText($comment->text) );
1317 foreach ($vmlComments as $relName => $relPath) {
1321 $vmlCommentsFile->registerXPathNamespace(
'v',
'urn:schemas-microsoft-com:vml');
1323 $shapes = $vmlCommentsFile->xpath(
'//v:shape');
1324 foreach ($shapes as $shape) {
1325 $shape->registerXPathNamespace(
'v',
'urn:schemas-microsoft-com:vml');
1327 if (isset($shape[
'style'])) {
1329 $fillColor = strtoupper( substr( (
string)$shape[
'fillcolor'], 1 ) );
1333 $clientData = $shape->xpath(
'.//x:ClientData');
1334 if (is_array($clientData) && !empty($clientData)) {
1335 $clientData = $clientData[0];
1337 if ( isset($clientData[
'ObjectType']) && (
string)$clientData[
'ObjectType'] ==
'Note' ) {
1338 $temp = $clientData->xpath(
'.//x:Row');
1339 if (is_array($temp)) $row = $temp[0];
1341 $temp = $clientData->xpath(
'.//x:Column');
1342 if (is_array($temp))
$column = $temp[0];
1346 if ((
$column !== NULL) && ($row !== NULL)) {
1348 $comment = $docSheet->getCommentByColumnAndRow((
string)
$column, $row + 1);
1349 $comment->getFillColor()->setRGB( $fillColor );
1352 $styleArray = explode(
';', str_replace(
' ',
'',
$style));
1353 foreach ($styleArray as $stylePair) {
1354 $stylePair = explode(
':', $stylePair);
1356 if ($stylePair[0] ==
'margin-left') $comment->setMarginLeft($stylePair[1]);
1357 if ($stylePair[0] ==
'margin-top') $comment->setMarginTop($stylePair[1]);
1358 if ($stylePair[0] ==
'width') $comment->setWidth($stylePair[1]);
1359 if ($stylePair[0] ==
'height') $comment->setHeight($stylePair[1]);
1360 if ($stylePair[0] ==
'visibility') $comment->setVisible( $stylePair[1] ==
'visible' );
1369 if ($xmlSheet && $xmlSheet->legacyDrawingHF && !$this->_readDataOnly) {
1370 if ($zip->locateName(dirname(
"$dir/$fileWorksheet") .
"/_rels/" . basename($fileWorksheet) .
".rels")) {
1372 $vmlRelationship =
'';
1374 foreach ($relsWorksheet->Relationship as $ele) {
1375 if ($ele[
"Type"] ==
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing") {
1376 $vmlRelationship = self::dir_add(
"$dir/$fileWorksheet", $ele[
"Target"]);
1380 if ($vmlRelationship !=
'') {
1383 $drawings =
array();
1384 foreach ($relsVML->Relationship as $ele) {
1385 if ($ele[
"Type"] ==
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image") {
1386 $drawings[(
string) $ele[
"Id"]] = self::dir_add($vmlRelationship, $ele[
"Target"]);
1392 $vmlDrawing->registerXPathNamespace(
'v',
'urn:schemas-microsoft-com:vml');
1394 $hfImages =
array();
1396 $shapes = $vmlDrawing->xpath(
'//v:shape');
1397 foreach ($shapes as $idx => $shape) {
1398 $shape->registerXPathNamespace(
'v',
'urn:schemas-microsoft-com:vml');
1399 $imageData = $shape->xpath(
'//v:imagedata');
1400 $imageData = $imageData[$idx];
1402 $imageData = $imageData->attributes(
'urn:schemas-microsoft-com:office:office');
1403 $style = self::toCSSArray( (
string)$shape[
'style'] );
1406 if (isset($imageData[
'title'])) {
1407 $hfImages[ (
string)$shape[
'id'] ]->setName( (
string)$imageData[
'title'] );
1411 $hfImages[ (
string)$shape[
'id'] ]->setResizeProportional(
false);
1412 $hfImages[ (
string)$shape[
'id'] ]->setWidth(
$style[
'width']);
1413 $hfImages[ (
string)$shape[
'id'] ]->setHeight(
$style[
'height']);
1414 if (isset(
$style[
'margin-left'])) {
1415 $hfImages[ (
string)$shape[
'id'] ]->setOffsetX(
$style[
'margin-left']);
1417 $hfImages[ (
string)$shape[
'id'] ]->setOffsetY(
$style[
'margin-top']);
1418 $hfImages[ (
string)$shape[
'id'] ]->setResizeProportional(
true);
1421 $docSheet->getHeaderFooter()->setImages($hfImages);
1429 if ($zip->locateName(dirname(
"$dir/$fileWorksheet") .
"/_rels/" . basename($fileWorksheet) .
".rels")) {
1431 $drawings =
array();
1432 foreach ($relsWorksheet->Relationship as $ele) {
1433 if ($ele[
"Type"] ==
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing") {
1434 $drawings[(
string) $ele[
"Id"]] = self::dir_add(
"$dir/$fileWorksheet", $ele[
"Target"]);
1437 if ($xmlSheet->drawing && !$this->_readDataOnly) {
1438 foreach ($xmlSheet->drawing as $drawing) {
1439 $fileDrawing = $drawings[(
string) self::array_item($drawing->attributes(
"http://schemas.openxmlformats.org/officeDocument/2006/relationships"),
"id")];
1443 if ($relsDrawing && $relsDrawing->Relationship) {
1444 foreach ($relsDrawing->Relationship as $ele) {
1445 if ($ele[
"Type"] ==
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image") {
1446 $images[(
string) $ele[
"Id"]] = self::dir_add($fileDrawing, $ele[
"Target"]);
1447 } elseif ($ele[
"Type"] ==
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart") {
1448 if ($this->_includeCharts) {
1449 $charts[self::dir_add($fileDrawing, $ele[
"Target"])] =
array(
'id' => (
string) $ele[
"Id"],
1450 'sheet' => $docSheet->getTitle()
1458 if ($xmlDrawing->oneCellAnchor) {
1459 foreach ($xmlDrawing->oneCellAnchor as $oneCellAnchor) {
1460 if ($oneCellAnchor->pic->blipFill) {
1461 $blip = $oneCellAnchor->pic->blipFill->children(
"http://schemas.openxmlformats.org/drawingml/2006/main")->blip;
1462 $xfrm = $oneCellAnchor->pic->spPr->children(
"http://schemas.openxmlformats.org/drawingml/2006/main")->xfrm;
1463 $outerShdw = $oneCellAnchor->pic->spPr->children(
"http://schemas.openxmlformats.org/drawingml/2006/main")->effectLst->outerShdw;
1465 $objDrawing->setName((
string) self::array_item($oneCellAnchor->pic->nvPicPr->cNvPr->attributes(),
"name"));
1466 $objDrawing->setDescription((
string) self::array_item($oneCellAnchor->pic->nvPicPr->cNvPr->attributes(),
"descr"));
1467 $objDrawing->setPath(
"zip://".
PHPExcel_Shared_File::realpath($pFilename).
"#" . $images[(
string) self::array_item($blip->attributes(
"http://schemas.openxmlformats.org/officeDocument/2006/relationships"),
"embed")],
false);
1479 $shadow->setVisible(
true);
1480 $shadow->setBlurRadius(PHPExcel_Shared_Drawing::EMUTopixels(self::array_item($outerShdw->attributes(),
"blurRad")));
1481 $shadow->setDistance(PHPExcel_Shared_Drawing::EMUTopixels(self::array_item($outerShdw->attributes(),
"dist")));
1483 $shadow->setAlignment((
string) self::array_item($outerShdw->attributes(),
"algn"));
1484 $shadow->getColor()->setRGB(self::array_item($outerShdw->srgbClr->attributes(),
"val"));
1485 $shadow->setAlpha(self::array_item($outerShdw->srgbClr->alpha->attributes(),
"val") / 1000);
1498 if ($xmlDrawing->twoCellAnchor) {
1499 foreach ($xmlDrawing->twoCellAnchor as $twoCellAnchor) {
1500 if ($twoCellAnchor->pic->blipFill) {
1501 $blip = $twoCellAnchor->pic->blipFill->children(
"http://schemas.openxmlformats.org/drawingml/2006/main")->blip;
1502 $xfrm = $twoCellAnchor->pic->spPr->children(
"http://schemas.openxmlformats.org/drawingml/2006/main")->xfrm;
1503 $outerShdw = $twoCellAnchor->pic->spPr->children(
"http://schemas.openxmlformats.org/drawingml/2006/main")->effectLst->outerShdw;
1505 $objDrawing->setName((
string) self::array_item($twoCellAnchor->pic->nvPicPr->cNvPr->attributes(),
"name"));
1506 $objDrawing->setDescription((
string) self::array_item($twoCellAnchor->pic->nvPicPr->cNvPr->attributes(),
"descr"));
1507 $objDrawing->setPath(
"zip://".
PHPExcel_Shared_File::realpath($pFilename).
"#" . $images[(
string) self::array_item($blip->attributes(
"http://schemas.openxmlformats.org/officeDocument/2006/relationships"),
"embed")],
false);
1520 $shadow->setVisible(
true);
1521 $shadow->setBlurRadius(PHPExcel_Shared_Drawing::EMUTopixels(self::array_item($outerShdw->attributes(),
"blurRad")));
1522 $shadow->setDistance(PHPExcel_Shared_Drawing::EMUTopixels(self::array_item($outerShdw->attributes(),
"dist")));
1524 $shadow->setAlignment((
string) self::array_item($outerShdw->attributes(),
"algn"));
1525 $shadow->getColor()->setRGB(self::array_item($outerShdw->srgbClr->attributes(),
"val"));
1526 $shadow->setAlpha(self::array_item($outerShdw->srgbClr->alpha->attributes(),
"val") / 1000);
1529 } elseif(($this->_includeCharts) && ($twoCellAnchor->graphicFrame)) {
1536 $graphic = $twoCellAnchor->graphicFrame->children(
"http://schemas.openxmlformats.org/drawingml/2006/main")->graphic;
1537 $chartRef = $graphic->graphicData->children(
"http://schemas.openxmlformats.org/drawingml/2006/chart")->chart;
1538 $thisChart = (
string) $chartRef->attributes(
"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
1540 $chartDetails[$docSheet->getTitle().
'!'.$thisChart] =
1541 array(
'fromCoordinate' => $fromCoordinate,
1542 'fromOffsetX' => $fromOffsetX,
1543 'fromOffsetY' => $fromOffsetY,
1544 'toCoordinate' => $toCoordinate,
1545 'toOffsetX' => $toOffsetX,
1546 'toOffsetY' => $toOffsetY,
1547 'worksheetTitle' => $docSheet->getTitle()
1558 if ($xmlWorkbook->definedNames) {
1559 foreach ($xmlWorkbook->definedNames->definedName as $definedName) {
1561 $extractedRange = (
string)$definedName;
1562 $extractedRange = preg_replace(
'/\'(\w+)\'\!/',
'', $extractedRange);
1563 if (($spos = strpos($extractedRange,
'!')) !==
false) {
1564 $extractedRange = substr($extractedRange,0,$spos).str_replace(
'$',
'', substr($extractedRange,$spos));
1566 $extractedRange = str_replace(
'$',
'', $extractedRange);
1570 if (stripos((
string)$definedName,
'#REF!') !== FALSE || $extractedRange ==
'') {
1575 if ((
string)$definedName[
'localSheetId'] !=
'' && (
string)$definedName[
'localSheetId'] == $sheetId) {
1577 switch ((
string)$definedName[
'name']) {
1579 case '_xlnm._FilterDatabase':
1580 if ((
string)$definedName[
'hidden'] !==
'1') {
1581 $extractedRange = explode(
',', $extractedRange);
1582 foreach ($extractedRange as $range) {
1583 $autoFilterRange = $range;
1584 if (strpos($autoFilterRange,
':') !==
false) {
1585 $docSheet->getAutoFilter()->setRange($autoFilterRange);
1591 case '_xlnm.Print_Titles':
1593 $extractedRange = explode(
',', $extractedRange);
1596 foreach ($extractedRange as $range) {
1598 $range = str_replace(
'$',
'', $range);
1601 if (preg_match(
'/!?([A-Z]+)\:([A-Z]+)$/', $range, $matches)) {
1602 $docSheet->getPageSetup()->setColumnsToRepeatAtLeft(
array($matches[1], $matches[2]));
1605 elseif (preg_match(
'/!?(\d+)\:(\d+)$/', $range, $matches)) {
1606 $docSheet->getPageSetup()->setRowsToRepeatAtTop(
array($matches[1], $matches[2]));
1611 case '_xlnm.Print_Area':
1612 $rangeSets = explode(
',', $extractedRange);
1613 $newRangeSets =
array();
1614 foreach($rangeSets as $rangeSet) {
1615 $range = explode(
'!', $rangeSet);
1616 $rangeSet = isset($range[1]) ? $range[1] : $range[0];
1617 if (strpos($rangeSet,
':') === FALSE) {
1618 $rangeSet = $rangeSet .
':' . $rangeSet;
1620 $newRangeSets[] = str_replace(
'$',
'', $rangeSet);
1622 $docSheet->getPageSetup()->setPrintArea(implode(
',',$newRangeSets));
1637 if ($xmlWorkbook->definedNames) {
1638 foreach ($xmlWorkbook->definedNames->definedName as $definedName) {
1640 $extractedRange = (
string)$definedName;
1641 $extractedRange = preg_replace(
'/\'(\w+)\'\!/',
'', $extractedRange);
1642 if (($spos = strpos($extractedRange,
'!')) !==
false) {
1643 $extractedRange = substr($extractedRange,0,$spos).str_replace(
'$',
'', substr($extractedRange,$spos));
1645 $extractedRange = str_replace(
'$',
'', $extractedRange);
1649 if (stripos((
string)$definedName,
'#REF!') !==
false || $extractedRange ==
'') {
1654 if ((
string)$definedName[
'localSheetId'] !=
'') {
1657 switch ((
string)$definedName[
'name']) {
1659 case '_xlnm._FilterDatabase':
1660 case '_xlnm.Print_Titles':
1661 case '_xlnm.Print_Area':
1665 if ($mapSheetId[(integer) $definedName[
'localSheetId']] !== null) {
1666 $range = explode(
'!', (
string)$definedName);
1667 if (count($range) == 2) {
1668 $range[0] = str_replace(
"''",
"'", $range[0]);
1669 $range[0] = str_replace(
"'",
"", $range[0]);
1670 if (
$worksheet = $docSheet->getParent()->getSheetByName($range[0])) {
1671 $extractedRange = str_replace(
'$',
'', $range[1]);
1672 $scope = $docSheet->getParent()->getSheet($mapSheetId[(integer) $definedName[
'localSheetId']]);
1679 }
else if (!isset($definedName[
'localSheetId'])) {
1681 $locatedSheet = null;
1682 $extractedSheetName =
'';
1683 if (strpos( (
string)$definedName,
'!' ) !==
false) {
1686 $extractedSheetName = $extractedSheetName[0];
1689 $locatedSheet = $excel->getSheetByName($extractedSheetName);
1692 $range = explode(
'!', $extractedRange);
1693 $extractedRange = isset($range[1]) ? $range[1] : $range[0];
1696 if ($locatedSheet !== NULL) {
1697 $excel->addNamedRange(
new PHPExcel_NamedRange((
string)$definedName[
'name'], $locatedSheet, $extractedRange,
false) );
1704 if ((!$this->_readDataOnly) || (!empty($this->_loadSheetsOnly))) {
1706 $activeTab = intval($xmlWorkbook->bookViews->workbookView[
"activeTab"]);
1709 if (isset($mapSheetId[$activeTab]) && $mapSheetId[$activeTab] !== null) {
1710 $excel->setActiveSheetIndex($mapSheetId[$activeTab]);
1712 if ($excel->getSheetCount() == 0) {
1713 $excel->createSheet();
1715 $excel->setActiveSheetIndex(0);
1724 if (!$this->_readDataOnly) {
1726 foreach ($contentTypes->Override as $contentType) {
1727 switch ($contentType[
"ContentType"]) {
1728 case "application/vnd.openxmlformats-officedocument.drawingml.chart+xml":
1729 if ($this->_includeCharts) {
1730 $chartEntryRef = ltrim($contentType[
'PartName'],
'/');
1737 if (isset($charts[$chartEntryRef])) {
1738 $chartPositionRef = $charts[$chartEntryRef][
'sheet'].
'!'.$charts[$chartEntryRef][
'id'];
1740 if (isset($chartDetails[$chartPositionRef])) {
1743 $excel->getSheetByName($charts[$chartEntryRef][
'sheet'])->addChart($objChart);
1744 $objChart->setWorksheet($excel->getSheetByName($charts[$chartEntryRef][
'sheet']));
1745 $objChart->setTopLeftPosition( $chartDetails[$chartPositionRef][
'fromCoordinate'],
1746 $chartDetails[$chartPositionRef][
'fromOffsetX'],
1747 $chartDetails[$chartPositionRef][
'fromOffsetY']
1749 $objChart->setBottomRightPosition( $chartDetails[$chartPositionRef][
'toCoordinate'],
1750 $chartDetails[$chartPositionRef][
'toOffsetX'],
1751 $chartDetails[$chartPositionRef][
'toOffsetY']
static getZipClass()
Return the name of the Zip handler Class that PHPExcel is configured to use (PCLZip or ZipArchive) or...
const AUTOFILTER_COLUMN_RULE_TOPTEN_PERCENT
const AUTOFILTER_FILTERTYPE_TOPTENFILTER
const AUTOFILTER_RULETYPE_CUSTOMFILTER
const CONDITION_CONTAINSTEXT
const AUTOFILTER_COLUMN_RULE_TOPTEN_BOTTOM
static coordinateFromString($pCoordinateString='A1')
Coordinate from string.
const AUTOFILTER_FILTERTYPE_FILTER
static setExcelCalendar($baseDate)
Set the Excel calendar (Windows 1900 or Mac 1904)
const AUTOFILTER_RULETYPE_DATEGROUP
Add rich text string
The name of the decorator.
const AUTOFILTER_COLUMN_RULE_TOPTEN_BY_VALUE
const AUTOFILTER_FILTERTYPE_CUSTOMFILTER
_getFromZipArchive($archive, $fileName='')
securityScan($xml)
Scan theXML for use of <!ENTITY to prevent XXE/XEE attacks.
static readChart($chartElements, $chartName)
static convertProperty($propertyValue, $propertyType)
const AUTOFILTER_RULETYPE_TOPTENFILTER
const AUTOFILTER_COLUMN_RULE_TOPTEN_TOP
_castToFormula($c, $r, &$cellDataType, &$value, &$calculatedValue, &$sharedFormulas, $castBaseType)
static getLibXmlLoaderOptions()
Get default options for libxml loader.
const AUTOFILTER_COLUMN_JOIN_AND
Create styles array
The data for the language used.
const CONDITION_EXPRESSION
getReadFilter()
Read filter.
static extractAllCellReferencesInRange($pRange='A1')
Extract all cell references in range.
static realpath($pFilename)
Returns canonicalized absolute pathname, also for ZIP archives.
Create new PHPExcel object
obj_idprivate
static stringFromColumnIndex($pColumnIndex=0)
String from columnindex.
static EMUToPixels($pValue=0)
Convert EMU to pixels.
static boolean($value=NULL)
static extractSheetTitle($pRange, $returnRange=false)
Extract worksheet title from range.
const CALENDAR_WINDOWS_1900
constants
const AUTOFILTER_RULETYPE_DYNAMICFILTER
const AUTOFILTER_RULETYPE_FILTER
static convertPropertyType($propertyType)
static angleToDegrees($pValue=0)
Convert angle to degrees.
static ControlCharacterOOXML2PHP($value='')
Convert from OpenXML escaped control character to PHP control character.
const AUTOFILTER_FILTERTYPE_DYNAMICFILTER
_readRibbon($excel, $customUITarget, $zip)