PHPExcel_Reader
[ class tree: PHPExcel_Reader ] [ index: PHPExcel_Reader ] [ all elements ]

Source for file Excel2007.php

Documentation is available at Excel2007.php

  1. <?php
  2. /**
  3.  * PHPExcel
  4.  *
  5.  * Copyright (c) 2006 - 2009 PHPExcel
  6.  *
  7.  * This library is free software; you can redistribute it and/or
  8.  * modify it under the terms of the GNU Lesser General Public
  9.  * License as published by the Free Software Foundation; either
  10.  * version 2.1 of the License, or (at your option) any later version.
  11.  *
  12.  * This library is distributed in the hope that it will be useful,
  13.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15.  * Lesser General Public License for more details.
  16.  *
  17.  * You should have received a copy of the GNU Lesser General Public
  18.  * License along with this library; if not, write to the Free Software
  19.  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  20.  *
  21.  * @category   PHPExcel
  22.  * @package    PHPExcel_Reader
  23.  * @copyright  Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
  24.  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL
  25.  * @version    1.6.7, 2009-04-22
  26.  */
  27.  
  28.  
  29. /** PHPExcel */
  30. require_once 'PHPExcel.php';
  31.  
  32. /** PHPExcel_Reader_IReader */
  33. require_once 'PHPExcel/Reader/IReader.php';
  34.  
  35. /** PHPExcel_Worksheet */
  36. require_once 'PHPExcel/Worksheet.php';
  37.  
  38. /** PHPExcel_Cell */
  39. require_once 'PHPExcel/Cell.php';
  40.  
  41. /** PHPExcel_Style */
  42. require_once 'PHPExcel/Style.php';
  43.  
  44. /** PHPExcel_Style_Borders */
  45. require_once 'PHPExcel/Style/Borders.php';
  46.  
  47. /** PHPExcel_Style_Conditional */
  48. require_once 'PHPExcel/Style/Conditional.php';
  49.  
  50. /** PHPExcel_Style_Protection */
  51. require_once 'PHPExcel/Style/Protection.php';
  52.  
  53. /** PHPExcel_Style_NumberFormat */
  54. require_once 'PHPExcel/Style/NumberFormat.php';
  55.  
  56. /** PHPExcel_Worksheet_BaseDrawing */
  57. require_once 'PHPExcel/Worksheet/BaseDrawing.php';
  58.  
  59. /** PHPExcel_Worksheet_Drawing */
  60. require_once 'PHPExcel/Worksheet/Drawing.php';
  61.  
  62. /** PHPExcel_Shared_Drawing */
  63. require_once 'PHPExcel/Shared/Drawing.php';
  64.  
  65. /** PHPExcel_Shared_Date */
  66. require_once 'PHPExcel/Shared/Date.php';
  67.  
  68. /** PHPExcel_Shared_File */
  69. require_once 'PHPExcel/Shared/File.php';
  70.  
  71. /** PHPExcel_Shared_String */
  72. require_once 'PHPExcel/Shared/String.php';
  73.  
  74. /** PHPExcel_ReferenceHelper */
  75. require_once 'PHPExcel/ReferenceHelper.php';
  76.  
  77.  /** PHPExcel_Reader_IReadFilter */
  78. require_once 'PHPExcel/Reader/IReadFilter.php';
  79.  
  80.  /** PHPExcel_Reader_DefaultReadFilter */
  81. require_once 'PHPExcel/Reader/DefaultReadFilter.php';
  82.  
  83.  
  84. /**
  85.  * PHPExcel_Reader_Excel2007
  86.  *
  87.  * @category   PHPExcel
  88.  * @package    PHPExcel_Reader
  89.  * @copyright  Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
  90.  */
  91. class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
  92. {
  93.     /**
  94.      * Read data only?
  95.      *
  96.      * @var boolean 
  97.      */
  98.     private $_readDataOnly = false;
  99.  
  100.     /**
  101.      * Restict which sheets should be loaded?
  102.      *
  103.      * @var array 
  104.      */
  105.     private $_loadSheetsOnly = null;
  106.  
  107.     /**
  108.      * PHPExcel_Reader_IReadFilter instance
  109.      *
  110.      * @var PHPExcel_Reader_IReadFilter 
  111.      */
  112.     private $_readFilter = null;
  113.  
  114.     /**
  115.      * Read data only?
  116.      *
  117.      * @return boolean 
  118.      */
  119.     public function getReadDataOnly({
  120.         return $this->_readDataOnly;
  121.     }
  122.  
  123.     /**
  124.      * Set read data only
  125.      *
  126.      * @param boolean $pValue 
  127.      */
  128.     public function setReadDataOnly($pValue false{
  129.         $this->_readDataOnly = $pValue;
  130.     }
  131.  
  132.     /**
  133.      * Get which sheets to load
  134.      *
  135.      * @return mixed 
  136.      */
  137.     public function getLoadSheetsOnly()
  138.     {
  139.         return $this->_loadSheetsOnly;
  140.     }
  141.  
  142.     /**
  143.      * Set which sheets to load
  144.      *
  145.      * @param mixed $value 
  146.      */
  147.     public function setLoadSheetsOnly($value null)
  148.     {
  149.         $this->_loadSheetsOnly = is_array($value?
  150.             $value array($value);
  151.     }
  152.  
  153.     /**
  154.      * Set all sheets to load
  155.      */
  156.     public function setLoadAllSheets()
  157.     {
  158.         $this->_loadSheetsOnly = null;
  159.     }
  160.  
  161.     /**
  162.      * Read filter
  163.      *
  164.      * @return PHPExcel_Reader_IReadFilter 
  165.      */
  166.     public function getReadFilter({
  167.         return $this->_readFilter;
  168.     }
  169.  
  170.     /**
  171.      * Set read filter
  172.      *
  173.      * @param PHPExcel_Reader_IReadFilter $pValue 
  174.      */
  175.     public function setReadFilter(PHPExcel_Reader_IReadFilter $pValue{
  176.         $this->_readFilter = $pValue;
  177.     }
  178.  
  179.     /**
  180.      * Create a new PHPExcel_Reader_Excel2007 instance
  181.      */
  182.     public function __construct({
  183.         $this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
  184.     }
  185.     
  186.     /**
  187.      * Can the current PHPExcel_Reader_IReader read the file?
  188.      *
  189.      * @param     string         $pFileName 
  190.      * @return     boolean 
  191.      */    
  192.     public function canRead($pFilename
  193.     {
  194.         // Check if file exists
  195.         if (!file_exists($pFilename)) {
  196.             throw new Exception("Could not open " $pFilename " for reading! File does not exist.");
  197.         }
  198.         
  199.         // Load file
  200.         $zip new ZipArchive;
  201.         if ($zip->open($pFilename=== true{
  202.             // check if it is an OOXML archive
  203.             $rels simplexml_load_string($zip->getFromName("_rels/.rels"));
  204.             
  205.             $zip->close();
  206.             
  207.             return ($rels !== false);
  208.         }
  209.         
  210.         return false;
  211.     }
  212.  
  213.     /**
  214.      * Loads PHPExcel from file
  215.      *
  216.      * @param     string         $pFilename 
  217.      * @throws     Exception
  218.      */
  219.     public function load($pFilename)
  220.     {
  221.         // Check if file exists
  222.         if (!file_exists($pFilename)) {
  223.             throw new Exception("Could not open " $pFilename " for reading! File does not exist.");
  224.         }
  225.  
  226.         // Initialisations
  227.         $excel new PHPExcel;
  228.         $excel->removeSheetByIndex(0);
  229.         $zip new ZipArchive;
  230.         $zip->open($pFilename);
  231.  
  232.         $rels simplexml_load_string($zip->getFromName("_rels/.rels"))//~ http://schemas.openxmlformats.org/package/2006/relationships");
  233.         foreach ($rels->Relationship as $rel{
  234.             switch ($rel["Type"]{
  235.                 case "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties":
  236.                     $xmlCore simplexml_load_string($zip->getFromName("{$rel['Target']}"));
  237.                     $xmlCore->registerXPathNamespace("dc""http://purl.org/dc/elements/1.1/");
  238.                     $xmlCore->registerXPathNamespace("dcterms""http://purl.org/dc/terms/");
  239.                     $xmlCore->registerXPathNamespace("cp""http://schemas.openxmlformats.org/package/2006/metadata/core-properties");
  240.                     $docProps $excel->getProperties();
  241.                     $docProps->setCreator((string) self::array_item($xmlCore->xpath("dc:creator")));
  242.                     $docProps->setLastModifiedBy((string) self::array_item($xmlCore->xpath("cp:lastModifiedBy")));
  243.                     $docProps->setCreated(strtotime(self::array_item($xmlCore->xpath("dcterms:created"))))//! respect xsi:type
  244.                     $docProps->setModified(strtotime(self::array_item($xmlCore->xpath("dcterms:modified"))))//! respect xsi:type
  245.                     $docProps->setTitle((string) self::array_item($xmlCore->xpath("dc:title")));
  246.                     $docProps->setDescription((string) self::array_item($xmlCore->xpath("dc:description")));
  247.                     $docProps->setSubject((string) self::array_item($xmlCore->xpath("dc:subject")));
  248.                     $docProps->setKeywords((string) self::array_item($xmlCore->xpath("cp:keywords")));
  249.                     $docProps->setCategory((string) self::array_item($xmlCore->xpath("cp:category")));
  250.                 break;
  251.  
  252.                 case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument":
  253.                     $dir dirname($rel["Target"]);
  254.                     $relsWorkbook simplexml_load_string($zip->getFromName("$dir/_rels/basename($rel["Target"]".rels"));  //~ http://schemas.openxmlformats.org/package/2006/relationships");
  255.                     $relsWorkbook->registerXPathNamespace("rel""http://schemas.openxmlformats.org/package/2006/relationships");
  256.  
  257.                     $sharedStrings array();
  258.                     $xpath self::array_item($relsWorkbook->xpath("rel:Relationship[@Type='http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings']"));
  259.                     $xmlStrings simplexml_load_string($zip->getFromName("$dir/$xpath[Target]"));  //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main");
  260.                     if (isset($xmlStrings&& isset($xmlStrings->si)) {
  261.                         foreach ($xmlStrings->si as $val{
  262.                             if (isset($val->t)) {
  263.                                 $sharedStrings[PHPExcel_Shared_String::ControlCharacterOOXML2PHP(string) $val->);
  264.                             elseif (isset($val->r)) {
  265.                                 $sharedStrings[$this->_parseRichText($val);
  266.                             }
  267.                         }
  268.                     }
  269.  
  270.                     $worksheets array();
  271.                     foreach ($relsWorkbook->Relationship as $ele{
  272.                         if ($ele["Type"== "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet"{
  273.                             $worksheets[(string) $ele["Id"]] $ele["Target"];
  274.                         }
  275.                     }
  276.  
  277.                     $styles     array();
  278.                     $cellStyles array();
  279.                     $xpath self::array_item($relsWorkbook->xpath("rel:Relationship[@Type='http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles']"));
  280.                     $xmlStyles simplexml_load_string($zip->getFromName("$dir/$xpath[Target]"))//~ http://schemas.openxmlformats.org/spreadsheetml/2006/main");
  281.                     $numFmts $xmlStyles->numFmts[0];
  282.                     if (isset($numFmts)) {
  283.                         $numFmts->registerXPathNamespace("sml""http://schemas.openxmlformats.org/spreadsheetml/2006/main");
  284.                     }
  285.                     if (!$this->_readDataOnly{
  286.                         foreach ($xmlStyles->cellXfs->xf as $xf{
  287.                             $numFmt PHPExcel_Style_NumberFormat::FORMAT_GENERAL;
  288.                             
  289.                             if ($xf["numFmtId"]{
  290.                                 if (isset($numFmts)) {
  291.                                     $tmpNumFmt self::array_item($numFmts->xpath("sml:numFmt[@numFmtId=$xf[numFmtId]]"));
  292.  
  293.                                     if (isset($tmpNumFmt["formatCode"])) {
  294.                                         $numFmt = (string) $tmpNumFmt["formatCode"];
  295.                                     }
  296.                                 }
  297.                                 
  298.                                 if ((int)$xf["numFmtId"164{
  299.                                     $numFmt PHPExcel_Style_NumberFormat::builtInFormatCode((int)$xf["numFmtId"]);
  300.                                 }
  301.                             }
  302.                             //$numFmt = str_replace('mm', 'i', $numFmt);
  303.                             //$numFmt = str_replace('h', 'H', $numFmt);
  304.  
  305.                             $styles[= (object) array(
  306.                                 "numFmt" => $numFmt,
  307.                                 "font" => $xmlStyles->fonts->font[intval($xf["fontId"])],
  308.                                 "fill" => $xmlStyles->fills->fill[intval($xf["fillId"])],
  309.                                 "border" => $xmlStyles->borders->border[intval($xf["borderId"])],
  310.                                 "alignment" => $xf->alignment,
  311.                                 "protection" => $xf->protection,
  312.                                 "applyAlignment" => (isset($xf["applyAlignment"]&& ((string)$xf["applyAlignment"== 'true' || (string)$xf["applyAlignment"== '1')),
  313.                                 "applyBorder" => (isset($xf["applyBorder"]&& ((string)$xf["applyBorder"== 'true' || (string)$xf["applyBorder"== '1')),
  314.                                 "applyFill" => (isset($xf["applyFill"]&& ((string)$xf["applyFill"== 'true' || (string)$xf["applyFill"== '1')),
  315.                                 "applyFont" => (isset($xf["applyFont"]&& ((string)$xf["applyFont"== 'true' || (string)$xf["applyFont"== '1')),
  316.                                 "applyNumberFormat" => (isset($xf["applyNumberFormat"]&& ((string)$xf["applyNumberFormat"== 'true' || (string)$xf["applyNumberFormat"== '1')),
  317.                                 "applyProtection" => (isset($xf["applyProtection"]&& ((string)$xf["applyProtection"== 'true' || (string)$xf["applyProtection"== '1'))
  318.                             );
  319.                         }
  320.  
  321.                         foreach ($xmlStyles->cellStyleXfs->xf as $xf{
  322.                             $numFmt PHPExcel_Style_NumberFormat::FORMAT_GENERAL;
  323.                             if ($numFmts && $xf["numFmtId"]{
  324.                                 $tmpNumFmt self::array_item($numFmts->xpath("sml:numFmt[@numFmtId=$xf[numFmtId]]"));
  325.                                 if (isset($tmpNumFmt["formatCode"])) {
  326.                                     $numFmt = (string) $tmpNumFmt["formatCode"];
  327.                                 else if ((int)$xf["numFmtId"165{
  328.                                     $numFmt PHPExcel_Style_NumberFormat::builtInFormatCode((int)$xf["numFmtId"]);
  329.                                 }
  330.                             }
  331.  
  332.                             $cellStyles[= (object) array(
  333.                                 "numFmt" => $numFmt,
  334.                                 "font" => $xmlStyles->fonts->font[intval($xf["fontId"])],
  335.                                 "fill" => $xmlStyles->fills->fill[intval($xf["fillId"])],
  336.                                 "border" => $xmlStyles->borders->border[intval($xf["borderId"])],
  337.                                 "alignment" => $xf->alignment,
  338.                                 "protection" => $xf->protection,
  339.                                 "applyAlignment" => true,
  340.                                 "applyBorder" => true,
  341.                                 "applyFill" => true,
  342.                                 "applyFont" => true,
  343.                                 "applyNumberFormat" => true,
  344.                                 "applyProtection" => true
  345.                             );
  346.                         }
  347.                     }
  348.  
  349.                     $dxfs array();
  350.                     if (!$this->_readDataOnly{
  351.                         foreach ($xmlStyles->dxfs->dxf as $dxf{
  352.                             $style new PHPExcel_Style;
  353.                             $this->_readStyle($style$dxf);
  354.                             $dxfs[$style;
  355.                         }
  356.  
  357.                         foreach ($xmlStyles->cellStyles->cellStyle as $cellStyle{
  358.                             if (intval($cellStyle['builtinId']== 0{
  359.                                 if (isset($cellStyles[intval($cellStyle['xfId'])])) {
  360.                                     // Set default style
  361.                                     $style new PHPExcel_Style;
  362.                                     $this->_readStyle($style$cellStyles[intval($cellStyle['xfId'])]);
  363.                                     PHPExcel_Style::setDefaultStyle($style);
  364.                                 }
  365.                             }
  366.                         }
  367.                     }
  368.  
  369.                     $xmlWorkbook simplexml_load_string($zip->getFromName("{$rel['Target']}"));  //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main");
  370.  
  371.                     // Set base date
  372.                     if ($xmlWorkbook->workbookPr{
  373.                         PHPExcel_Shared_Date::setExcelCalendar(PHPExcel_Shared_Date::CALENDAR_WINDOWS_1900);
  374.                         if (isset($xmlWorkbook->workbookPr['date1904'])) {
  375.                             $date1904 = (string)$xmlWorkbook->workbookPr['date1904'];
  376.                             if ($date1904 == "true" || $date1904 == "1"{
  377.                                 PHPExcel_Shared_Date::setExcelCalendar(PHPExcel_Shared_Date::CALENDAR_MAC_1904);
  378.                             }
  379.                         }
  380.                     }
  381.  
  382.                     $sheetId 0;
  383.                     foreach ($xmlWorkbook->sheets->sheet as $eleSheet{
  384.                         // Check if sheet should be skipped
  385.                         if (isset($this->_loadSheetsOnly&& !in_array((string) $eleSheet["name"]$this->_loadSheetsOnly)) {
  386.                             continue;
  387.                         }
  388.  
  389.                         // Load sheet
  390.                         $docSheet $excel->createSheet();
  391.                         $docSheet->setTitle((string) $eleSheet["name"]);
  392.                         $fileWorksheet $worksheets[(string) self::array_item($eleSheet->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships")"id")];
  393.                         $xmlSheet simplexml_load_string($zip->getFromName("$dir/$fileWorksheet"));  //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main");
  394.  
  395.                         $sharedFormulas array();
  396.  
  397.                         if (isset($xmlSheet->sheetViews&& isset($xmlSheet->sheetViews->sheetView)) {
  398.                             if (isset($xmlSheet->sheetViews->sheetView['zoomScale'])) {
  399.                                 $docSheet->getSheetView()->setZoomScaleintval($xmlSheet->sheetViews->sheetView['zoomScale']) );
  400.                             }
  401.  
  402.                             if (isset($xmlSheet->sheetViews->sheetView['zoomScaleNormal'])) {
  403.                                 $docSheet->getSheetView()->setZoomScaleNormalintval($xmlSheet->sheetViews->sheetView['zoomScaleNormal']) );
  404.                             }
  405.  
  406.                             if (isset($xmlSheet->sheetViews->sheetView['showGridLines'])) {
  407.                                 $docSheet->setShowGridLines($xmlSheet->sheetViews->sheetView['showGridLines'true false);
  408.                             }
  409.  
  410.                             if (isset($xmlSheet->sheetViews->sheetView->pane)) {
  411.                                 if (isset($xmlSheet->sheetViews->sheetView->pane['topLeftCell'])) {
  412.                                     $docSheet->freezePane(string)$xmlSheet->sheetViews->sheetView->pane['topLeftCell');
  413.                                 else {
  414.                                     $xSplit 0;
  415.                                     $ySplit 0;
  416.  
  417.                                     if (isset($xmlSheet->sheetViews->sheetView->pane['xSplit'])) {
  418.                                         $xSplit intval($xmlSheet->sheetViews->sheetView->pane['xSplit']);
  419.                                     }
  420.  
  421.                                     if (isset($xmlSheet->sheetViews->sheetView->pane['ySplit'])) {
  422.                                         $ySplit intval($xmlSheet->sheetViews->sheetView->pane['ySplit']);
  423.                                     }
  424.  
  425.                                     $docSheet->freezePaneByColumnAndRow($xSplit$ySplit);
  426.                                 }
  427.                             }
  428.                         }
  429.  
  430.                         if (isset($xmlSheet->sheetPr&& isset($xmlSheet->sheetPr->outlinePr)) {
  431.                             if (isset($xmlSheet->sheetPr->outlinePr['summaryRight']&& $xmlSheet->sheetPr->outlinePr['summaryRight'== false{
  432.                                 $docSheet->setShowSummaryRight(false);
  433.                             else {
  434.                                 $docSheet->setShowSummaryRight(true);
  435.                             }
  436.  
  437.                             if (isset($xmlSheet->sheetPr->outlinePr['summaryBelow']&& $xmlSheet->sheetPr->outlinePr['summaryBelow'== false{
  438.                                 $docSheet->setShowSummaryBelow(false);
  439.                             else {
  440.                                 $docSheet->setShowSummaryBelow(true);
  441.                             }
  442.                         }
  443.  
  444.                         if (isset($xmlSheet->sheetFormatPr)) {
  445.                             if (isset($xmlSheet->sheetFormatPr['customHeight']&& ((string)$xmlSheet->sheetFormatPr['customHeight'== '1' || strtolower((string)$xmlSheet->sheetFormatPr['customHeight']== 'true'&& isset($xmlSheet->sheetFormatPr['defaultRowHeight'])) {
  446.                                 $docSheet->getDefaultRowDimension()->setRowHeight(float)$xmlSheet->sheetFormatPr['defaultRowHeight');
  447.                             }
  448.                             if (isset($xmlSheet->sheetFormatPr['defaultColWidth'])) {
  449.                                 $docSheet->getDefaultColumnDimension()->setWidth(float)$xmlSheet->sheetFormatPr['defaultColWidth');
  450.                             }
  451.                         }
  452.  
  453.                         if (isset($xmlSheet->cols&& !$this->_readDataOnly{
  454.                             foreach ($xmlSheet->cols->col as $col{
  455.                                 for ($i intval($col["min"]1$i intval($col["max"])++$i{
  456.                                     if ($col["bestFit"]{
  457.                                         $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setAutoSize(true);
  458.                                     }
  459.                                     if ($col["hidden"]{
  460.                                         $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setVisible(false);
  461.                                     }
  462.                                     if ($col["collapsed"]{
  463.                                         $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setCollapsed(true);
  464.                                     }
  465.                                     if ($col["outlineLevel"0{
  466.                                         $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setOutlineLevel(intval($col["outlineLevel"]));
  467.                                     }
  468.                                     $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setWidth(floatval($col["width"]));
  469.  
  470.                                     if (intval($col["max"]== 16384{
  471.                                         break;
  472.                                     }
  473.                                 }
  474.                             }
  475.                         }
  476.  
  477.                         if (isset($xmlSheet->printOptions&& !$this->_readDataOnly{
  478.                             if ($xmlSheet->printOptions['gridLinesSet'== 'true' && $xmlSheet->printOptions['gridLinesSet'== '1'{
  479.                                 $docSheet->setShowGridlines(true);
  480.                             }
  481.  
  482.                             if ($xmlSheet->printOptions['gridLines'== 'true' || $xmlSheet->printOptions['gridLines'== '1'{
  483.                                 $docSheet->setPrintGridlines(true);
  484.                             }
  485.  
  486.                             if ($xmlSheet->printOptions['horizontalCentered']{
  487.                                 $docSheet->getPageSetup()->setHorizontalCentered(true);
  488.                             }
  489.                             if ($xmlSheet->printOptions['verticalCentered']{
  490.                                 $docSheet->getPageSetup()->setVerticalCentered(true);
  491.                             }
  492.                         }
  493.  
  494.                         foreach ($xmlSheet->sheetData->row as $row{
  495.                             if ($row["ht"&& !$this->_readDataOnly{
  496.                                 $docSheet->getRowDimension(intval($row["r"]))->setRowHeight(floatval($row["ht"]));
  497.                             }
  498.                             if ($row["hidden"&& !$this->_readDataOnly{
  499.                                 $docSheet->getRowDimension(intval($row["r"]))->setVisible(false);
  500.                             }
  501.                             if ($row["collapsed"]{
  502.                                 $docSheet->getRowDimension(intval($row["r"]))->setCollapsed(true);
  503.                             }
  504.                             if ($row["outlineLevel"0{
  505.                                 $docSheet->getRowDimension(intval($row["r"]))->setOutlineLevel(intval($row["outlineLevel"]));
  506.                             }
  507.  
  508.                             foreach ($row->as $c{
  509.                                 $r                     = (string) $c["r"];
  510.                                 $cellDataType         = (string) $c["t"];
  511.                                 $value                null;
  512.                                 $calculatedValue     null;
  513.  
  514.                                 // Read cell?
  515.                                 if !is_null($this->getReadFilter()) ) {
  516.                                     $coordinates PHPExcel_Cell::coordinateFromString($r);
  517.  
  518.                                     if !$this->getReadFilter()->readCell($coordinates[0]$coordinates[1]$docSheet->getTitle()) ) {
  519.                                         break;
  520.                                     }
  521.                                 }
  522.  
  523.                                 // Read cell!
  524.                                 switch ($cellDataType{
  525.                                     case "s":
  526.                                         if ((string)$c->!= ''{
  527.                                             $value $sharedStrings[intval($c->v)];
  528.  
  529.                                             if ($value instanceof PHPExcel_RichText{
  530.                                                 $value clone $value;
  531.                                             }
  532.                                         else {
  533.                                             $value '';
  534.                                         }
  535.  
  536.                                         break;
  537.                                     case "b":
  538.                                         $value = (string)$c->v;
  539.                                         if ($value == '0'{
  540.                                             $value false;
  541.                                         else if ($value == '1'{
  542.                                             $value true;
  543.                                         else {
  544.                                             $value = (bool)$c->v;
  545.                                         }
  546.  
  547.                                         break;
  548.                                     case "inlineStr":
  549.                                         $value $this->_parseRichText($c->is);
  550.  
  551.                                         break;
  552.                                     case "e":
  553.                                         if (!isset($c->f)) {
  554.                                             $value = (string)$c->v;
  555.                                         else {
  556.                                             $value "={$c->f}";
  557.                                         }
  558.  
  559.                                         break;
  560.  
  561.                                     default:
  562.                                         if (!isset($c->f)) {
  563.                                             $value = (string) $c->v;
  564.                                         else {
  565.                                             // Formula
  566.                                             $value                 "={$c->f}";
  567.                                             $calculatedValue     = isset($c->v? (string) $c->null;
  568.                                             $cellDataType         'f';
  569.  
  570.                                             // Shared formula?
  571.                                             if (isset($c->f['t']&& strtolower((string)$c->f['t']== 'shared'{
  572.                                                 $instance = (string)$c->f['si'];
  573.  
  574.                                                 if (!isset($sharedFormulas[(string)$c->f['si']])) {
  575.                                                     $sharedFormulas[$instancearray('master' => $r,
  576.                                                                                         'formula' => $value);
  577.                                                 else {
  578.                                                     $master PHPExcel_Cell::coordinateFromString($sharedFormulas[$instance]['master']);
  579.                                                     $current PHPExcel_Cell::coordinateFromString($r);
  580.  
  581.                                                     $difference array(00);
  582.                                                     $difference[0PHPExcel_Cell::columnIndexFromString($current[0]PHPExcel_Cell::columnIndexFromString$master[0]);
  583.                                                     $difference[1$current[1$master[1];
  584.  
  585.                                                     $helper PHPExcel_ReferenceHelper::getInstance();
  586.                                                     $x $helper->updateFormulaReferences(
  587.                                                         $sharedFormulas[$instance]['formula'],
  588.                                                         'A1',
  589.                                                         $difference[0],
  590.                                                         $difference[1]
  591.                                                     );
  592.  
  593.                                                     $value $x;
  594.                                                 }
  595.                                             }
  596.                                         }
  597.  
  598.                                         break;
  599.                                 }
  600.  
  601.                                 // Check for numeric values
  602.                                 if (is_numeric($value&& $cellDataType != 's'{
  603.                                     if ($value == (int)$value$value = (int)$value;
  604.                                     elseif ($value == (float)$value$value = (float)$value;
  605.                                     elseif ($value == (double)$value$value = (double)$value;
  606.                                 }
  607.  
  608.                                 // Rich text?
  609.                                 if ($value instanceof PHPExcel_RichText && $this->_readDataOnly{
  610.                                     $value $value->getPlainText();
  611.                                 }
  612.  
  613.                                 // Assign value
  614.                                 if ($cellDataType != ''{
  615.                                     $docSheet->setCellValueExplicit($r$value$cellDataType);
  616.                                 else {
  617.                                     $docSheet->setCellValue($r$value);
  618.                                 }
  619.                                 if (!is_null($calculatedValue)) {
  620.                                     $docSheet->getCell($r)->setCalculatedValue($calculatedValue);
  621.                                 }
  622.  
  623.                                 // Style information?
  624.                                 if ($c["s"&& !$this->_readDataOnly{
  625.                                     if (isset($styles[intval($c["s"])])) {
  626.                                         $this->_readStyle($docSheet->getStyle($r)$styles[intval($c["s"])]);
  627.                                     }
  628.                                 }
  629.  
  630.                                 // Set rich text parent
  631.                                 if ($value instanceof PHPExcel_RichText && !$this->_readDataOnly{
  632.                                     $value->setParent($docSheet->getCell($r));
  633.                                 }
  634.                             }
  635.                         }
  636.  
  637.                         $conditionals array();
  638.                         if (!$this->_readDataOnly{
  639.                             foreach ($xmlSheet->conditionalFormatting as $conditional{
  640.                                 foreach ($conditional->cfRule as $cfRule{
  641.                                     if (
  642.                                         (
  643.                                             (string)$cfRule["type"== PHPExcel_Style_Conditional::CONDITION_NONE ||
  644.                                             (string)$cfRule["type"== PHPExcel_Style_Conditional::CONDITION_CELLIS ||
  645.                                             (string)$cfRule["type"== PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT
  646.                                         && isset($dxfs[intval($cfRule["dxfId"])])
  647.                                     {
  648.                                         $conditionals[(string) $conditional["sqref"]][intval($cfRule["priority"])$cfRule;
  649.                                     }
  650.                                 }
  651.                             }
  652.  
  653.                             foreach ($conditionals as $ref => $cfRules{
  654.                                 ksort($cfRules);
  655.                                 $conditionalStyles array();
  656.                                 foreach ($cfRules as $cfRule{
  657.                                     $objConditional new PHPExcel_Style_Conditional();
  658.                                     $objConditional->setConditionType((string)$cfRule["type"]);
  659.                                     $objConditional->setOperatorType((string)$cfRule["operator"]);
  660.  
  661.                                     if ((string)$cfRule["text"!= ''{
  662.                                         $objConditional->setText((string)$cfRule["text"]);
  663.                                     }
  664.  
  665.                                     if (count($cfRule->formula1{
  666.                                         foreach ($cfRule->formula as $formula{
  667.                                             $objConditional->addCondition((string)$formula);
  668.                                         }
  669.                                     else {
  670.                                         $objConditional->addCondition((string)$cfRule->formula);
  671.                                     }
  672.                                     $objConditional->setStyle(clone $dxfs[intval($cfRule["dxfId"])]);
  673.                                     $conditionalStyles[$objConditional;
  674.                                 }
  675.  
  676.                                 // Extract all cell references in $ref
  677.                                 $aReferences PHPExcel_Cell::extractAllCellReferencesInRange($ref);
  678.                                 foreach ($aReferences as $reference{
  679.                                     $docSheet->getStyle($reference)->setConditionalStyles($conditionalStyles);
  680.                                 }
  681.                             }
  682.                         }
  683.  
  684.                         $aKeys array("sheet""objects""scenarios""formatCells""formatColumns""formatRows""insertColumns""insertRows""insertHyperlinks""deleteColumns""deleteRows""selectLockedCells""sort""autoFilter""pivotTables""selectUnlockedCells");
  685.                         if (!$this->_readDataOnly{
  686.                             foreach ($aKeys as $key{
  687.                                 $method "set" ucfirst($key);
  688.                                 $docSheet->getProtection()->$method($xmlSheet->sheetProtection[$key== "true");
  689.                             }
  690.                         }
  691.  
  692.                         if (!$this->_readDataOnly{
  693.                             $docSheet->getProtection()->setPassword((string) $xmlSheet->sheetProtection["password"]true);
  694.                             if ($xmlSheet->protectedRanges->protectedRange{
  695.                                 foreach ($xmlSheet->protectedRanges->protectedRange as $protectedRange{
  696.                                     $docSheet->protectCells((string) $protectedRange["sqref"](string) $protectedRange["password"]true);
  697.                                 }
  698.                             }
  699.                         }
  700.  
  701.                         if ($xmlSheet->autoFilter && !$this->_readDataOnly{
  702.                             $docSheet->setAutoFilter((string) $xmlSheet->autoFilter["ref"]);
  703.                         }
  704.  
  705.                         if ($xmlSheet->mergeCells->mergeCell && !$this->_readDataOnly{
  706.                             foreach ($xmlSheet->mergeCells->mergeCell as $mergeCell{
  707.                                 $docSheet->mergeCells((string) $mergeCell["ref"]);
  708.                             }
  709.                         }
  710.  
  711.                         if (!$this->_readDataOnly{
  712.                             $docPageMargins $docSheet->getPageMargins();
  713.                             $docPageMargins->setLeft(floatval($xmlSheet->pageMargins["left"]));
  714.                             $docPageMargins->setRight(floatval($xmlSheet->pageMargins["right"]));
  715.                             $docPageMargins->setTop(floatval($xmlSheet->pageMargins["top"]));
  716.                             $docPageMargins->setBottom(floatval($xmlSheet->pageMargins["bottom"]));
  717.                             $docPageMargins->setHeader(floatval($xmlSheet->pageMargins["header"]));
  718.                             $docPageMargins->setFooter(floatval($xmlSheet->pageMargins["footer"]));
  719.                         }
  720.  
  721.                         if (!$this->_readDataOnly{
  722.                             $docPageSetup $docSheet->getPageSetup();
  723.  
  724.                             if (isset($xmlSheet->pageSetup["orientation"])) {
  725.                                 $docPageSetup->setOrientation((string) $xmlSheet->pageSetup["orientation"]);
  726.                             }
  727.                             if (isset($xmlSheet->pageSetup["paperSize"])) {
  728.                                 $docPageSetup->setPaperSize(intval($xmlSheet->pageSetup["paperSize"]));
  729.                             }
  730.                             if (isset($xmlSheet->pageSetup["scale"])) {
  731.                                 $docPageSetup->setScale(intval($xmlSheet->pageSetup["scale"]));
  732.                             }
  733.                             if (isset($xmlSheet->pageSetup["fitToHeight"]&& intval($xmlSheet->pageSetup["fitToHeight"]0{
  734.                                 $docPageSetup->setFitToHeight(intval($xmlSheet->pageSetup["fitToHeight"]));
  735.                             }
  736.                             if (isset($xmlSheet->pageSetup["fitToWidth"]&& intval($xmlSheet->pageSetup["fitToWidth"]0{
  737.                                 $docPageSetup->setFitToWidth(intval($xmlSheet->pageSetup["fitToWidth"]));
  738.                             }
  739.                         }
  740.  
  741.                         if (!$this->_readDataOnly{
  742.                             $docHeaderFooter $docSheet->getHeaderFooter();
  743.                             
  744.                             if (isset($xmlSheet->headerFooter["differentOddEven"]&& 
  745.                                 ((string)$xmlSheet->headerFooter["differentOddEven"== 'true' || (string)$xmlSheet->headerFooter["differentOddEven"== '1')) {
  746.                                 $docHeaderFooter->setDifferentOddEven(true)
  747.                             else {
  748.                                 $docHeaderFooter->setDifferentOddEven(false)
  749.                             }
  750.                             if (isset($xmlSheet->headerFooter["differentFirst"]&& 
  751.                                 ((string)$xmlSheet->headerFooter["differentFirst"== 'true' || (string)$xmlSheet->headerFooter["differentFirst"== '1')) {
  752.                                 $docHeaderFooter->setDifferentFirst(true)
  753.                             else {
  754.                                 $docHeaderFooter->setDifferentFirst(false);
  755.                             }
  756.                             if (isset($xmlSheet->headerFooter["scaleWithDoc"]&& 
  757.                                 ((string)$xmlSheet->headerFooter["scaleWithDoc"== 'false' || (string)$xmlSheet->headerFooter["scaleWithDoc"== '0')) {
  758.                                 $docHeaderFooter->setScaleWithDocument(false)
  759.                             else {
  760.                                 $docHeaderFooter->setScaleWithDocument(true)
  761.                             }
  762.                             if (isset($xmlSheet->headerFooter["alignWithMargins"]&& 
  763.                                 ((string)$xmlSheet->headerFooter["alignWithMargins"== 'false' || (string)$xmlSheet->headerFooter["alignWithMargins"== '0')) {
  764.                                 $docHeaderFooter->setAlignWithMargins(false)
  765.                             else {
  766.                                 $docHeaderFooter->setAlignWithMargins(true)
  767.                             }
  768.                             
  769.                             $docHeaderFooter->setOddHeader((string) $xmlSheet->headerFooter->oddHeader);
  770.                             $docHeaderFooter->setOddFooter((string) $xmlSheet->headerFooter->oddFooter);
  771.                             $docHeaderFooter->setEvenHeader((string) $xmlSheet->headerFooter->evenHeader);
  772.                             $docHeaderFooter->setEvenFooter((string) $xmlSheet->headerFooter->evenFooter);
  773.                             $docHeaderFooter->setFirstHeader((string) $xmlSheet->headerFooter->firstHeader);
  774.                             $docHeaderFooter->setFirstFooter((string) $xmlSheet->headerFooter->firstFooter);
  775.                         }
  776.  
  777.                         if ($xmlSheet->rowBreaks->brk && !$this->_readDataOnly{
  778.                             foreach ($xmlSheet->rowBreaks->brk as $brk{
  779.                                 if ($brk["man"]{
  780.                                     $docSheet->setBreak("A$brk[id]"PHPExcel_Worksheet::BREAK_ROW);
  781.                                 }
  782.                             }
  783.                         }
  784.                         if ($xmlSheet->colBreaks->brk && !$this->_readDataOnly{
  785.                             foreach ($xmlSheet->colBreaks->brk as $brk{
  786.                                 if ($brk["man"]{
  787.                                     $docSheet->setBreak(PHPExcel_Cell::stringFromColumnIndex($brk["id"]"1"PHPExcel_Worksheet::BREAK_COLUMN);
  788.                                 }
  789.                             }
  790.                         }
  791.  
  792.                         if ($xmlSheet->dataValidations && !$this->_readDataOnly{
  793.                             foreach ($xmlSheet->dataValidations->dataValidation as $dataValidation{
  794.                                 // Uppercase coordinate
  795.                                 $range strtoupper($dataValidation["sqref"]);
  796.  
  797.                                 // Extract all cell references in $range
  798.                                 $aReferences PHPExcel_Cell::extractAllCellReferencesInRange($range);
  799.                                 foreach ($aReferences as $reference{
  800.                                     // Create validation
  801.                                     $docValidation $docSheet->getCell($reference)->getDataValidation();
  802.                                     $docValidation->setType((string) $dataValidation["type"]);
  803.                                     $docValidation->setErrorStyle((string) $dataValidation["errorStyle"]);
  804.                                     $docValidation->setOperator((string) $dataValidation["operator"]);
  805.                                     $docValidation->setAllowBlank($dataValidation["allowBlank"!= 0);
  806.                                     $docValidation->setShowDropDown($dataValidation["showDropDown"== 0);
  807.                                     $docValidation->setShowInputMessage($dataValidation["showInputMessage"!= 0);
  808.                                     $docValidation->setShowErrorMessage($dataValidation["showErrorMessage"!= 0);
  809.                                     $docValidation->setErrorTitle((string) $dataValidation["errorTitle"]);
  810.                                     $docValidation->setError((string) $dataValidation["error"]);
  811.                                     $docValidation->setPromptTitle((string) $dataValidation["promptTitle"]);
  812.                                     $docValidation->setPrompt((string) $dataValidation["prompt"]);
  813.                                     $docValidation->setFormula1((string) $dataValidation->formula1);
  814.                                     $docValidation->setFormula2((string) $dataValidation->formula2);
  815.                                 }
  816.                             }
  817.                         }
  818.  
  819.                         // Add hyperlinks
  820.                         $hyperlinks array();
  821.                         if (!$this->_readDataOnly{
  822.                             // Locate hyperlink relations
  823.                             if ($zip->locateName(dirname("$dir/$fileWorksheet""/_rels/" basename($fileWorksheet".rels")) {
  824.                                 $relsWorksheet simplexml_load_string($zip->getFromNamedirname("$dir/$fileWorksheet""/_rels/" basename($fileWorksheet".rels") )//~ http://schemas.openxmlformats.org/package/2006/relationships");
  825.                                 foreach ($relsWorksheet->Relationship as $ele{
  826.                                     if ($ele["Type"== "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink"{
  827.                                         $hyperlinks[(string)$ele["Id"]] = (string)$ele["Target"];
  828.                                     }
  829.                                 }
  830.                             }
  831.  
  832.                             // Loop trough hyperlinks
  833.                             if ($xmlSheet->hyperlinks{
  834.                                 foreach ($xmlSheet->hyperlinks->hyperlink as $hyperlink{
  835.                                     // Link url
  836.                                     $linkRel $hyperlink->attributes('http://schemas.openxmlformats.org/officeDocument/2006/relationships');
  837.  
  838.                                     if (isset($linkRel['id'])) {
  839.                                         $docSheet->getCell$hyperlink['ref')->getHyperlink()->setUrl$hyperlinks(string)$linkRel['id'] ] );
  840.                                     }
  841.                                     if (isset($hyperlink['location'])) {
  842.                                         $docSheet->getCell$hyperlink['ref')->getHyperlink()->setUrl'sheet://' . (string)$hyperlink['location');
  843.                                     }
  844.  
  845.                                     // Tooltip
  846.                                     if (isset($hyperlink['tooltip'])) {
  847.                                         $docSheet->getCell$hyperlink['ref')->getHyperlink()->setTooltip(string)$hyperlink['tooltip');
  848.                                     }
  849.                                 }
  850.                             }
  851.                         }
  852.  
  853.                         // Add comments
  854.                         $comments array();
  855.                         $vmlComments array();
  856.                         if (!$this->_readDataOnly{
  857.                             // Locate comment relations
  858.                             if ($zip->locateName(dirname("$dir/$fileWorksheet""/_rels/" basename($fileWorksheet".rels")) {
  859.                                 $relsWorksheet simplexml_load_string($zip->getFromNamedirname("$dir/$fileWorksheet""/_rels/" basename($fileWorksheet".rels") )//~ http://schemas.openxmlformats.org/package/2006/relationships");
  860.                                 foreach ($relsWorksheet->Relationship as $ele{
  861.                                     if ($ele["Type"== "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments"{
  862.                                         $comments[(string)$ele["Id"]] = (string)$ele["Target"];
  863.                                     }
  864.                                     if ($ele["Type"== "http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing"{
  865.                                         $vmlComments[(string)$ele["Id"]] = (string)$ele["Target"];
  866.                                     }
  867.                                 }
  868.                             }
  869.  
  870.                             // Loop trough comments
  871.                         foreach ($comments as $relName => $relPath{
  872.                                 // Load comments file
  873.                                 $relPath PHPExcel_Shared_File::realpath(dirname("$dir/$fileWorksheet""/" $relPath);
  874.                                 $commentsFile simplexml_load_string($zip->getFromName($relPath) );
  875.  
  876.                                 // Utility variables
  877.                                 $authors array();
  878.  
  879.                                 // Loop trough authors
  880.                                 foreach ($commentsFile->authors->author as $author{
  881.                                     $authors[= (string)$author;
  882.                                 }
  883.  
  884.                                 // Loop trough contents
  885.                                 foreach ($commentsFile->commentList->comment as $comment{
  886.                                     $docSheet->getComment(string)$comment['ref')->setAuthor$authors[(string)$comment['authorId']] );
  887.                                     $docSheet->getComment(string)$comment['ref')->setText$this->_parseRichText($comment->text) );
  888.                                 }
  889.                             }
  890.  
  891.                             // Loop trough VML comments
  892.                             foreach ($vmlComments as $relName => $relPath{
  893.                                 // Load VML comments file
  894.                                 $relPath PHPExcel_Shared_File::realpath(dirname("$dir/$fileWorksheet""/" $relPath);
  895.                                 $vmlCommentsFile simplexml_load_string$zip->getFromName($relPath) );
  896.                                 $vmlCommentsFile->registerXPathNamespace('v''urn:schemas-microsoft-com:vml');
  897.  
  898.                                 $shapes $vmlCommentsFile->xpath('//v:shape');
  899.                                 foreach ($shapes as $shape{
  900.                                     $shape->registerXPathNamespace('v''urn:schemas-microsoft-com:vml');
  901.  
  902.                                     if (isset($shape['style'])) {
  903.                                         $style        = (string)$shape['style'];
  904.                                         $fillColor    strtouppersubstr(string)$shape['fillcolor']) );
  905.                                         $column       null;
  906.                                         $row          null;
  907.  
  908.                                         $clientData   $shape->xpath('.//x:ClientData');
  909.                                         if (is_array($clientData)) {
  910.                                             $clientData   $clientData[0];
  911.  
  912.                                             if isset($clientData['ObjectType']&& (string)$clientData['ObjectType'== 'Note' {
  913.                                                 $temp $clientData->xpath('.//x:Row');
  914.                                                 if (is_array($temp)) $row $temp[0];
  915.  
  916.                                                 $temp $clientData->xpath('.//x:Column');
  917.                                                 if (is_array($temp)) $column $temp[0];
  918.                                             }
  919.                                         }
  920.  
  921.                                         if (!is_null($column&& !is_null($row)) {
  922.                                             // Set comment properties
  923.                                             $comment $docSheet->getCommentByColumnAndRow($column$row 1);
  924.                                             $comment->getFillColor()->setRGB$fillColor );
  925.  
  926.                                             // Parse style
  927.                                             $styleArray explode(';'str_replace(' '''$style));
  928.                                             foreach ($styleArray as $stylePair{
  929.                                                 $stylePair explode(':'$stylePair);
  930.  
  931.                                                 if ($stylePair[0== 'margin-left')     $comment->setMarginLeft($stylePair[1]);
  932.                                                 if ($stylePair[0== 'margin-top')      $comment->setMarginTop($stylePair[1]);
  933.                                                 if ($stylePair[0== 'width')           $comment->setWidth($stylePair[1]);
  934.                                                 if ($stylePair[0== 'height')          $comment->setHeight($stylePair[1]);
  935.                                                 if ($stylePair[0== 'visibility')      $comment->setVisible$stylePair[1== 'visible' );
  936.  
  937.                                             }
  938.                                         }
  939.                                     }
  940.                                 }
  941.                             }
  942.  
  943.                             // Header/footer images
  944.                             if ($xmlSheet->legacyDrawingHF && !$this->_readDataOnly{
  945.                                 if ($zip->locateName(dirname("$dir/$fileWorksheet""/_rels/" basename($fileWorksheet".rels")) {
  946.                                     $relsWorksheet simplexml_load_string($zip->getFromNamedirname("$dir/$fileWorksheet""/_rels/" basename($fileWorksheet".rels") )//~ http://schemas.openxmlformats.org/package/2006/relationships");
  947.                                     $vmlRelationship '';
  948.  
  949.                                     foreach ($relsWorksheet->Relationship as $ele{
  950.                                         if ($ele["Type"== "http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing"{
  951.                                             $vmlRelationship self::dir_add("$dir/$fileWorksheet"$ele["Target"]);
  952.                                         }
  953.                                     }
  954.  
  955.                                     if ($vmlRelationship != ''{
  956.                                         // Fetch linked images
  957.                                         $relsVML simplexml_load_string($zip->getFromNamedirname($vmlRelationship'/_rels/' basename($vmlRelationship'.rels' ))//~ http://schemas.openxmlformats.org/package/2006/relationships");
  958.                                         $drawings array();
  959.                                         foreach ($relsVML->Relationship as $ele{
  960.                                             if ($ele["Type"== "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"{
  961.                                                 $drawings[(string) $ele["Id"]] self::dir_add($vmlRelationship$ele["Target"]);
  962.                                             }
  963.                                         }
  964.  
  965.                                         // Fetch VML document
  966.                                         $vmlDrawing simplexml_load_string($zip->getFromName($vmlRelationship));
  967.                                         $vmlDrawing->registerXPathNamespace('v''urn:schemas-microsoft-com:vml');
  968.  
  969.                                         $hfImages array();
  970.  
  971.                                         $shapes $vmlDrawing->xpath('//v:shape');
  972.                                         foreach ($shapes as $shape{
  973.                                             $shape->registerXPathNamespace('v''urn:schemas-microsoft-com:vml');
  974.                                             $imageData $shape->xpath('//v:imagedata');
  975.                                             $imageData $imageData[0];
  976.  
  977.                                             $imageData $imageData->attributes('urn:schemas-microsoft-com:office:office');
  978.                                             $style self::toCSSArray(string)$shape['style');
  979.  
  980.                                             $hfImages(string)$shape['id'] ] new PHPExcel_Worksheet_HeaderFooterDrawing();
  981.                                             if (isset($imageData['title'])) {
  982.                                                 $hfImages(string)$shape['id'] ]->setName(string)$imageData['title');
  983.                                             }
  984.  
  985.                                             $hfImages(string)$shape['id'] ]->setPath("zip://$pFilename#$drawings[(string)$imageData['relid']]false);
  986.                                             $hfImages(string)$shape['id'] ]->setResizeProportional(false);
  987.                                             $hfImages(string)$shape['id'] ]->setWidth($style['width']);
  988.                                             $hfImages(string)$shape['id'] ]->setHeight($style['height']);
  989.                                             $hfImages(string)$shape['id'] ]->setOffsetX($style['margin-left']);
  990.                                             $hfImages(string)$shape['id'] ]->setOffsetY($style['margin-top']);
  991.                                             $hfImages(string)$shape['id'] ]->setResizeProportional(true);
  992.                                         }
  993.  
  994.                                         $docSheet->getHeaderFooter()->setImages($hfImages);
  995.                                     }
  996.                                 }
  997.                             }
  998.  
  999.                         }
  1000.  
  1001. // TODO: Make sure drawings and graph are loaded differently!
  1002.                         if ($zip->locateName(dirname("$dir/$fileWorksheet""/_rels/" basename($fileWorksheet".rels")) {
  1003.                             $relsWorksheet simplexml_load_string($zip->getFromNamedirname("$dir/$fileWorksheet""/_rels/" basename($fileWorksheet".rels") )//~ http://schemas.openxmlformats.org/package/2006/relationships");
  1004.                             $drawings array();
  1005.                             foreach ($relsWorksheet->Relationship as $ele{
  1006.                                 if ($ele["Type"== "http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing"{
  1007.                                     $drawings[(string) $ele["Id"]] self::dir_add("$dir/$fileWorksheet"$ele["Target"]);
  1008.                                 }
  1009.                             }
  1010.                             if ($xmlSheet->drawing && !$this->_readDataOnly{
  1011.                                 foreach ($xmlSheet->drawing as $drawing{
  1012.                                     $fileDrawing $drawings[(string) self::array_item($drawing->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships")"id")];
  1013.                                     $relsDrawing simplexml_load_string($zip->getFromNamedirname($fileDrawing"/_rels/" basename($fileDrawing".rels") )//~ http://schemas.openxmlformats.org/package/2006/relationships");
  1014.                                     $images array();
  1015.  
  1016.                                     if ($relsDrawing && $relsDrawing->Relationship{
  1017.                                         foreach ($relsDrawing->Relationship as $ele{
  1018.                                             if ($ele["Type"== "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"{
  1019.                                                 $images[(string) $ele["Id"]] self::dir_add($fileDrawing$ele["Target"]);
  1020.                                             }
  1021.                                         }
  1022.                                     }
  1023.                                     $xmlDrawing simplexml_load_string($zip->getFromName($fileDrawing))->children("http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing");
  1024.  
  1025.                                     if ($xmlDrawing->oneCellAnchor{
  1026.                                         foreach ($xmlDrawing->oneCellAnchor as $oneCellAnchor{
  1027.                                             if ($oneCellAnchor->pic->blipFill{
  1028.                                                 $blip $oneCellAnchor->pic->blipFill->children("http://schemas.openxmlformats.org/drawingml/2006/main")->blip;
  1029.                                                 $xfrm $oneCellAnchor->pic->spPr->children("http://schemas.openxmlformats.org/drawingml/2006/main")->xfrm;
  1030.                                                 $outerShdw $oneCellAnchor->pic->spPr->children("http://schemas.openxmlformats.org/drawingml/2006/main")->effectLst->outerShdw;
  1031.                                                 $objDrawing new PHPExcel_Worksheet_Drawing;
  1032.                                                 $objDrawing->setName((string) self::array_item($oneCellAnchor->pic->nvPicPr->cNvPr->attributes()"name"));
  1033.                                                 $objDrawing->setDescription((string) self::array_item($oneCellAnchor->pic->nvPicPr->cNvPr->attributes()"descr"));
  1034.                                                 $objDrawing->setPath("zip://$pFilename#$images[(string) self::array_item($blip->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships")"embed")]false);
  1035.                                                 $objDrawing->setCoordinates(PHPExcel_Cell::stringFromColumnIndex($oneCellAnchor->from->col($oneCellAnchor->from->row 1));
  1036.                                                 $objDrawing->setOffsetX(PHPExcel_Shared_Drawing::EMUToPixels($oneCellAnchor->from->colOff));
  1037.                                                 $objDrawing->setOffsetY(PHPExcel_Shared_Drawing::EMUToPixels($oneCellAnchor->from->rowOff));
  1038.                                                 $objDrawing->setResizeProportional(false);
  1039.                                                 $objDrawing->setWidth(PHPExcel_Shared_Drawing::EMUToPixels(self::array_item($oneCellAnchor->ext->attributes()"cx")));
  1040.                                                 $objDrawing->setHeight(PHPExcel_Shared_Drawing::EMUToPixels(self::array_item($oneCellAnchor->ext->attributes()"cy")));
  1041.                                                 if ($xfrm{
  1042.                                                     $objDrawing->setRotation(PHPExcel_Shared_Drawing::angleToDegrees(self::array_item($xfrm->attributes()"rot")));
  1043.                                                 }
  1044.                                                 if ($outerShdw{
  1045.                                                     $shadow $objDrawing->getShadow();
  1046.                                                     $shadow->setVisible(true);
  1047.                                                     $shadow->setBlurRadius(PHPExcel_Shared_Drawing::EMUTopixels(self::array_item($outerShdw->attributes()"blurRad")));
  1048.                                                     $shadow->setDistance(PHPExcel_Shared_Drawing::EMUTopixels(self::array_item($outerShdw->attributes()"dist")));
  1049.                                                     $shadow->setDirection(PHPExcel_Shared_Drawing::angleToDegrees(self::array_item($outerShdw->attributes()"dir")));
  1050.                                                     $shadow->setAlignment((string) self::array_item($outerShdw->attributes()"algn"));
  1051.                                                     $shadow->getColor()->setRGB(self::array_item($outerShdw->srgbClr->attributes()"val"));
  1052.                                                     $shadow->setAlpha(self::array_item($outerShdw->srgbClr->alpha->attributes()"val"1000);
  1053.                                                 }
  1054.                                                 $objDrawing->setWorksheet($docSheet);
  1055.                                             }
  1056.                                         }
  1057.                                     }
  1058.                                     if ($xmlDrawing->twoCellAnchor{
  1059.                                         foreach ($xmlDrawing->twoCellAnchor as $twoCellAnchor{
  1060.                                             if ($twoCellAnchor->pic->blipFill{
  1061.                                                 $blip $twoCellAnchor->pic->blipFill->children("http://schemas.openxmlformats.org/drawingml/2006/main")->blip;
  1062.                                                 $xfrm $twoCellAnchor->pic->spPr->children("http://schemas.openxmlformats.org/drawingml/2006/main")->xfrm;
  1063.                                                 $outerShdw $twoCellAnchor->pic->spPr->children("http://schemas.openxmlformats.org/drawingml/2006/main")->effectLst->outerShdw;
  1064.                                                 $objDrawing new PHPExcel_Worksheet_Drawing;
  1065.                                                 $objDrawing->setName((string) self::array_item($twoCellAnchor->pic->nvPicPr->cNvPr->attributes()"name"));
  1066.                                                 $objDrawing->setDescription((string) self::array_item($twoCellAnchor->pic->nvPicPr->cNvPr->attributes()"descr"));
  1067.                                                 $objDrawing->setPath("zip://$pFilename#$images[(string) self::array_item($blip->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships")"embed")]false);
  1068.                                                 $objDrawing->setCoordinates(PHPExcel_Cell::stringFromColumnIndex($twoCellAnchor->from->col($twoCellAnchor->from->row 1));
  1069.                                                 $objDrawing->setOffsetX(PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->colOff));
  1070.                                                 $objDrawing->setOffsetY(PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->rowOff));
  1071.                                                 $objDrawing->setResizeProportional(false);
  1072.  
  1073.                                                 $objDrawing->setWidth(PHPExcel_Shared_Drawing::EMUToPixels(self::array_item($xfrm->ext->attributes()"cx")));
  1074.                                                 $objDrawing->setHeight(PHPExcel_Shared_Drawing::EMUToPixels(self::array_item($xfrm->ext->attributes()"cy")));
  1075.  
  1076.                                                 if ($xfrm{
  1077.                                                     $objDrawing->setRotation(PHPExcel_Shared_Drawing::angleToDegrees(self::array_item($xfrm->attributes()"rot")));
  1078.                                                 }
  1079.                                                 if ($outerShdw{
  1080.                                                     $shadow $objDrawing->getShadow();
  1081.                                                     $shadow->setVisible(true);
  1082.                                                     $shadow->setBlurRadius(PHPExcel_Shared_Drawing::EMUTopixels(self::array_item($outerShdw->attributes()"blurRad")));
  1083.                                                     $shadow->setDistance(PHPExcel_Shared_Drawing::EMUTopixels(self::array_item($outerShdw->attributes()"dist")));
  1084.                                                     $shadow->setDirection(PHPExcel_Shared_Drawing::angleToDegrees(self::array_item($outerShdw->attributes()"dir")));
  1085.                                                     $shadow->setAlignment((string) self::array_item($outerShdw->attributes()"algn"));
  1086.                                                     $shadow->getColor()->setRGB(self::array_item($outerShdw->srgbClr->attributes()"val"));
  1087.                                                     $shadow->setAlpha(self::array_item($outerShdw->srgbClr->alpha->attributes()"val"1000);
  1088.                                                 }
  1089.                                                 $objDrawing->setWorksheet($docSheet);
  1090.                                             }
  1091.                                         }
  1092.                                     }
  1093.  
  1094.                                 }
  1095.                             }
  1096.                         }
  1097.  
  1098.                         // Loop trough definedNames
  1099.                         if ($xmlWorkbook->definedNames{
  1100.                             foreach ($xmlWorkbook->definedNames->definedName as $definedName{
  1101.                                 // Extract range
  1102.                                 $extractedRange = (string)$definedName;
  1103.                                 $extractedRange preg_replace('/\'(\w+)\'\!/'''$extractedRange);
  1104.                                 $extractedRange str_replace('$'''$extractedRange);
  1105.  
  1106.                                 // Valid range?
  1107.                                 if (stripos((string)$definedName'#REF!'!== false || $extractedRange == ''{
  1108.                                     continue;
  1109.                                 }
  1110.  
  1111.                                 // Some definedNames are only applicable if we are on the same sheet...
  1112.                                 if ((string)$definedName['localSheetId'!= '' && (string)$definedName['localSheetId'== $sheetId{
  1113.                                     // Switch on type
  1114.                                     switch ((string)$definedName['name']{
  1115.  
  1116.                                         case '_xlnm._FilterDatabase':
  1117.                                             $docSheet->setAutoFilter($extractedRange);
  1118.                                             break;
  1119.  
  1120.                                         case '_xlnm.Print_Titles':
  1121.                                             // Split $extractedRange
  1122.                                             $extractedRange explode(','$extractedRange);
  1123.  
  1124.                                             // Set print titles
  1125.                                             if (isset($extractedRange[0])) {
  1126.                                                 $range explode(':'$extractedRange[0]);
  1127.  
  1128.                                                 if (PHPExcel_Worksheet::extractSheetTitle($range[0]!= '')
  1129.                                                     $range[0PHPExcel_Worksheet::extractSheetTitle($range[0]);
  1130.                                                 $range[0str_replace('$'''$range[0]);
  1131.                                                 if (PHPExcel_Worksheet::extractSheetTitle($range[1]!= '')
  1132.                                                     $range[1PHPExcel_Worksheet::extractSheetTitle($range[1]);
  1133.                                                 $range[1str_replace('$'''$range[1]);
  1134.  
  1135.                                                 $docSheet->getPageSetup()->setColumnsToRepeatAtLeft$range );
  1136.                                             }
  1137.                                             if (isset($extractedRange[1])) {
  1138.                                                 $range explode(':'$extractedRange[1]);
  1139.  
  1140.                                                 if (PHPExcel_Worksheet::extractSheetTitle($range[0]!= '')
  1141.                                                     $range[0PHPExcel_Worksheet::extractSheetTitle($range[0]);
  1142.                                                 $range[0str_replace('$'''$range[0]);
  1143.                                                 if (PHPExcel_Worksheet::extractSheetTitle($range[1]!= '')
  1144.                                                     $range[1PHPExcel_Worksheet::extractSheetTitle($range[1]);
  1145.                                                 $range[1str_replace('$'''$range[1]);
  1146.  
  1147.                                                 $docSheet->getPageSetup()->setRowsToRepeatAtTop$range );
  1148.                                             }
  1149.  
  1150.                                             break;
  1151.  
  1152.                                         case '_xlnm.Print_Area':
  1153.                                             $range explode('!'$extractedRange);
  1154.                                             $extractedRange = isset($range[1]$range[1$range[0];
  1155.  
  1156.                                             $docSheet->getPageSetup()->setPrintArea($extractedRange);
  1157.                                             break;
  1158.  
  1159.                                         default:
  1160.                                             $range explode('!'$extractedRange);
  1161.                                             $extractedRange = isset($range[1]$range[1$range[0];
  1162.                                             
  1163.                                             $excel->addNamedRangenew PHPExcel_NamedRange((string)$definedName['name']$docSheet$extractedRangetrue) );
  1164.                                             break;
  1165.                                     }
  1166.                                 else {
  1167.                                     // "Global" definedNames
  1168.                                     $locatedSheet null;
  1169.                                     $extractedSheetName '';
  1170.                                     if (strpos(string)$definedName'!' !== false{
  1171.                                         // Extract sheet name
  1172.                                         $extractedSheetName PHPExcel_Worksheet::extractSheetTitle(string)$definedNametrue );
  1173.                                         $extractedSheetName $extractedSheetName[0];
  1174.                                         
  1175.                                         // Locate sheet
  1176.                                         $locatedSheet $excel->getSheetByName($extractedSheetName);
  1177.  
  1178.                                         // Modify range
  1179.                                         $range explode('!'$extractedRange);
  1180.                                         $extractedRange = isset($range[1]$range[1$range[0];
  1181.                                     }
  1182.  
  1183.                                     if (!is_null($locatedSheet)) {
  1184.                                         $excel->addNamedRangenew PHPExcel_NamedRange((string)$definedName['name']$locatedSheet$extractedRangefalse) );
  1185.                                     }
  1186.                                 }
  1187.                             }
  1188.                         }
  1189.  
  1190.                         // Garbage collect...
  1191.                         $docSheet->garbageCollect();
  1192.  
  1193.                         // Next sheet id
  1194.                         ++$sheetId;
  1195.                     }
  1196.  
  1197.                     if (!$this->_readDataOnly{
  1198.                         $excel->setActiveSheetIndex(intval($xmlWorkbook->bookViews->workbookView["activeTab"]));
  1199.                     }
  1200.                 break;
  1201.             }
  1202.  
  1203.         }
  1204.  
  1205.         return $excel;
  1206.     }
  1207.  
  1208.     private function _readColor($color{
  1209.         if (isset($color["rgb"])) {
  1210.             return (string)$color["rgb"];
  1211.         else if (isset($color["indexed"])) {
  1212.             return PHPExcel_Style_Color::indexedColor($color["indexed"])->getARGB();
  1213.         }
  1214.     }
  1215.  
  1216.     private function _readStyle($docStyle$style{
  1217.         // format code
  1218.         if ($style->applyNumberFormat$docStyle->getNumberFormat()->setFormatCode($style->numFmt);
  1219.  
  1220.         // font
  1221.         if (isset($style->font&& ($style->applyFont || $style instanceof SimpleXMLElement)) {
  1222.             $docStyle->getFont()->setName((string) $style->font->name["val"]);
  1223.             $docStyle->getFont()->setSize((string) $style->font->sz["val"]);
  1224.             if (isset($style->font->b)) {
  1225.                 $docStyle->getFont()->setBold(!isset($style->font->b["val"]|| $style->font->b["val"== 'true');
  1226.             }
  1227.             if (isset($style->font->i)) {
  1228.                 $docStyle->getFont()->setItalic(!isset($style->font->i["val"]|| $style->font->i["val"== 'true');
  1229.             }
  1230.             if (isset($style->font->strike)) {
  1231.                 $docStyle->getFont()->setStrikethrough(!isset($style->font->strike["val"]|| $style->font->strike["val"== 'true');
  1232.             }
  1233.             $docStyle->getFont()->getColor()->setARGB($this->_readColor($style->font->color));
  1234.  
  1235.             if (isset($style->font->u&& !isset($style->font->u["val"])) {
  1236.                 $docStyle->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLE);
  1237.             else if (isset($style->font->u&& isset($style->font->u["val"])) {
  1238.                 $docStyle->getFont()->setUnderline((string)$style->font->u["val"]);
  1239.             }
  1240.  
  1241.             if (isset($style->font->vertAlign&& isset($style->font->vertAlign["val"])) {
  1242.                 $vertAlign strtolower((string)$style->font->vertAlign["val"]);
  1243.                 if ($vertAlign == 'superscript'{
  1244.                     $docStyle->getFont()->setSuperScript(true);
  1245.                 }
  1246.                 if ($vertAlign == 'subscript'{
  1247.                     $docStyle->getFont()->setSubScript(true);
  1248.                 }
  1249.             }
  1250.         }
  1251.  
  1252.         // fill
  1253.         if (isset($style->fill&& ($style->applyFill || $style instanceof SimpleXMLElement)) {
  1254.             if ($style->fill->gradientFill{
  1255.                 $gradientFill $style->fill->gradientFill[0];
  1256.                 $docStyle->getFill()->setFillType((string) $gradientFill["type"]);
  1257.                 $docStyle->getFill()->setRotation(floatval($gradientFill["degree"]));
  1258.                 $gradientFill->registerXPathNamespace("sml""http://schemas.openxmlformats.org/spreadsheetml/2006/main");
  1259.                 $docStyle->getFill()->getStartColor()->setARGB($this->_readColorself::array_item($gradientFill->xpath("sml:stop[@position=0]"))->color) );
  1260.                 $docStyle->getFill()->getEndColor()->setARGB($this->_readColorself::array_item($gradientFill->xpath("sml:stop[@position=1]"))->color) );
  1261.             elseif ($style->fill->patternFill{
  1262.                 $patternType = (string)$style->fill->patternFill["patternType"!= '' ? (string)$style->fill->patternFill["patternType"'solid';
  1263.                 $docStyle->getFill()->setFillType($patternType);
  1264.                 if ($style->fill->patternFill->fgColor{
  1265.                     $docStyle->getFill()->getStartColor()->setARGB($this->_readColor($style->fill->patternFill->fgColor));
  1266.                 else {
  1267.                     $docStyle->getFill()->getStartColor()->setARGB('FF000000');
  1268.                 }
  1269.                 if ($style->fill->patternFill->bgColor{
  1270.                     $docStyle->getFill()->getEndColor()->setARGB($this->_readColor($style->fill->patternFill->bgColor));
  1271.                 }
  1272.             }
  1273.         }
  1274.  
  1275.         // border
  1276.         if (isset($style->border&& ($style->applyBorder || $style instanceof SimpleXMLElement)) {
  1277.             if ($style->border["diagonalUp"== 'true'{
  1278.                 $docStyle->getBorders()->setDiagonalDirection(PHPExcel_Style_Borders::DIAGONAL_UP);
  1279.             elseif ($style->border["diagonalDown"== 'true'{
  1280.                 $docStyle->getBorders()->setDiagonalDirection(PHPExcel_Style_Borders::DIAGONAL_DOWN);
  1281.             }
  1282.             $docStyle->getBorders()->setOutline($style->border["outline"== 'true');
  1283.             $this->_readBorder($docStyle->getBorders()->getLeft()$style->border->left);
  1284.             $this->_readBorder($docStyle->getBorders()->getRight()$style->border->right);
  1285.             $this->_readBorder($docStyle->getBorders()->getTop()$style->border->top);
  1286.             $this->_readBorder($docStyle->getBorders()->getBottom()$style->border->bottom);
  1287.             $this->_readBorder($docStyle->getBorders()->getDiagonal()$style->border->diagonal);
  1288.             $this->_readBorder($docStyle->getBorders()->getVertical()$style->border->vertical);
  1289.             $this->_readBorder($docStyle->getBorders()->getHorizontal()$style->border->horizontal);
  1290.         }
  1291.  
  1292.         // alignment
  1293.         if (isset($style->alignment&& ($style->applyAlignment || $style instanceof SimpleXMLElement)) {
  1294.             $docStyle->getAlignment()->setHorizontal((string) $style->alignment["horizontal"]);
  1295.             $docStyle->getAlignment()->setVertical((string) $style->alignment["vertical"]);
  1296.  
  1297.             $textRotation 0;
  1298.             if ((int)$style->alignment["textRotation"<= 90{
  1299.                 $textRotation = (int)$style->alignment["textRotation"];
  1300.             else if ((int)$style->alignment["textRotation"90{
  1301.                 $textRotation 90 - (int)$style->alignment["textRotation"];
  1302.             }
  1303.  
  1304.             $docStyle->getAlignment()->setTextRotation(intval($textRotation));
  1305.             $docStyle->getAlignment()->setWrapText(string)$style->alignment["wrapText"== "true" || (string)$style->alignment["wrapText"== "1" );
  1306.             $docStyle->getAlignment()->setShrinkToFit(string)$style->alignment["shrinkToFit"== "true" || (string)$style->alignment["shrinkToFit"== "1" );
  1307.             $docStyle->getAlignment()->setIndentintval((string)$style->alignment["indent"]intval((string)$style->alignment["indent"]);
  1308.         }
  1309.  
  1310.         // protection
  1311.         if (isset($style->protection&& $style->applyProtection{
  1312.             if (isset($style->protection['locked'])) {
  1313.                 if ((string)$style->protection['locked'== 'true'{
  1314.                     $docStyle->getProtection()->setLocked(PHPExcel_Style_Protection::PROTECTION_PROTECTED);
  1315.                 else {
  1316.                     $docStyle->getProtection()->setLocked(PHPExcel_Style_Protection::PROTECTION_UNPROTECTED);
  1317.                 }
  1318.             }
  1319.  
  1320.             if (isset($style->protection['hidden'])) {
  1321.                 if ((string)$style->protection['hidden'== 'true'{
  1322.                     $docStyle->getProtection()->setHidden(PHPExcel_Style_Protection::PROTECTION_PROTECTED);
  1323.                 else {
  1324.                     $docStyle->getProtection()->setHidden(PHPExcel_Style_Protection::PROTECTION_UNPROTECTED);
  1325.                 }
  1326.             }
  1327.         }
  1328.     }
  1329.  
  1330.     private function _readBorder($docBorder$eleBorder{
  1331.         if (isset($eleBorder["style"])) {
  1332.             $docBorder->setBorderStyle((string) $eleBorder["style"]);
  1333.         }
  1334.         if (isset($eleBorder->color)) {
  1335.             $docBorder->getColor()->setARGB($this->_readColor($eleBorder->color));
  1336.         }
  1337.     }
  1338.  
  1339.     private function _parseRichText($is null{
  1340.         $value new PHPExcel_RichText();
  1341.  
  1342.         if (isset($is->t)) {
  1343.             $value->createTextPHPExcel_Shared_String::ControlCharacterOOXML2PHP(string) $is->) );
  1344.         else {
  1345.             foreach ($is->as $run{
  1346.                 $objText $value->createTextRunPHPExcel_Shared_String::ControlCharacterOOXML2PHP(string) $run->) );
  1347.  
  1348.                 if (isset($run->rPr)) {
  1349.                     if (isset($run->rPr->rFont["val"])) {
  1350.                         $objText->getFont()->setName((string) $run->rPr->rFont["val"]);
  1351.                     }
  1352.  
  1353.                     if (isset($run->rPr->sz["val"])) {
  1354.                         $objText->getFont()->setSize((string) $run->rPr->sz["val"]);
  1355.                     }
  1356.  
  1357.                     if (isset($run->rPr->color)) {
  1358.                         $objText->getFont()->setColornew PHPExcel_Style_Color$this->_readColor($run->rPr->color) ) );
  1359.                     }
  1360.  
  1361.                     if ( (isset($run->rPr->b["val"]&& ((string) $run->rPr->b["val"== 'true' || (string) $run->rPr->b["val"== '1'))
  1362.                          || (isset($run->rPr->b&& !isset($run->rPr->b["val"])) ) {
  1363.                         $objText->getFont()->setBold(true);
  1364.                     }
  1365.  
  1366.                     if ( (isset($run->rPr->i["val"]&& ((string) $run->rPr->i["val"== 'true' || (string) $run->rPr->i["val"== '1'))
  1367.                          || (isset($run->rPr->i&& !isset($run->rPr->i["val"])) ) {
  1368.                         $objText->getFont()->setItalic(true);
  1369.                     }
  1370.  
  1371.                     if (isset($run->rPr->vertAlign&& isset($run->rPr->vertAlign["val"])) {
  1372.                         $vertAlign strtolower((string)$run->rPr->vertAlign["val"]);
  1373.                         if ($vertAlign == 'superscript'{
  1374.                             $objText->getFont()->setSuperScript(true);
  1375.                         }
  1376.                         if ($vertAlign == 'subscript'{
  1377.                             $objText->getFont()->setSubScript(true);
  1378.                         }
  1379.                     }
  1380.  
  1381.                     if (isset($run->rPr->u&& !isset($run->rPr->u["val"])) {
  1382.                         $objText->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLE);
  1383.                     else if (isset($run->rPr->u&& isset($run->rPr->u["val"])) {
  1384.                         $objText->getFont()->setUnderline((string)$run->rPr->u["val"]);
  1385.                     }
  1386.  
  1387.                     if ( (isset($run->rPr->strike["val"])  && ((string) $run->rPr->strike["val"== 'true' || (string) $run->rPr->strike["val"== '1'))
  1388.                          || (isset($run->rPr->strike&& !isset($run->rPr->strike["val"])) ) {
  1389.                         $objText->getFont()->setStrikethrough(true);
  1390.                     }
  1391.                 }
  1392.             }
  1393.         }
  1394.  
  1395.         return $value;
  1396.     }
  1397.  
  1398.     private static function array_item($array$key 0{
  1399.         return (isset($array[$key]$array[$keynull);
  1400.     }
  1401.  
  1402.     private static function dir_add($base$add{
  1403.         return preg_replace('~[^/]+/\.\./~'''dirname($base"/$add");
  1404.     }
  1405.  
  1406.     private static function toCSSArray($style{
  1407.         $style str_replace("\r"""$style);
  1408.         $style str_replace("\n"""$style);
  1409.  
  1410.         $temp explode(';'$style);
  1411.  
  1412.         $style array();
  1413.         foreach ($temp as $item{
  1414.             $item explode(':'$item);
  1415.  
  1416.             if (strpos($item[1]'px'!== false{
  1417.                 $item[1str_replace('px'''$item[1]);
  1418.             }
  1419.             if (strpos($item[1]'pt'!== false{
  1420.                 $item[1str_replace('pt'''$item[1]);
  1421.                 $item[1PHPExcel_Shared_Font::fontSizeToPixels($item[1]);
  1422.             }
  1423.             if (strpos($item[1]'in'!== false{
  1424.                 $item[1str_replace('in'''$item[1]);
  1425.                 $item[1PHPExcel_Shared_Font::inchSizeToPixels($item[1]);
  1426.             }
  1427.             if (strpos($item[1]'cm'!== false{
  1428.                 $item[1str_replace('cm'''$item[1]);
  1429.                 $item[1PHPExcel_Shared_Font::centimeterSizeToPixels($item[1]);
  1430.             }
  1431.  
  1432.             $style[$item[0]] $item[1];
  1433.         }
  1434.  
  1435.         return $style;
  1436.     }
  1437. }

Documentation generated on Wed, 22 Apr 2009 08:58:09 +0200 by phpDocumentor 1.4.1