30 if (!defined(
'PHPEXCEL_ROOT')) {
34 define(
'PHPEXCEL_ROOT', dirname(__FILE__) .
'/../../');
38 require_once PHPEXCEL_ROOT .
'PHPExcel.php';
41 require_once PHPEXCEL_ROOT .
'PHPExcel/Reader/IReader.php';
44 require_once PHPEXCEL_ROOT .
'PHPExcel/Worksheet.php';
47 require_once PHPEXCEL_ROOT .
'PHPExcel/Cell.php';
50 require_once PHPEXCEL_ROOT .
'PHPExcel/Style.php';
53 require_once PHPEXCEL_ROOT .
'PHPExcel/Style/Borders.php';
56 require_once PHPEXCEL_ROOT .
'PHPExcel/Style/Conditional.php';
59 require_once PHPEXCEL_ROOT .
'PHPExcel/Style/Protection.php';
62 require_once PHPEXCEL_ROOT .
'PHPExcel/Style/NumberFormat.php';
65 require_once PHPEXCEL_ROOT .
'PHPExcel/Worksheet/BaseDrawing.php';
68 require_once PHPEXCEL_ROOT .
'PHPExcel/Worksheet/Drawing.php';
71 require_once PHPEXCEL_ROOT .
'PHPExcel/Shared/Drawing.php';
74 require_once PHPEXCEL_ROOT .
'PHPExcel/Shared/Date.php';
77 require_once PHPEXCEL_ROOT .
'PHPExcel/Shared/File.php';
80 require_once PHPEXCEL_ROOT .
'PHPExcel/Shared/String.php';
83 require_once PHPEXCEL_ROOT .
'PHPExcel/ReferenceHelper.php';
86 require_once PHPEXCEL_ROOT .
'PHPExcel/Reader/IReadFilter.php';
89 require_once PHPEXCEL_ROOT .
'PHPExcel/Reader/DefaultReadFilter.php';
138 $this->_readDataOnly = $pValue;
160 $this->_loadSheetsOnly = is_array($value) ?
161 $value : array($value);
172 $this->_loadSheetsOnly = null;
192 $this->_readFilter = $pValue;
212 if (!file_exists($pFilename)) {
213 throw new Exception(
"Could not open " . $pFilename .
" for reading! File does not exist.");
217 $zip =
new ZipArchive;
218 if ($zip->open($pFilename) ===
true) {
220 $rels = simplexml_load_string($zip->getFromName(
"_rels/.rels"));
224 return ($rels !==
false);
233 $value = isset($c->v) ? (string) $c->v : null;
236 }
elseif ($value ==
'1') {
239 $value = (bool)$c->v;
246 return isset($c->v) ? (string) $c->v : null;;
251 return isset($c->v) ? (string) $c->v : null;;
254 private function _castToFormula($c,$r,&$cellDataType,&$value,&$calculatedValue,&$sharedFormulas,$castBaseType) {
259 $calculatedValue = $this->$castBaseType($c);
262 if (isset($c->f[
't']) && strtolower((
string)$c->f[
't']) ==
'shared') {
264 $instance = (string)$c->f[
'si'];
271 if (!isset($sharedFormulas[(
string)$c->f[
'si']])) {
275 $sharedFormulas[$instance] = array(
'master' => $r,
288 $difference = array(0, 0);
290 $difference[1] = $current[1] - $master[1];
293 $value = $helper->updateFormulaReferences( $sharedFormulas[$instance][
'formula'],
310 public function load($pFilename)
313 if (!file_exists($pFilename)) {
314 throw new Exception(
"Could not open " . $pFilename .
" for reading! File does not exist.");
320 if (!$this->_readDataOnly) {
321 $excel->removeCellStyleXfByIndex(0);
322 $excel->removeCellXfByIndex(0);
324 $zip =
new ZipArchive;
325 $zip->open($pFilename);
327 $rels = simplexml_load_string($zip->getFromName(
"_rels/.rels"));
328 foreach ($rels->Relationship as $rel) {
329 switch ($rel[
"Type"]) {
330 case "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties":
331 $xmlCore = simplexml_load_string($zip->getFromName(
"{$rel['Target']}"));
332 if ($xmlCore ===
false) {
333 $xmlCore = simplexml_load_string($zip->getFromName(substr(
"{$rel['Target']}", 1)));
336 $xmlCore->registerXPathNamespace(
"dc",
"http://purl.org/dc/elements/1.1/");
337 $xmlCore->registerXPathNamespace(
"dcterms",
"http://purl.org/dc/terms/");
338 $xmlCore->registerXPathNamespace(
"cp",
"http://schemas.openxmlformats.org/package/2006/metadata/core-properties");
339 $docProps = $excel->getProperties();
340 $docProps->setCreator((
string) self::array_item($xmlCore->xpath(
"dc:creator")));
341 $docProps->setLastModifiedBy((
string) self::array_item($xmlCore->xpath(
"cp:lastModifiedBy")));
342 $docProps->setCreated(strtotime(self::array_item($xmlCore->xpath(
"dcterms:created"))));
343 $docProps->setModified(strtotime(self::array_item($xmlCore->xpath(
"dcterms:modified"))));
344 $docProps->setTitle((
string) self::array_item($xmlCore->xpath(
"dc:title")));
345 $docProps->setDescription((
string) self::array_item($xmlCore->xpath(
"dc:description")));
346 $docProps->setSubject((
string) self::array_item($xmlCore->xpath(
"dc:subject")));
347 $docProps->setKeywords((
string) self::array_item($xmlCore->xpath(
"cp:keywords")));
348 $docProps->setCategory((
string) self::array_item($xmlCore->xpath(
"cp:category")));
352 case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument":
353 $dir = dirname($rel[
"Target"]);
354 $relsWorkbook = simplexml_load_string($zip->getFromName(
"$dir/_rels/" . basename($rel[
"Target"]) .
".rels"));
355 if ($relsWorkbook ===
false) {
356 $relsWorkbook = simplexml_load_string($zip->getFromName(substr(
"$dir/_rels/" . basename($rel[
"Target"]) .
".rels", 1)));
358 $relsWorkbook->registerXPathNamespace(
"rel",
"http://schemas.openxmlformats.org/package/2006/relationships");
360 $sharedStrings = array();
361 $xpath =
self::array_item($relsWorkbook->xpath(
"rel:Relationship[@Type='http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings']"));
362 $xmlStrings = simplexml_load_string($zip->getFromName(
"$dir/$xpath[Target]"));
363 if (isset($xmlStrings) && isset($xmlStrings->si)) {
364 foreach ($xmlStrings->si as $val) {
365 if (isset($val->t)) {
367 }
elseif (isset($val->r)) {
373 $worksheets = array();
374 foreach ($relsWorkbook->Relationship as $ele) {
375 if ($ele[
"Type"] ==
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet") {
376 $worksheets[(string) $ele[
"Id"]] = $ele[
"Target"];
381 $cellStyles = array();
382 $xpath =
self::array_item($relsWorkbook->xpath(
"rel:Relationship[@Type='http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles']"));
383 $xmlStyles = simplexml_load_string($zip->getFromName(
"$dir/$xpath[Target]"));
385 if ($xmlStyles && $xmlStyles->numFmts[0]) {
386 $numFmts = $xmlStyles->numFmts[0];
388 if (isset($numFmts) && !is_null($numFmts)) {
389 $numFmts->registerXPathNamespace(
"sml",
"http://schemas.openxmlformats.org/spreadsheetml/2006/main");
391 if (!$this->_readDataOnly && $xmlStyles) {
392 foreach ($xmlStyles->cellXfs->xf as $xf) {
395 if ($xf[
"numFmtId"]) {
396 if (isset($numFmts)) {
397 $tmpNumFmt =
self::array_item($numFmts->xpath(
"sml:numFmt[@numFmtId=$xf[numFmtId]]"));
399 if (isset($tmpNumFmt[
"formatCode"])) {
400 $numFmt = (string) $tmpNumFmt[
"formatCode"];
404 if ((
int)$xf[
"numFmtId"] < 164) {
411 $style = (object) array(
413 "font" => $xmlStyles->fonts->font[intval($xf[
"fontId"])],
414 "fill" => $xmlStyles->fills->fill[intval($xf[
"fillId"])],
415 "border" => $xmlStyles->borders->border[intval($xf[
"borderId"])],
416 "alignment" => $xf->alignment,
417 "protection" => $xf->protection,
418 "applyAlignment" => (isset($xf[
"applyAlignment"]) && ((string)$xf[
"applyAlignment"] ==
'true' || (
string)$xf[
"applyAlignment"] ==
'1')),
419 "applyBorder" => (isset($xf[
"applyBorder"]) && ((string)$xf[
"applyBorder"] ==
'true' || (
string)$xf[
"applyBorder"] ==
'1')),
420 "applyFill" => (isset($xf[
"applyFill"]) && ((string)$xf[
"applyFill"] ==
'true' || (
string)$xf[
"applyFill"] ==
'1')),
421 "applyFont" => (isset($xf[
"applyFont"]) && ((string)$xf[
"applyFont"] ==
'true' || (
string)$xf[
"applyFont"] ==
'1')),
422 "applyNumberFormat" => (isset($xf[
"applyNumberFormat"]) && ((string)$xf[
"applyNumberFormat"] ==
'true' || (
string)$xf[
"applyNumberFormat"] ==
'1')),
423 "applyProtection" => (isset($xf[
"applyProtection"]) && ((string)$xf[
"applyProtection"] ==
'true' || (
string)$xf[
"applyProtection"] ==
'1'))
430 $excel->addCellXf($objStyle);
433 foreach ($xmlStyles->cellStyleXfs->xf as $xf) {
435 if ($numFmts && $xf[
"numFmtId"]) {
436 $tmpNumFmt =
self::array_item($numFmts->xpath(
"sml:numFmt[@numFmtId=$xf[numFmtId]]"));
437 if (isset($tmpNumFmt[
"formatCode"])) {
438 $numFmt = (string) $tmpNumFmt[
"formatCode"];
439 }
else if ((
int)$xf[
"numFmtId"] < 165) {
444 $cellStyle = (object) array(
446 "font" => $xmlStyles->fonts->font[intval($xf[
"fontId"])],
447 "fill" => $xmlStyles->fills->fill[intval($xf[
"fillId"])],
448 "border" => $xmlStyles->borders->border[intval($xf[
"borderId"])],
449 "alignment" => $xf->alignment,
450 "protection" => $xf->protection,
451 "applyAlignment" =>
true,
452 "applyBorder" =>
true,
455 "applyNumberFormat" =>
true,
456 "applyProtection" => true
458 $cellStyles[] = $cellStyle;
463 $excel->addCellStyleXf($objStyle);
468 if (!$this->_readDataOnly && $xmlStyles) {
469 foreach ($xmlStyles->dxfs->dxf as $dxf) {
475 foreach ($xmlStyles->cellStyles->cellStyle as $cellStyle) {
476 if (intval($cellStyle[
'builtinId']) == 0) {
477 if (isset($cellStyles[intval($cellStyle[
'xfId'])])) {
480 $this->
_readStyle($style, $cellStyles[intval($cellStyle[
'xfId'])]);
488 $xmlWorkbook = simplexml_load_string($zip->getFromName(
"{$rel['Target']}"));
489 if ($xmlWorkbook ===
false) {
490 $xmlWorkbook = simplexml_load_string($zip->getFromName(substr(
"{$rel['Target']}", 1)));
493 if ($xmlWorkbook->workbookPr) {
495 if (isset($xmlWorkbook->workbookPr[
'date1904'])) {
496 $date1904 = (string)$xmlWorkbook->workbookPr[
'date1904'];
497 if ($date1904 ==
"true" || $date1904 ==
"1") {
505 $countSkippedSheets = 0;
506 $mapSheetId = array();
508 foreach ($xmlWorkbook->sheets->sheet as $eleSheet) {
512 if (isset($this->_loadSheetsOnly) && !in_array((
string) $eleSheet[
"name"], $this->_loadSheetsOnly)) {
513 ++$countSkippedSheets;
514 $mapSheetId[$oldSheetId] = null;
520 $mapSheetId[$oldSheetId] = $oldSheetId - $countSkippedSheets;
523 $docSheet = $excel->createSheet();
524 $docSheet->setTitle((
string) $eleSheet[
"name"]);
525 $fileWorksheet = $worksheets[(string) self::array_item($eleSheet->attributes(
"http://schemas.openxmlformats.org/officeDocument/2006/relationships"),
"id")];
526 $xmlSheet = simplexml_load_string($zip->getFromName(
"$dir/$fileWorksheet"));
528 $sharedFormulas = array();
530 if (isset($xmlSheet->sheetViews) && isset($xmlSheet->sheetViews->sheetView)) {
531 if (isset($xmlSheet->sheetViews->sheetView[
'zoomScale'])) {
532 $docSheet->getSheetView()->setZoomScale( intval($xmlSheet->sheetViews->sheetView[
'zoomScale']) );
535 if (isset($xmlSheet->sheetViews->sheetView[
'zoomScaleNormal'])) {
536 $docSheet->getSheetView()->setZoomScaleNormal( intval($xmlSheet->sheetViews->sheetView[
'zoomScaleNormal']) );
539 if (isset($xmlSheet->sheetViews->sheetView[
'showGridLines'])) {
540 $docSheet->setShowGridLines((
string)$xmlSheet->sheetViews->sheetView[
'showGridLines'] ?
true :
false);
543 if (isset($xmlSheet->sheetViews->sheetView[
'rightToLeft'])) {
544 $docSheet->setRightToLeft((
string)$xmlSheet->sheetViews->sheetView[
'rightToLeft'] ?
true :
false);
547 if (isset($xmlSheet->sheetViews->sheetView->pane)) {
548 if (isset($xmlSheet->sheetViews->sheetView->pane[
'topLeftCell'])) {
549 $docSheet->freezePane( (
string)$xmlSheet->sheetViews->sheetView->pane[
'topLeftCell'] );
554 if (isset($xmlSheet->sheetViews->sheetView->pane[
'xSplit'])) {
555 $xSplit = 1 + intval($xmlSheet->sheetViews->sheetView->pane[
'xSplit']);
558 if (isset($xmlSheet->sheetViews->sheetView->pane[
'ySplit'])) {
559 $ySplit = 1 + intval($xmlSheet->sheetViews->sheetView->pane[
'ySplit']);
562 $docSheet->freezePaneByColumnAndRow($xSplit, $ySplit);
567 if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr->outlinePr)) {
568 if (isset($xmlSheet->sheetPr->outlinePr[
'summaryRight']) && $xmlSheet->sheetPr->outlinePr[
'summaryRight'] ==
false) {
569 $docSheet->setShowSummaryRight(
false);
571 $docSheet->setShowSummaryRight(
true);
574 if (isset($xmlSheet->sheetPr->outlinePr[
'summaryBelow']) && $xmlSheet->sheetPr->outlinePr[
'summaryBelow'] ==
false) {
575 $docSheet->setShowSummaryBelow(
false);
577 $docSheet->setShowSummaryBelow(
true);
581 if (isset($xmlSheet->sheetFormatPr)) {
582 if (isset($xmlSheet->sheetFormatPr[
'customHeight']) && ((
string)$xmlSheet->sheetFormatPr[
'customHeight'] ==
'1' || strtolower((
string)$xmlSheet->sheetFormatPr[
'customHeight']) ==
'true') && isset($xmlSheet->sheetFormatPr[
'defaultRowHeight'])) {
583 $docSheet->getDefaultRowDimension()->setRowHeight( (
float)$xmlSheet->sheetFormatPr[
'defaultRowHeight'] );
585 if (isset($xmlSheet->sheetFormatPr[
'defaultColWidth'])) {
586 $docSheet->getDefaultColumnDimension()->setWidth( (
float)$xmlSheet->sheetFormatPr[
'defaultColWidth'] );
590 if (isset($xmlSheet->cols) && !$this->_readDataOnly) {
591 foreach ($xmlSheet->cols->col as $col) {
592 for ($i = intval($col[
"min"]) - 1; $i < intval($col[
"max"]); ++$i) {
593 if ($col[
"bestFit"]) {
596 if ($col[
"hidden"]) {
599 if ($col[
"collapsed"]) {
602 if ($col[
"outlineLevel"] > 0) {
607 if (intval($col[
"max"]) == 16384) {
614 if (isset($xmlSheet->printOptions) && !$this->_readDataOnly) {
615 if ($xmlSheet->printOptions[
'gridLinesSet'] ==
'true' && $xmlSheet->printOptions[
'gridLinesSet'] ==
'1') {
616 $docSheet->setShowGridlines(
true);
619 if ($xmlSheet->printOptions[
'gridLines'] ==
'true' || $xmlSheet->printOptions[
'gridLines'] ==
'1') {
620 $docSheet->setPrintGridlines(
true);
623 if ($xmlSheet->printOptions[
'horizontalCentered']) {
624 $docSheet->getPageSetup()->setHorizontalCentered(
true);
626 if ($xmlSheet->printOptions[
'verticalCentered']) {
627 $docSheet->getPageSetup()->setVerticalCentered(
true);
631 if ($xmlSheet && $xmlSheet->sheetData && $xmlSheet->sheetData->row) {
632 foreach ($xmlSheet->sheetData->row as
$row) {
633 if ($row[
"ht"] && !$this->_readDataOnly) {
634 $docSheet->getRowDimension(intval($row[
"r"]))->setRowHeight(floatval($row[
"ht"]));
636 if ($row[
"hidden"] && !$this->_readDataOnly) {
637 $docSheet->getRowDimension(intval($row[
"r"]))->setVisible(
false);
639 if ($row[
"collapsed"]) {
640 $docSheet->getRowDimension(intval($row[
"r"]))->setCollapsed(
true);
642 if ($row[
"outlineLevel"] > 0) {
643 $docSheet->getRowDimension(intval($row[
"r"]))->setOutlineLevel(intval($row[
"outlineLevel"]));
646 foreach ($row->c as $c) {
647 $r = (string) $c[
"r"];
648 $cellDataType = (string) $c[
"t"];
650 $calculatedValue = null;
656 if (!$this->
getReadFilter()->readCell($coordinates[0], $coordinates[1], $docSheet->getTitle())) {
667 switch ($cellDataType) {
670 if ((
string)$c->v !=
'') {
671 $value = $sharedStrings[intval($c->v)];
674 $value = clone $value;
687 $this->
_castToFormula($c,$r,$cellDataType,$value,$calculatedValue,$sharedFormulas,
'_castToBool');
702 $this->
_castToFormula($c,$r,$cellDataType,$value,$calculatedValue,$sharedFormulas,
'_castToError');
716 $this->
_castToFormula($c,$r,$cellDataType,$value,$calculatedValue,$sharedFormulas,
'_castToString');
725 if (is_numeric($value) && $cellDataType !=
's') {
726 if ($value == (
int)$value) $value = (int)$value;
727 elseif ($value == (
float)$value) $value = (float)$value;
728 elseif ($value == (
double)$value) $value = (double)$value;
733 $value = $value->getPlainText();
737 if ($cellDataType !=
'') {
738 $docSheet->setCellValueExplicit($r, $value, $cellDataType);
740 $docSheet->setCellValue($r, $value);
742 if (!is_null($calculatedValue)) {
743 $docSheet->getCell($r)->setCalculatedValue($calculatedValue);
747 if ($c[
"s"] && !$this->_readDataOnly) {
749 $docSheet->getCell($r)->setXfIndex(isset($styles[intval($c[
"s"])]) ?
750 intval($c[
"s"]) : 0);
755 $value->setParent($docSheet->getCell($r));
761 $conditionals = array();
762 if (!$this->_readDataOnly && $xmlSheet && $xmlSheet->conditionalFormatting) {
763 foreach ($xmlSheet->conditionalFormatting as $conditional) {
764 foreach ($conditional->cfRule as $cfRule) {
770 ) && isset($dxfs[intval($cfRule[
"dxfId"])])
772 $conditionals[(string) $conditional[
"sqref"]][intval($cfRule[
"priority"])] = $cfRule;
777 foreach ($conditionals as $ref => $cfRules) {
779 $conditionalStyles = array();
780 foreach ($cfRules as $cfRule) {
782 $objConditional->setConditionType((
string)$cfRule[
"type"]);
783 $objConditional->setOperatorType((
string)$cfRule[
"operator"]);
785 if ((
string)$cfRule[
"text"] !=
'') {
786 $objConditional->setText((
string)$cfRule[
"text"]);
789 if (count($cfRule->formula) > 1) {
790 foreach ($cfRule->formula as $formula) {
791 $objConditional->addCondition((
string)$formula);
794 $objConditional->addCondition((
string)$cfRule->formula);
796 $objConditional->setStyle(clone $dxfs[intval($cfRule[
"dxfId"])]);
797 $conditionalStyles[] = $objConditional;
802 foreach ($aReferences as $reference) {
803 $docSheet->getStyle($reference)->setConditionalStyles($conditionalStyles);
808 $aKeys = array(
"sheet",
"objects",
"scenarios",
"formatCells",
"formatColumns",
"formatRows",
"insertColumns",
"insertRows",
"insertHyperlinks",
"deleteColumns",
"deleteRows",
"selectLockedCells",
"sort",
"autoFilter",
"pivotTables",
"selectUnlockedCells");
809 if (!$this->_readDataOnly && $xmlSheet && $xmlSheet->sheetProtection) {
810 foreach ($aKeys as
$key) {
811 $method =
"set" . ucfirst($key);
812 $docSheet->getProtection()->$method($xmlSheet->sheetProtection[$key] ==
"true");
816 if (!$this->_readDataOnly && $xmlSheet && $xmlSheet->sheetProtection) {
817 $docSheet->getProtection()->setPassword((
string) $xmlSheet->sheetProtection[
"password"],
true);
818 if ($xmlSheet->protectedRanges->protectedRange) {
819 foreach ($xmlSheet->protectedRanges->protectedRange as $protectedRange) {
820 $docSheet->protectCells((
string) $protectedRange[
"sqref"], (
string) $protectedRange[
"password"],
true);
825 if ($xmlSheet && $xmlSheet->autoFilter && !$this->_readDataOnly) {
826 $docSheet->setAutoFilter((
string) $xmlSheet->autoFilter[
"ref"]);
829 if ($xmlSheet && $xmlSheet->mergeCells && $xmlSheet->mergeCells->mergeCell && !$this->_readDataOnly) {
830 foreach ($xmlSheet->mergeCells->mergeCell as $mergeCell) {
831 $docSheet->mergeCells((
string) $mergeCell[
"ref"]);
835 if ($xmlSheet && $xmlSheet->pageMargins && !$this->_readDataOnly) {
836 $docPageMargins = $docSheet->getPageMargins();
837 $docPageMargins->setLeft(floatval($xmlSheet->pageMargins[
"left"]));
838 $docPageMargins->setRight(floatval($xmlSheet->pageMargins[
"right"]));
839 $docPageMargins->setTop(floatval($xmlSheet->pageMargins[
"top"]));
840 $docPageMargins->setBottom(floatval($xmlSheet->pageMargins[
"bottom"]));
841 $docPageMargins->setHeader(floatval($xmlSheet->pageMargins[
"header"]));
842 $docPageMargins->setFooter(floatval($xmlSheet->pageMargins[
"footer"]));
845 if ($xmlSheet && $xmlSheet->pageSetup && !$this->_readDataOnly) {
846 $docPageSetup = $docSheet->getPageSetup();
848 if (isset($xmlSheet->pageSetup[
"orientation"])) {
849 $docPageSetup->setOrientation((
string) $xmlSheet->pageSetup[
"orientation"]);
851 if (isset($xmlSheet->pageSetup[
"paperSize"])) {
852 $docPageSetup->setPaperSize(intval($xmlSheet->pageSetup[
"paperSize"]));
854 if (isset($xmlSheet->pageSetup[
"scale"])) {
855 $docPageSetup->setScale(intval($xmlSheet->pageSetup[
"scale"]));
857 if (isset($xmlSheet->pageSetup[
"fitToHeight"]) && intval($xmlSheet->pageSetup[
"fitToHeight"]) > 0) {
858 $docPageSetup->setFitToHeight(intval($xmlSheet->pageSetup[
"fitToHeight"]));
860 if (isset($xmlSheet->pageSetup[
"fitToWidth"]) && intval($xmlSheet->pageSetup[
"fitToWidth"]) > 0) {
861 $docPageSetup->setFitToWidth(intval($xmlSheet->pageSetup[
"fitToWidth"]));
865 if ($xmlSheet && $xmlSheet->headerFooter && !$this->_readDataOnly) {
866 $docHeaderFooter = $docSheet->getHeaderFooter();
868 if (isset($xmlSheet->headerFooter[
"differentOddEven"]) &&
869 ((
string)$xmlSheet->headerFooter[
"differentOddEven"] ==
'true' || (
string)$xmlSheet->headerFooter[
"differentOddEven"] ==
'1')) {
870 $docHeaderFooter->setDifferentOddEven(
true);
872 $docHeaderFooter->setDifferentOddEven(
false);
874 if (isset($xmlSheet->headerFooter[
"differentFirst"]) &&
875 ((
string)$xmlSheet->headerFooter[
"differentFirst"] ==
'true' || (
string)$xmlSheet->headerFooter[
"differentFirst"] ==
'1')) {
876 $docHeaderFooter->setDifferentFirst(
true);
878 $docHeaderFooter->setDifferentFirst(
false);
880 if (isset($xmlSheet->headerFooter[
"scaleWithDoc"]) &&
881 ((
string)$xmlSheet->headerFooter[
"scaleWithDoc"] ==
'false' || (
string)$xmlSheet->headerFooter[
"scaleWithDoc"] ==
'0')) {
882 $docHeaderFooter->setScaleWithDocument(
false);
884 $docHeaderFooter->setScaleWithDocument(
true);
886 if (isset($xmlSheet->headerFooter[
"alignWithMargins"]) &&
887 ((
string)$xmlSheet->headerFooter[
"alignWithMargins"] ==
'false' || (
string)$xmlSheet->headerFooter[
"alignWithMargins"] ==
'0')) {
888 $docHeaderFooter->setAlignWithMargins(
false);
890 $docHeaderFooter->setAlignWithMargins(
true);
893 $docHeaderFooter->setOddHeader((
string) $xmlSheet->headerFooter->oddHeader);
894 $docHeaderFooter->setOddFooter((
string) $xmlSheet->headerFooter->oddFooter);
895 $docHeaderFooter->setEvenHeader((
string) $xmlSheet->headerFooter->evenHeader);
896 $docHeaderFooter->setEvenFooter((
string) $xmlSheet->headerFooter->evenFooter);
897 $docHeaderFooter->setFirstHeader((
string) $xmlSheet->headerFooter->firstHeader);
898 $docHeaderFooter->setFirstFooter((
string) $xmlSheet->headerFooter->firstFooter);
901 if ($xmlSheet && $xmlSheet->rowBreaks && $xmlSheet->rowBreaks->brk && !$this->_readDataOnly) {
902 foreach ($xmlSheet->rowBreaks->brk as $brk) {
908 if ($xmlSheet && $xmlSheet->colBreaks && $xmlSheet->colBreaks->brk && !$this->_readDataOnly) {
909 foreach ($xmlSheet->colBreaks->brk as $brk) {
916 if ($xmlSheet && $xmlSheet->dataValidations && !$this->_readDataOnly) {
917 foreach ($xmlSheet->dataValidations->dataValidation as $dataValidation) {
919 $range = strtoupper($dataValidation[
"sqref"]);
923 foreach ($aReferences as $reference) {
925 $docValidation = $docSheet->getCell($reference)->getDataValidation();
926 $docValidation->setType((
string) $dataValidation[
"type"]);
927 $docValidation->setErrorStyle((
string) $dataValidation[
"errorStyle"]);
928 $docValidation->setOperator((
string) $dataValidation[
"operator"]);
929 $docValidation->setAllowBlank($dataValidation[
"allowBlank"] != 0);
930 $docValidation->setShowDropDown($dataValidation[
"showDropDown"] == 0);
931 $docValidation->setShowInputMessage($dataValidation[
"showInputMessage"] != 0);
932 $docValidation->setShowErrorMessage($dataValidation[
"showErrorMessage"] != 0);
933 $docValidation->setErrorTitle((
string) $dataValidation[
"errorTitle"]);
934 $docValidation->setError((
string) $dataValidation[
"error"]);
935 $docValidation->setPromptTitle((
string) $dataValidation[
"promptTitle"]);
936 $docValidation->setPrompt((
string) $dataValidation[
"prompt"]);
937 $docValidation->setFormula1((
string) $dataValidation->formula1);
938 $docValidation->setFormula2((
string) $dataValidation->formula2);
944 $hyperlinks = array();
945 if (!$this->_readDataOnly) {
947 if ($zip->locateName(dirname(
"$dir/$fileWorksheet") .
"/_rels/" . basename($fileWorksheet) .
".rels")) {
948 $relsWorksheet = simplexml_load_string($zip->getFromName( dirname(
"$dir/$fileWorksheet") .
"/_rels/" . basename($fileWorksheet) .
".rels") );
949 foreach ($relsWorksheet->Relationship as $ele) {
950 if ($ele[
"Type"] ==
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink") {
951 $hyperlinks[(string)$ele[
"Id"]] = (
string)$ele[
"Target"];
957 if ($xmlSheet && $xmlSheet->hyperlinks) {
958 foreach ($xmlSheet->hyperlinks->hyperlink as $hyperlink) {
960 $linkRel = $hyperlink->attributes(
'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
963 if (isset($linkRel[
'id'])) {
964 $docSheet->getCell( $cellReference )->getHyperlink()->setUrl( $hyperlinks[ (
string)$linkRel[
'id'] ] );
966 if (isset($hyperlink[
'location'])) {
967 $docSheet->getCell( $cellReference )->getHyperlink()->setUrl(
'sheet://' . (
string)$hyperlink[
'location'] );
971 if (isset($hyperlink[
'tooltip'])) {
972 $docSheet->getCell( $cellReference )->getHyperlink()->setTooltip( (
string)$hyperlink[
'tooltip'] );
981 $vmlComments = array();
982 if (!$this->_readDataOnly) {
984 if ($zip->locateName(dirname(
"$dir/$fileWorksheet") .
"/_rels/" . basename($fileWorksheet) .
".rels")) {
985 $relsWorksheet = simplexml_load_string($zip->getFromName( dirname(
"$dir/$fileWorksheet") .
"/_rels/" . basename($fileWorksheet) .
".rels") );
986 foreach ($relsWorksheet->Relationship as $ele) {
987 if ($ele[
"Type"] ==
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments") {
988 $comments[(string)$ele[
"Id"]] = (
string)$ele[
"Target"];
990 if ($ele[
"Type"] ==
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing") {
991 $vmlComments[(string)$ele[
"Id"]] = (
string)$ele[
"Target"];
997 foreach ($comments as $relName => $relPath) {
1000 $commentsFile = simplexml_load_string($zip->getFromName($relPath) );
1006 foreach ($commentsFile->authors->author as $author) {
1007 $authors[] = (string)$author;
1011 foreach ($commentsFile->commentList->comment as
$comment) {
1012 $docSheet->getComment( (
string)$comment[
'ref'] )->setAuthor( $authors[(
string)$comment[
'authorId']] );
1013 $docSheet->getComment( (
string)$comment[
'ref'] )->setText( $this->
_parseRichText($comment->text) );
1018 foreach ($vmlComments as $relName => $relPath) {
1021 $vmlCommentsFile = simplexml_load_string( $zip->getFromName($relPath) );
1022 $vmlCommentsFile->registerXPathNamespace(
'v',
'urn:schemas-microsoft-com:vml');
1024 $shapes = $vmlCommentsFile->xpath(
'//v:shape');
1025 foreach ($shapes as $shape) {
1026 $shape->registerXPathNamespace(
'v',
'urn:schemas-microsoft-com:vml');
1028 if (isset($shape[
'style'])) {
1029 $style = (string)$shape[
'style'];
1030 $fillColor = strtoupper( substr( (
string)$shape[
'fillcolor'], 1 ) );
1034 $clientData = $shape->xpath(
'.//x:ClientData');
1035 if (is_array($clientData)) {
1036 $clientData = $clientData[0];
1038 if ( isset($clientData[
'ObjectType']) && (
string)$clientData[
'ObjectType'] ==
'Note' ) {
1039 $temp = $clientData->xpath(
'.//x:Row');
1040 if (is_array($temp))
$row = $temp[0];
1042 $temp = $clientData->xpath(
'.//x:Column');
1043 if (is_array($temp)) $column = $temp[0];
1047 if (!is_null($column) && !is_null(
$row)) {
1049 $comment = $docSheet->getCommentByColumnAndRow($column,
$row + 1);
1050 $comment->getFillColor()->setRGB( $fillColor );
1053 $styleArray = explode(
';', str_replace(
' ',
'', $style));
1054 foreach ($styleArray as $stylePair) {
1055 $stylePair = explode(
':', $stylePair);
1057 if ($stylePair[0] ==
'margin-left')
$comment->setMarginLeft($stylePair[1]);
1058 if ($stylePair[0] ==
'margin-top')
$comment->setMarginTop($stylePair[1]);
1059 if ($stylePair[0] ==
'width')
$comment->setWidth($stylePair[1]);
1060 if ($stylePair[0] ==
'height')
$comment->setHeight($stylePair[1]);
1061 if ($stylePair[0] ==
'visibility')
$comment->setVisible( $stylePair[1] ==
'visible' );
1070 if ($xmlSheet && $xmlSheet->legacyDrawingHF && !$this->_readDataOnly) {
1071 if ($zip->locateName(dirname(
"$dir/$fileWorksheet") .
"/_rels/" . basename($fileWorksheet) .
".rels")) {
1072 $relsWorksheet = simplexml_load_string($zip->getFromName( dirname(
"$dir/$fileWorksheet") .
"/_rels/" . basename($fileWorksheet) .
".rels") );
1073 $vmlRelationship =
'';
1075 foreach ($relsWorksheet->Relationship as $ele) {
1076 if ($ele[
"Type"] ==
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing") {
1077 $vmlRelationship =
self::dir_add(
"$dir/$fileWorksheet", $ele[
"Target"]);
1081 if ($vmlRelationship !=
'') {
1083 $relsVML = simplexml_load_string($zip->getFromName( dirname($vmlRelationship) .
'/_rels/' . basename($vmlRelationship) .
'.rels' ));
1084 $drawings = array();
1085 foreach ($relsVML->Relationship as $ele) {
1086 if ($ele[
"Type"] ==
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image") {
1087 $drawings[(string) $ele[
"Id"]] = self::dir_add($vmlRelationship, $ele[
"Target"]);
1092 $vmlDrawing = simplexml_load_string($zip->getFromName($vmlRelationship));
1093 $vmlDrawing->registerXPathNamespace(
'v',
'urn:schemas-microsoft-com:vml');
1095 $hfImages = array();
1097 $shapes = $vmlDrawing->xpath(
'//v:shape');
1098 foreach ($shapes as $shape) {
1099 $shape->registerXPathNamespace(
'v',
'urn:schemas-microsoft-com:vml');
1100 $imageData = $shape->xpath(
'//v:imagedata');
1101 $imageData = $imageData[0];
1103 $imageData = $imageData->attributes(
'urn:schemas-microsoft-com:office:office');
1107 if (isset($imageData[
'title'])) {
1108 $hfImages[ (string)$shape[
'id'] ]->setName( (
string)$imageData[
'title'] );
1111 $hfImages[ (string)$shape[
'id'] ]->setPath(
"zip://$pFilename#" . $drawings[(
string)$imageData[
'relid']],
false);
1112 $hfImages[ (string)$shape[
'id'] ]->setResizeProportional(
false);
1113 $hfImages[ (string)$shape[
'id'] ]->setWidth($style[
'width']);
1114 $hfImages[ (string)$shape[
'id'] ]->setHeight($style[
'height']);
1115 $hfImages[ (string)$shape[
'id'] ]->setOffsetX($style[
'margin-left']);
1116 $hfImages[ (string)$shape[
'id'] ]->setOffsetY($style[
'margin-top']);
1117 $hfImages[ (string)$shape[
'id'] ]->setResizeProportional(
true);
1120 $docSheet->getHeaderFooter()->setImages($hfImages);
1128 if ($zip->locateName(dirname(
"$dir/$fileWorksheet") .
"/_rels/" . basename($fileWorksheet) .
".rels")) {
1129 $relsWorksheet = simplexml_load_string($zip->getFromName( dirname(
"$dir/$fileWorksheet") .
"/_rels/" . basename($fileWorksheet) .
".rels") );
1130 $drawings = array();
1131 foreach ($relsWorksheet->Relationship as $ele) {
1132 if ($ele[
"Type"] ==
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing") {
1133 $drawings[(string) $ele[
"Id"]] = self::dir_add(
"$dir/$fileWorksheet", $ele[
"Target"]);
1136 if ($xmlSheet->drawing && !$this->_readDataOnly) {
1137 foreach ($xmlSheet->drawing as $drawing) {
1138 $fileDrawing = $drawings[(string) self::array_item($drawing->attributes(
"http://schemas.openxmlformats.org/officeDocument/2006/relationships"),
"id")];
1139 $relsDrawing = simplexml_load_string($zip->getFromName( dirname($fileDrawing) .
"/_rels/" . basename($fileDrawing) .
".rels") );
1142 if ($relsDrawing && $relsDrawing->Relationship) {
1143 foreach ($relsDrawing->Relationship as $ele) {
1144 if ($ele[
"Type"] ==
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image") {
1145 $images[(string) $ele[
"Id"]] = self::dir_add($fileDrawing, $ele[
"Target"]);
1149 $xmlDrawing = simplexml_load_string($zip->getFromName($fileDrawing))->children(
"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing");
1151 if ($xmlDrawing->oneCellAnchor) {
1152 foreach ($xmlDrawing->oneCellAnchor as $oneCellAnchor) {
1153 if ($oneCellAnchor->pic->blipFill) {
1154 $blip = $oneCellAnchor->pic->blipFill->children(
"http://schemas.openxmlformats.org/drawingml/2006/main")->blip;
1155 $xfrm = $oneCellAnchor->pic->spPr->children(
"http://schemas.openxmlformats.org/drawingml/2006/main")->xfrm;
1156 $outerShdw = $oneCellAnchor->pic->spPr->children(
"http://schemas.openxmlformats.org/drawingml/2006/main")->effectLst->outerShdw;
1158 $objDrawing->
setName((
string) self::array_item($oneCellAnchor->pic->nvPicPr->cNvPr->attributes(),
"name"));
1159 $objDrawing->setDescription((
string) self::array_item($oneCellAnchor->pic->nvPicPr->cNvPr->attributes(),
"descr"));
1160 $objDrawing->setPath(
"zip://$pFilename#" . $images[(
string) self::array_item($blip->attributes(
"http://schemas.openxmlformats.org/officeDocument/2006/relationships"),
"embed")],
false);
1164 $objDrawing->setResizeProportional(
false);
1171 $shadow = $objDrawing->getShadow();
1172 $shadow->setVisible(
true);
1173 $shadow->setBlurRadius(PHPExcel_Shared_Drawing::EMUTopixels(self::array_item($outerShdw->attributes(),
"blurRad")));
1174 $shadow->setDistance(PHPExcel_Shared_Drawing::EMUTopixels(self::array_item($outerShdw->attributes(),
"dist")));
1176 $shadow->setAlignment((
string) self::array_item($outerShdw->attributes(),
"algn"));
1177 $shadow->getColor()->setRGB(self::array_item($outerShdw->srgbClr->attributes(),
"val"));
1178 $shadow->setAlpha(self::array_item($outerShdw->srgbClr->alpha->attributes(),
"val") / 1000);
1180 $objDrawing->setWorksheet($docSheet);
1184 if ($xmlDrawing->twoCellAnchor) {
1185 foreach ($xmlDrawing->twoCellAnchor as $twoCellAnchor) {
1186 if ($twoCellAnchor->pic->blipFill) {
1187 $blip = $twoCellAnchor->pic->blipFill->children(
"http://schemas.openxmlformats.org/drawingml/2006/main")->blip;
1188 $xfrm = $twoCellAnchor->pic->spPr->children(
"http://schemas.openxmlformats.org/drawingml/2006/main")->xfrm;
1189 $outerShdw = $twoCellAnchor->pic->spPr->children(
"http://schemas.openxmlformats.org/drawingml/2006/main")->effectLst->outerShdw;
1191 $objDrawing->
setName((
string) self::array_item($twoCellAnchor->pic->nvPicPr->cNvPr->attributes(),
"name"));
1192 $objDrawing->setDescription((
string) self::array_item($twoCellAnchor->pic->nvPicPr->cNvPr->attributes(),
"descr"));
1193 $objDrawing->setPath(
"zip://$pFilename#" . $images[(
string) self::array_item($blip->attributes(
"http://schemas.openxmlformats.org/officeDocument/2006/relationships"),
"embed")],
false);
1197 $objDrawing->setResizeProportional(
false);
1206 $shadow = $objDrawing->getShadow();
1207 $shadow->setVisible(
true);
1208 $shadow->setBlurRadius(PHPExcel_Shared_Drawing::EMUTopixels(self::array_item($outerShdw->attributes(),
"blurRad")));
1209 $shadow->setDistance(PHPExcel_Shared_Drawing::EMUTopixels(self::array_item($outerShdw->attributes(),
"dist")));
1211 $shadow->setAlignment((
string) self::array_item($outerShdw->attributes(),
"algn"));
1212 $shadow->getColor()->setRGB(self::array_item($outerShdw->srgbClr->attributes(),
"val"));
1213 $shadow->setAlpha(self::array_item($outerShdw->srgbClr->alpha->attributes(),
"val") / 1000);
1215 $objDrawing->setWorksheet($docSheet);
1225 if ($xmlWorkbook->definedNames) {
1226 foreach ($xmlWorkbook->definedNames->definedName as $definedName) {
1228 $extractedRange = (string)$definedName;
1229 $extractedRange = preg_replace(
'/\'(\w+)\'\!/',
'', $extractedRange);
1230 $extractedRange = str_replace(
'$',
'', $extractedRange);
1233 if (stripos((
string)$definedName,
'#REF!') !==
false || $extractedRange ==
'') {
1238 if ((
string)$definedName[
'localSheetId'] !=
'' && (
string)$definedName[
'localSheetId'] == $sheetId) {
1240 switch ((
string)$definedName[
'name']) {
1242 case '_xlnm._FilterDatabase':
1243 $docSheet->setAutoFilter($extractedRange);
1246 case '_xlnm.Print_Titles':
1248 $extractedRange = explode(
',', $extractedRange);
1251 if (isset($extractedRange[0])) {
1252 $range = explode(
':', $extractedRange[0]);
1256 $range[0] = str_replace(
'$',
'', $range[0]);
1259 $range[1] = str_replace(
'$',
'', $range[1]);
1261 $docSheet->getPageSetup()->setColumnsToRepeatAtLeft( $range );
1263 if (isset($extractedRange[1])) {
1264 $range = explode(
':', $extractedRange[1]);
1268 $range[0] = str_replace(
'$',
'', $range[0]);
1271 $range[1] = str_replace(
'$',
'', $range[1]);
1273 $docSheet->getPageSetup()->setRowsToRepeatAtTop( $range );
1278 case '_xlnm.Print_Area':
1279 $range = explode(
'!', $extractedRange);
1280 $extractedRange = isset($range[1]) ? $range[1] : $range[0];
1282 $docSheet->getPageSetup()->setPrintArea($extractedRange);
1286 $range = explode(
'!', $extractedRange);
1287 $extractedRange = isset($range[1]) ? $range[1] : $range[0];
1289 $excel->addNamedRange(
new PHPExcel_NamedRange((
string)$definedName[
'name'], $docSheet, $extractedRange,
true) );
1294 $locatedSheet = null;
1295 $extractedSheetName =
'';
1296 if (strpos( (
string)$definedName,
'!' ) !==
false) {
1299 $extractedSheetName = $extractedSheetName[0];
1302 $locatedSheet = $excel->getSheetByName($extractedSheetName);
1305 $range = explode(
'!', $extractedRange);
1306 $extractedRange = isset($range[1]) ? $range[1] : $range[0];
1309 if (!is_null($locatedSheet)) {
1310 $excel->addNamedRange(
new PHPExcel_NamedRange((
string)$definedName[
'name'], $locatedSheet, $extractedRange,
false) );
1320 if (!$this->_readDataOnly) {
1322 $activeTab = intval($xmlWorkbook->bookViews->workbookView[
"activeTab"]);
1325 if ($mapSheetId[$activeTab] !== null) {
1326 $excel->setActiveSheetIndex($mapSheetId[$activeTab]);
1328 $excel->setActiveSheetIndex(0);
1340 if (isset($color[
"rgb"])) {
1341 return (
string)$color[
"rgb"];
1342 }
else if (isset($color[
"indexed"])) {
1349 if ($style->applyNumberFormat) $docStyle->getNumberFormat()->setFormatCode($style->numFmt);
1352 if (isset($style->font)) {
1353 $docStyle->getFont()->setName((
string) $style->font->name[
"val"]);
1354 $docStyle->getFont()->setSize((
string) $style->font->sz[
"val"]);
1355 if (isset($style->font->b)) {
1356 $docStyle->getFont()->setBold(!isset($style->font->b[
"val"]) || $style->font->b[
"val"] ==
'true');
1358 if (isset($style->font->i)) {
1359 $docStyle->getFont()->setItalic(!isset($style->font->i[
"val"]) || $style->font->i[
"val"] ==
'true');
1361 if (isset($style->font->strike)) {
1362 $docStyle->getFont()->setStrikethrough(!isset($style->font->strike[
"val"]) || $style->font->strike[
"val"] ==
'true');
1364 $docStyle->getFont()->getColor()->setARGB($this->
_readColor($style->font->color));
1366 if (isset($style->font->u) && !isset($style->font->u[
"val"])) {
1368 }
else if (isset($style->font->u) && isset($style->font->u[
"val"])) {
1369 $docStyle->getFont()->setUnderline((
string)$style->font->u[
"val"]);
1372 if (isset($style->font->vertAlign) && isset($style->font->vertAlign[
"val"])) {
1373 $vertAlign = strtolower((
string)$style->font->vertAlign[
"val"]);
1374 if ($vertAlign ==
'superscript') {
1375 $docStyle->getFont()->setSuperScript(
true);
1377 if ($vertAlign ==
'subscript') {
1378 $docStyle->getFont()->setSubScript(
true);
1384 if (isset($style->fill) && ($style->applyFill || $style instanceof SimpleXMLElement)) {
1385 if ($style->fill->gradientFill) {
1386 $gradientFill = $style->fill->gradientFill[0];
1387 $docStyle->getFill()->setFillType((
string) $gradientFill[
"type"]);
1388 $docStyle->getFill()->setRotation(floatval($gradientFill[
"degree"]));
1389 $gradientFill->registerXPathNamespace(
"sml",
"http://schemas.openxmlformats.org/spreadsheetml/2006/main");
1390 $docStyle->getFill()->getStartColor()->setARGB($this->
_readColor( self::array_item($gradientFill->xpath(
"sml:stop[@position=0]"))->color) );
1391 $docStyle->getFill()->getEndColor()->setARGB($this->
_readColor( self::array_item($gradientFill->xpath(
"sml:stop[@position=1]"))->color) );
1392 }
elseif ($style->fill->patternFill) {
1393 $patternType = (string)$style->fill->patternFill[
"patternType"] !=
'' ? (
string)$style->fill->patternFill[
"patternType"] :
'solid';
1394 $docStyle->getFill()->setFillType($patternType);
1395 if ($style->fill->patternFill->fgColor) {
1396 $docStyle->getFill()->getStartColor()->setARGB($this->
_readColor($style->fill->patternFill->fgColor));
1398 $docStyle->getFill()->getStartColor()->setARGB(
'FF000000');
1400 if ($style->fill->patternFill->bgColor) {
1401 $docStyle->getFill()->getEndColor()->setARGB($this->
_readColor($style->fill->patternFill->bgColor));
1407 if (isset($style->border) && ($style->applyBorder || $style instanceof SimpleXMLElement)) {
1408 if ($style->border[
"diagonalUp"] ==
'true') {
1410 }
elseif ($style->border[
"diagonalDown"] ==
'true') {
1413 $this->
_readBorder($docStyle->getBorders()->getLeft(), $style->border->left);
1414 $this->
_readBorder($docStyle->getBorders()->getRight(), $style->border->right);
1415 $this->
_readBorder($docStyle->getBorders()->getTop(), $style->border->top);
1416 $this->
_readBorder($docStyle->getBorders()->getBottom(), $style->border->bottom);
1417 $this->
_readBorder($docStyle->getBorders()->getDiagonal(), $style->border->diagonal);
1421 if (isset($style->alignment) && ($style->applyAlignment || $style instanceof SimpleXMLElement)) {
1422 $docStyle->getAlignment()->setHorizontal((
string) $style->alignment[
"horizontal"]);
1423 $docStyle->getAlignment()->setVertical((
string) $style->alignment[
"vertical"]);
1426 if ((
int)$style->alignment[
"textRotation"] <= 90) {
1427 $textRotation = (int)$style->alignment[
"textRotation"];
1428 }
else if ((
int)$style->alignment[
"textRotation"] > 90) {
1429 $textRotation = 90 - (int)$style->alignment[
"textRotation"];
1432 $docStyle->getAlignment()->setTextRotation(intval($textRotation));
1433 $docStyle->getAlignment()->setWrapText( (
string)$style->alignment[
"wrapText"] ==
"true" || (
string)$style->alignment[
"wrapText"] ==
"1" );
1434 $docStyle->getAlignment()->setShrinkToFit( (
string)$style->alignment[
"shrinkToFit"] ==
"true" || (
string)$style->alignment[
"shrinkToFit"] ==
"1" );
1435 $docStyle->getAlignment()->setIndent( intval((
string)$style->alignment[
"indent"]) > 0 ? intval((
string)$style->alignment[
"indent"]) : 0 );
1439 if (isset($style->protection) && $style->applyProtection) {
1440 if (isset($style->protection[
'locked'])) {
1441 if ((
string)$style->protection[
'locked'] ==
'true') {
1448 if (isset($style->protection[
'hidden'])) {
1449 if ((
string)$style->protection[
'hidden'] ==
'true') {
1459 if (isset($eleBorder[
"style"])) {
1460 $docBorder->setBorderStyle((
string) $eleBorder[
"style"]);
1462 if (isset($eleBorder->color)) {
1463 $docBorder->getColor()->setARGB($this->
_readColor($eleBorder->color));
1470 if (isset($is->t)) {
1473 foreach ($is->r as $run) {
1476 if (isset($run->rPr)) {
1477 if (isset($run->rPr->rFont[
"val"])) {
1478 $objText->getFont()->setName((
string) $run->rPr->rFont[
"val"]);
1481 if (isset($run->rPr->sz[
"val"])) {
1482 $objText->getFont()->setSize((
string) $run->rPr->sz[
"val"]);
1485 if (isset($run->rPr->color)) {
1489 if ( (isset($run->rPr->b[
"val"]) && ((
string) $run->rPr->b[
"val"] ==
'true' || (
string) $run->rPr->b[
"val"] ==
'1'))
1490 || (isset($run->rPr->b) && !isset($run->rPr->b[
"val"])) ) {
1491 $objText->getFont()->setBold(
true);
1494 if ( (isset($run->rPr->i[
"val"]) && ((
string) $run->rPr->i[
"val"] ==
'true' || (
string) $run->rPr->i[
"val"] ==
'1'))
1495 || (isset($run->rPr->i) && !isset($run->rPr->i[
"val"])) ) {
1496 $objText->getFont()->setItalic(
true);
1499 if (isset($run->rPr->vertAlign) && isset($run->rPr->vertAlign[
"val"])) {
1500 $vertAlign = strtolower((
string)$run->rPr->vertAlign[
"val"]);
1501 if ($vertAlign ==
'superscript') {
1502 $objText->getFont()->setSuperScript(
true);
1504 if ($vertAlign ==
'subscript') {
1505 $objText->getFont()->setSubScript(
true);
1509 if (isset($run->rPr->u) && !isset($run->rPr->u[
"val"])) {
1511 }
else if (isset($run->rPr->u) && isset($run->rPr->u[
"val"])) {
1512 $objText->getFont()->setUnderline((
string)$run->rPr->u[
"val"]);
1515 if ( (isset($run->rPr->strike[
"val"]) && ((
string) $run->rPr->strike[
"val"] ==
'true' || (
string) $run->rPr->strike[
"val"] ==
'1'))
1516 || (isset($run->rPr->strike) && !isset($run->rPr->strike[
"val"])) ) {
1517 $objText->getFont()->setStrikethrough(
true);
1527 return (isset($array[
$key]) ? $array[$key] : null);
1531 return preg_replace(
'~[^/]+/\.\./~',
'', dirname($base) .
"/$add");
1535 $style = str_replace(
"\r",
"", $style);
1536 $style = str_replace(
"\n",
"", $style);
1538 $temp = explode(
';', $style);
1541 foreach ($temp as $item) {
1542 $item = explode(
':', $item);
1544 if (strpos($item[1],
'px') !==
false) {
1545 $item[1] = str_replace(
'px',
'', $item[1]);
1547 if (strpos($item[1],
'pt') !==
false) {
1548 $item[1] = str_replace(
'pt',
'', $item[1]);
1551 if (strpos($item[1],
'in') !==
false) {
1552 $item[1] = str_replace(
'in',
'', $item[1]);
1555 if (strpos($item[1],
'cm') !==
false) {
1556 $item[1] = str_replace(
'cm',
'', $item[1]);
1560 $style[$item[0]] = $item[1];