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

Source for file Excel5.php

Documentation is available at Excel5.php

  1. <?php
  2. /**
  3.  * PHPExcel
  4.  *
  5.  * Copyright (c) 2006 - 2010 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_Writer_Excel5
  23.  * @copyright  Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
  24.  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL
  25.  * @version    1.7.3c, 2010-06-01
  26.  */
  27.  
  28.  
  29. /**
  30.  * PHPExcel_Writer_Excel5
  31.  *
  32.  * @category   PHPExcel
  33.  * @package    PHPExcel_Writer_Excel5
  34.  * @copyright  Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
  35.  */
  36. class PHPExcel_Writer_Excel5 implements PHPExcel_Writer_IWriter
  37. {
  38.     /**
  39.      * Pre-calculate formulas
  40.      *
  41.      * @var boolean 
  42.      */
  43.     private $_preCalculateFormulas;
  44.  
  45.     /**
  46.      * PHPExcel object
  47.      *
  48.      * @var PHPExcel 
  49.      */
  50.     private $_phpExcel;
  51.  
  52.     /**
  53.      * The BIFF version of the written Excel file, BIFF5 = 0x0500, BIFF8 = 0x0600
  54.      *
  55.      * @var integer 
  56.      */
  57.     private $_BIFF_version;
  58.  
  59.     /**
  60.      * Total number of shared strings in workbook
  61.      *
  62.      * @var int 
  63.      */
  64.     private $_str_total;
  65.  
  66.     /**
  67.      * Number of unique shared strings in workbook
  68.      *
  69.      * @var int 
  70.      */
  71.     private $_str_unique;
  72.  
  73.     /**
  74.      * Array of unique shared strings in workbook
  75.      *
  76.      * @var array 
  77.      */
  78.     private $_str_table;
  79.  
  80.     /**
  81.      * Color cache. Mapping between RGB value and color index.
  82.      *
  83.      * @var array 
  84.      */
  85.     private $_colors;
  86.  
  87.     /**
  88.      * Formula parser
  89.      *
  90.      * @var PHPExcel_Writer_Excel5_Parser 
  91.      */
  92.     private $_parser;
  93.  
  94.  
  95.     /**
  96.      * Create a new PHPExcel_Writer_Excel5
  97.      *
  98.      * @param    PHPExcel    $phpExcel    PHPExcel object
  99.      */
  100.     public function __construct(PHPExcel $phpExcel{
  101.         $this->_preCalculateFormulas true;
  102.         $this->_phpExcel        $phpExcel;
  103.         $this->_BIFF_version    0x0600;
  104.  
  105.         $this->_str_total       0;
  106.         $this->_str_unique      0;
  107.         $this->_str_table       array();
  108.         $this->_parser          new PHPExcel_Writer_Excel5_Parser($this->_BIFF_version);
  109.  
  110.     }
  111.  
  112.     /**
  113.      * Save PHPExcel to file
  114.      *
  115.      * @param    string        $pFileName 
  116.      * @throws    Exception
  117.      */
  118.     public function save($pFilename null{
  119.  
  120.         // garbage collect
  121.         $this->_phpExcel->garbageCollect();
  122.  
  123.         $saveDateReturnType PHPExcel_Calculation_Functions::getReturnDateType();
  124.  
  125.         // initialize colors array
  126.         $this->_colors          array();
  127.  
  128.         // Initialise workbook writer
  129.         $this->_writerWorkbook new PHPExcel_Writer_Excel5_Workbook($this->_phpExcel$this->_BIFF_version,
  130.                     $this->_str_total$this->_str_unique$this->_str_table$this->_colors$this->_parser);
  131.  
  132.         // add 15 identical cell style Xfs
  133.         // for now, we use the first cellXf instead of cellStyleXf
  134.         $cellXfCollection $this->_phpExcel->getCellXfCollection();
  135.         for ($i 0$i 15++$i{
  136.             $this->_writerWorkbook->addXfWriter($cellXfCollection[0]true);
  137.         }
  138.  
  139.         // add all the cell Xfs
  140.         foreach ($this->_phpExcel->getCellXfCollection(as $style{
  141.             $this->_writerWorkbook->addXfWriter($stylefalse);
  142.         }
  143.  
  144.         // initialize OLE file
  145.         $workbookStreamName ($this->_BIFF_version == 0x0600'Workbook' 'Book';
  146.         $OLE new PHPExcel_Shared_OLE_PPS_File(PHPExcel_Shared_OLE::Asc2Ucs($workbookStreamName));
  147.  
  148.         // Initialise worksheet writers
  149.         $countSheets $this->_phpExcel->getSheetCount();
  150.         // Write the worksheet streams before the global workbook stream,
  151.         // because the byte sizes of these are needed in the global workbook stream
  152.         $worksheetSizes array();
  153.         for ($i 0$i $countSheets++$i{
  154.             $this->_writerWorksheets[$inew PHPExcel_Writer_Excel5_Worksheet($this->_BIFF_version,
  155.                                        $this->_str_total$this->_str_unique,
  156.                                        $this->_str_table$this->_colors,
  157.                                        $this->_parser,
  158.                                        $this->_preCalculateFormulas,
  159.                                        $this->_phpExcel->getSheet($i));
  160.  
  161.             $this->_writerWorksheets[$i]->close();
  162.             $worksheetSizes[$this->_writerWorksheets[$i]->_datasize;
  163.         }
  164.  
  165.         // add binary data for global workbook stream
  166.         $OLE->append$this->_writerWorkbook->writeWorkbook($worksheetSizes) );
  167.  
  168.         // add binary data for sheet streams
  169.         for ($i 0$i $countSheets++$i{
  170.             $OLE->append($this->_writerWorksheets[$i]->getData());
  171.         }
  172.  
  173.         $root new PHPExcel_Shared_OLE_PPS_Root(time()time()array($OLE));
  174.         // save the OLE file
  175.         $res $root->save($pFilename);
  176.  
  177.         PHPExcel_Calculation_Functions::setReturnDateType($saveDateReturnType);
  178.     }
  179.  
  180.     /**
  181.      * Set temporary storage directory
  182.      *
  183.      * @deprecated
  184.      * @param    string    $pValue        Temporary storage directory
  185.      * @throws    Exception    Exception when directory does not exist
  186.      * @return PHPExcel_Writer_Excel5 
  187.      */
  188.     public function setTempDir($pValue ''{
  189.         return $this;
  190.     }
  191.  
  192.     /**
  193.      * Get Pre-Calculate Formulas
  194.      *
  195.      * @return boolean 
  196.      */
  197.     public function getPreCalculateFormulas({
  198.         return $this->_preCalculateFormulas;
  199.     }
  200.  
  201.     /**
  202.      * Set Pre-Calculate Formulas
  203.      *
  204.      * @param boolean $pValue    Pre-Calculate Formulas?
  205.      */
  206.     public function setPreCalculateFormulas($pValue true{
  207.         $this->_preCalculateFormulas $pValue;
  208.     }
  209.  
  210. }

Documentation generated on Tue, 01 Jun 2010 17:03:34 +0200 by phpDocumentor 1.4.3