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

Source for file Excel5.php

Documentation is available at Excel5.php

  1. <?php
  2. /**
  3.  * PHPExcel
  4.  *
  5.  * Copyright (c) 2006 - 2008 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
  23.  * @copyright  Copyright (c) 2006 - 2008 PHPExcel (http://www.codeplex.com/PHPExcel)
  24.  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL
  25.  * @version    1.6.4, 2008-10-27
  26.  */
  27.  
  28.  
  29. /** PHPExcel_IWriter */
  30. require_once 'PHPExcel/Writer/IWriter.php';
  31.  
  32. /** PHPExcel_Cell */
  33. require_once 'PHPExcel/Cell.php';
  34.  
  35. /** PHPExcel_Writer_Excel5_Writer */
  36. require_once 'PHPExcel/Writer/Excel5/Writer.php';
  37.  
  38. /** PHPExcel_RichText */
  39. require_once 'PHPExcel/RichText.php';
  40.  
  41.  
  42. /**
  43.  * PHPExcel_Writer_Excel5
  44.  *
  45.  * @category   PHPExcel
  46.  * @package    PHPExcel_Writer
  47.  * @copyright  Copyright (c) 2006 - 2008 PHPExcel (http://www.codeplex.com/PHPExcel)
  48.  */
  49. class PHPExcel_Writer_Excel5 implements PHPExcel_Writer_IWriter {
  50.     /**
  51.      * PHPExcel object
  52.      *
  53.      * @var PHPExcel 
  54.      */
  55.     private $_phpExcel;
  56.  
  57.     /**
  58.      * Temporary storage directory
  59.      *
  60.      * @var string 
  61.      */
  62.     private $_tempDir = '';
  63.  
  64.     /**
  65.      * Color cache
  66.      */
  67.     private $_colors = array();
  68.  
  69.     /**
  70.      * Create a new PHPExcel_Writer_Excel5
  71.      *
  72.      * @param    PHPExcel    $phpExcel    PHPExcel object
  73.      */
  74.     public function __construct(PHPExcel $phpExcel{
  75.         $this->_phpExcel    = $phpExcel;
  76.         $this->_tempDir        = '';
  77.         $this->_colors        = array();
  78.     }
  79.  
  80.     /**
  81.      * Save PHPExcel to file
  82.      *
  83.      * @param    string        $pFileName 
  84.      * @throws    Exception
  85.      */
  86.     public function save($pFilename null{
  87.         $this->_colors        = array();
  88.  
  89.         $phpExcel $this->_phpExcel;
  90.         $workbook new PHPExcel_Writer_Excel5_Writer($pFilename);
  91.         $workbook->setVersion(8);
  92.  
  93.         // Set temp dir
  94.         if ($this->_tempDir != ''{
  95.             $workbook->setTempDir($this->_tempDir);
  96.         }
  97.  
  98.         $saveDateReturnType PHPExcel_Calculation_Functions::getReturnDateType();
  99.  
  100.         // Add empty sheets
  101.         foreach ($phpExcel->getSheetNames(as $sheetIndex => $sheetName{
  102.             $phpSheet  $phpExcel->getSheet($sheetIndex);
  103.             $worksheet $workbook->addWorksheet($sheetName);
  104.         }
  105.         $allWorksheets $workbook->worksheets();
  106.  
  107.         // Add full sheet data
  108.         foreach ($phpExcel->getSheetNames(as $sheetIndex => $sheetName{
  109.             $phpSheet  $phpExcel->getSheet($sheetIndex);
  110.             $worksheet $allWorksheets[$sheetIndex];
  111.             $worksheet->setInputEncoding("UTF-8");
  112.  
  113.             // Default style
  114.             $emptyStyle $phpSheet->getDefaultStyle();
  115.  
  116.             $aStyles $phpSheet->getStyles();
  117.  
  118.             $freeze $phpSheet->getFreezePane();
  119.             if ($freeze{
  120.                 list($column$rowPHPExcel_Cell::coordinateFromString($freeze);
  121.                 $worksheet->freezePanes(array($row 1PHPExcel_Cell::columnIndexFromString($column1));
  122.             }
  123.  
  124.             //if ($sheetIndex == $phpExcel->getActiveSheetIndex()) {
  125.                 // $worksheet->select();
  126.             //}
  127.  
  128.             if ($phpSheet->getProtection()->getSheet()) {
  129.                 $worksheet->protect($phpSheet->getProtection()->getPassword()true);
  130.             }
  131.  
  132.             if (!$phpSheet->getShowGridlines()) {
  133.                 $worksheet->hideGridLines();
  134.             }
  135.  
  136.             // initialize first, last, row and column index, needed for DIMENSION record
  137.             $firstRowIndex 0;
  138.             $lastRowIndex = -1;
  139.             $firstColumnIndex 0;
  140.             $lastColumnIndex = -1;
  141.  
  142.             $formats array();
  143.  
  144.             foreach ($phpSheet->getCellCollection(as $cell{
  145.                 $row $cell->getRow(1;
  146.                 $column PHPExcel_Cell::columnIndexFromString($cell->getColumn()) 1;
  147.  
  148.                 // Don't break Excel!
  149.                 if ($row >= 65569{
  150.                     break;
  151.                 }
  152.  
  153.                 $firstRowIndex min($firstRowIndex$row);
  154.                 $lastRowIndex max($lastRowIndex$row);
  155.                 $firstColumnIndex min($firstColumnIndex$column);
  156.                 $lastColumnIndex max($lastColumnIndex$column);
  157.  
  158.                 $style $emptyStyle;
  159.                 if (isset($aStyles[$cell->getCoordinate()])) {
  160.                     $style $aStyles[$cell->getCoordinate()];
  161.                 }
  162.                 $styleHash $style->getHashCode();
  163.  
  164.                 if (!isset($formats[$styleHash])) {
  165.                     $formats[$styleHash$workbook->addFormat(array(
  166.                         'HAlign' => $style->getAlignment()->getHorizontal(),
  167.                         'VAlign' => $this->_mapVAlign($style->getAlignment()->getVertical()),
  168.                         'TextRotation' => $style->getAlignment()->getTextRotation(),
  169.  
  170.                         'Bold' => $style->getFont()->getBold(),
  171.                         'FontFamily' => $style->getFont()->getName(),
  172.                         'Color' => $this->_addColor($workbook$style->getFont()->getColor()->getRGB()),
  173.                         'Underline' => $this->_mapUnderline($style->getFont()->getUnderline()),
  174.                         'Size' => $style->getFont()->getSize(),
  175.                         //~ 'Script' => $style->getSuperscript(),
  176.  
  177.                         'NumFormat' => $style->getNumberFormat()->getFormatCode(),
  178.  
  179.                         'Bottom' => $this->_mapBorderStyle($style->getBorders()->getBottom()->getBorderStyle()),
  180.                         'Top' => $this->_mapBorderStyle($style->getBorders()->getTop()->getBorderStyle()),
  181.                         'Left' => $this->_mapBorderStyle($style->getBorders()->getLeft()->getBorderStyle()),
  182.                         'Right' => $this->_mapBorderStyle($style->getBorders()->getRight()->getBorderStyle()),
  183.                         'BottomColor' => $this->_addColor($workbook$style->getBorders()->getBottom()->getColor()->getRGB()),
  184.                         'TopColor' => $this->_addColor($workbook$style->getBorders()->getTop()->getColor()->getRGB()),
  185.                         'RightColor' => $this->_addColor($workbook$style->getBorders()->getRight()->getColor()->getRGB()),
  186.                         'LeftColor' => $this->_addColor($workbook$style->getBorders()->getLeft()->getColor()->getRGB()),
  187.  
  188.                         'FgColor' => $this->_addColor($workbook$style->getFill()->getStartColor()->getRGB()),
  189.                         'BgColor' => $this->_addColor($workbook$style->getFill()->getEndColor()->getRGB()),
  190.                         'Pattern' => $this->_mapFillType($style->getFill()->getFillType()),
  191.  
  192.                     ));
  193.                     if ($style->getAlignment()->getWrapText()) {
  194.                         $formats[$styleHash]->setTextWrap();
  195.                     }
  196.                     $formats[$styleHash]->setIndent($style->getAlignment()->getIndent());
  197.                     if ($style->getAlignment()->getShrinkToFit()) {
  198.                         $formats[$styleHash]->setShrinkToFit();
  199.                     }
  200.                     if ($style->getFont()->getItalic()) {
  201.                         $formats[$styleHash]->setItalic();
  202.                     }
  203.                     if ($style->getFont()->getStriketrough()) {
  204.                         $formats[$styleHash]->setStrikeOut();
  205.                     }
  206.                     if ($style->getProtection()->getLocked(== PHPExcel_Style_Protection::PROTECTION_UNPROTECTED{
  207.                         $formats[$styleHash]->setUnlocked();
  208.                     }
  209.                     if ($style->getProtection()->getHidden(== PHPExcel_Style_Protection::PROTECTION_PROTECTED{
  210.                         $formats[$styleHash]->setHidden();
  211.                     }
  212.                 }
  213.  
  214.                 // Write cell value
  215.                 if ($cell->getValue(instanceof PHPExcel_RichText{
  216.                     $worksheet->write($row$column$cell->getValue()->getPlainText()$formats[$styleHash]);
  217.                 else {
  218.                     switch ($cell->getDatatype()) {
  219.  
  220.                     case PHPExcel_Cell_DataType::TYPE_STRING:
  221.                         if ($cell->getValue(=== '' or $cell->getValue(=== null{
  222.                             $worksheet->writeBlank($row$column$formats[$styleHash]);
  223.                         else {
  224.                             $worksheet->writeString($row$column$cell->getValue()$formats[$styleHash]);
  225.                         }
  226.                         break;
  227.  
  228.                     case PHPExcel_Cell_DataType::TYPE_FORMULA:
  229.                         $worksheet->writeFormula($row$column$cell->getValue()$formats[$styleHash]);
  230.                         break;
  231.  
  232.                     case PHPExcel_Cell_DataType::TYPE_BOOL:
  233.                         $worksheet->writeBoolErr($row$column$cell->getValue()0$formats[$styleHash]);
  234.                         break;
  235.  
  236.                     case PHPExcel_Cell_DataType::TYPE_ERROR:
  237.                         $worksheet->writeBoolErr($row$column$this->_mapErrorCode($cell->getValue())1$formats[$styleHash]);
  238.                         break;
  239.  
  240.                     default:
  241.                         $worksheet->write($row$column$cell->getValue()$formats[$styleHash]$style->getNumberFormat()->getFormatCode());
  242.                         break;
  243.                     }
  244.  
  245.                     // Hyperlink?
  246.                     if ($cell->hasHyperlink()) {
  247.                         $worksheet->writeUrl($row$columnstr_replace('sheet://''internal:'$cell->getHyperlink()->getUrl()));
  248.                     }
  249.                 }
  250.             }
  251.  
  252.             // set the worksheet dimension for the DIMENSION record
  253.             $worksheet->setDimensions($firstRowIndex$lastRowIndex$firstColumnIndex$lastColumnIndex);
  254.  
  255.             $phpSheet->calculateColumnWidths();
  256.  
  257.             // Default column width
  258.             if ($phpSheet->getDefaultColumnDimension()->getWidth(>= 0{
  259.                 $worksheet->setDefColWidth((int) $phpSheet->getDefaultColumnDimension()->getWidth());
  260.             }
  261.  
  262.             // Column dimensions
  263.             foreach ($phpSheet->getColumnDimensions(as $columnDimension{
  264.                 $column PHPExcel_Cell::columnIndexFromString($columnDimension->getColumnIndex()) 1;
  265.                 if ($columnDimension->getWidth(>= 0{
  266.                     $width $columnDimension->getWidth();
  267.                 else if ($phpSheet->getDefaultColumnDimension()->getWidth(>= 0{
  268.                     $width $phpSheet->getDefaultColumnDimension()->getWidth();
  269.                 else {
  270.                     $width 8;
  271.                 }
  272.                 $worksheet->setColumn$column$column$widthnull($columnDimension->getVisible('0' '1')$columnDimension->getOutlineLevel());
  273.             }
  274.  
  275.             // Default row dimension
  276.             if ($phpSheet->getDefaultRowDimension()->getRowHeight(>= 0{
  277.                 // set default row height in twips = 1/20 point
  278.                 $worksheet->setDefaultRowHeight((int) 20 $phpSheet->getDefaultRowDimension()->getRowHeight());
  279.             }
  280.  
  281.             // Row dimensions
  282.             foreach ($phpSheet->getRowDimensions(as $rowDimension{
  283.                 $worksheet->setRow$rowDimension->getRowIndex(1$rowDimension->getRowHeight()null($rowDimension->getVisible('0' '1')$rowDimension->getOutlineLevel() );
  284.             }
  285.  
  286.             foreach ($phpSheet->getMergeCells(as $cells{
  287.                 list($first$lastPHPExcel_Cell::splitRange($cells);
  288.                 list($firstColumn$firstRowPHPExcel_Cell::coordinateFromString($first);
  289.                 list($lastColumn$lastRowPHPExcel_Cell::coordinateFromString($last);
  290.                 $worksheet->mergeCells($firstRow 1PHPExcel_Cell::columnIndexFromString($firstColumn1$lastRow 1PHPExcel_Cell::columnIndexFromString($lastColumn1);
  291.             }
  292.  
  293.             foreach ($phpSheet->getDrawingCollection(as $drawing{
  294.                 if ($drawing instanceof PHPExcel_Worksheet_BaseDrawing{
  295.                     $filename $drawing->getPath();
  296.                     $imagesize getimagesize($filename);
  297.                     switch ($imagesize[2]{
  298.                         case 1$image imagecreatefromgif($filename)break;
  299.                         case 2$image imagecreatefromjpeg($filename)break;
  300.                         case 3$image imagecreatefrompng($filename)break;
  301.                         defaultcontinue 2;
  302.                     }
  303.                     list($column$rowPHPExcel_Cell::coordinateFromString($drawing->getCoordinates());
  304.                     $worksheet->insertBitmap($row 1PHPExcel_Cell::columnIndexFromString($column1$image$drawing->getOffsetX()$drawing->getOffsetY()$drawing->getWidth($imagesize[0]$drawing->getHeight($imagesize[1]);
  305.                 }
  306.             }
  307.  
  308.             // page setup
  309.             if ($phpSheet->getPageSetup()->getOrientation(== PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE{
  310.                 $worksheet->setLandscape();
  311.             }
  312.             $worksheet->setPaper($phpSheet->getPageSetup()->getPaperSize());
  313.             $worksheet->setHeader($phpSheet->getHeaderFooter()->getOddHeader()$phpSheet->getPageMargins()->getHeader());
  314.             $worksheet->setFooter($phpSheet->getHeaderFooter()->getOddFooter()$phpSheet->getPageMargins()->getFooter());
  315.             if ($phpSheet->getPageSetup()->getHorizontalCentered()) {
  316.                 $worksheet->centerHorizontally();
  317.             }
  318.             if ($phpSheet->getPageSetup()->getVerticalCentered()) {
  319.                 $worksheet->centerVertically();
  320.             }
  321.             $worksheet->setMarginLeft($phpSheet->getPageMargins()->getLeft());
  322.             $worksheet->setMarginRight($phpSheet->getPageMargins()->getRight());
  323.             $worksheet->setMarginTop($phpSheet->getPageMargins()->getTop());
  324.             $worksheet->setMarginBottom($phpSheet->getPageMargins()->getBottom());
  325.  
  326.             // Uncommented again: should now be fixed
  327.             // -------------------------------------------------------------------
  328.             // Commented due to bug:
  329.             // http://pear.php.net/bugs/bug.php?id=2146
  330.             // -------------------------------------------------------------------
  331.             // repeatColumns / repeatRows
  332.             if ($phpSheet->getPageSetup()->isColumnsToRepeatAtLeftSet(|| $phpSheet->getPageSetup()->isRowsToRepeatAtTopSet()) {
  333.                 // Columns to repeat
  334.                 if ($phpSheet->getPageSetup()->isColumnsToRepeatAtLeftSet()) {
  335.                     $repeat $phpSheet->getPageSetup()->getColumnsToRepeatAtLeft();
  336.                     $worksheet->repeatColumns(PHPExcel_Cell::columnIndexFromString($repeat[0]1PHPExcel_Cell::columnIndexFromString($repeat[1]1);
  337.                 }
  338.                 // Rows to repeat
  339.                 if ($phpSheet->getPageSetup()->isRowsToRepeatAtTopSet()) {
  340.                     $repeat $phpSheet->getPageSetup()->getRowsToRepeatAtTop();
  341.                     $worksheet->repeatRows($repeat[01$repeat[11);
  342.                 }
  343.             }
  344.  
  345.             // Uncommented again: should now be fixed
  346.             // -------------------------------------------------------------------
  347.             // Commented due to bug:
  348.             // http://pear.php.net/bugs/bug.php?id=2146
  349.             // -------------------------------------------------------------------
  350.             if ($phpSheet->getPageSetup()->isPrintAreaSet()) {
  351.                 // Print area
  352.                 $printArea PHPExcel_Cell::splitRange($phpSheet->getPageSetup()->getPrintArea());
  353.                 $printArea[0PHPExcel_Cell::coordinateFromString($printArea[0]);
  354.                 $printArea[1PHPExcel_Cell::coordinateFromString($printArea[1]);
  355.                 $worksheet->printArea(
  356.                     $printArea[0][11,
  357.                     PHPExcel_Cell::columnIndexFromString($printArea[0][0]1,
  358.                     $printArea[1][11,
  359.                     PHPExcel_Cell::columnIndexFromString($printArea[1][0]1
  360.                 );
  361.             }
  362.  
  363.             // Support for print scale
  364.             if ($phpSheet->getPageSetup()->getScale()) {
  365.                 $worksheet->setPrintScale($phpSheet->getPageSetup()->getScale());
  366.             }
  367.  
  368.             // Support for fitting to pages
  369.             if ($phpSheet->getPageSetup()->getFitToWidth()) {
  370.                 if ($phpSheet->getPageSetup()->getFitToHeight()) {
  371.                     // Both properties are set, so use them
  372.                     // Note: This case is double, see below
  373.                     $worksheet->fitToPages($phpSheet->getPageSetup()->getFitToWidth()$phpSheet->getPageSetup()->getFitToHeight());
  374.                 else {
  375.                     // Only width given, make assumption about height
  376.                     $height 0;
  377.                     $worksheet->fitToPages($phpSheet->getPageSetup()->getFitToWidth()$height);
  378.                 }
  379.             else if ($phpSheet->getPageSetup()->getFitToHeight()) {
  380.                 if ($phpSheet->getPageSetup()->getFitToWidth()) {
  381.                     // Both properties are set, so use them
  382.                     // Note: This case is double, see below
  383.                     $worksheet->fitToPages($phpSheet->getPageSetup()->getFitToWidth()$phpSheet->getPageSetup()->getFitToHeight());
  384.                 else {
  385.                     // Only height given, make assumption about width
  386.                     $width 0;
  387.                     $worksheet->fitToPages($width$phpSheet->getPageSetup()->getFitToHeight());
  388.                 }
  389.             }
  390.  
  391.             // Support for breaks
  392.             $vBreaks array();
  393.             $hBreaks array();
  394.             foreach ($phpSheet->getBreaks(as $cell => $breakType{
  395.                 // Fetch coordinates
  396.                 $coordinates PHPExcel_Cell::coordinateFromString($cell);
  397.  
  398.                 // Decide what to do by the type of break
  399.                 switch ($breakType{
  400.                     case PHPExcel_Worksheet::BREAK_COLUMN:
  401.                         // Add to list of vertical breaks
  402.                         $vBreaks[$coordinates[0];
  403.                         break;
  404.  
  405.                     case PHPExcel_Worksheet::BREAK_ROW:
  406.                         // Add to list of horizontal breaks
  407.                         $hBreaks[$coordinates[1];
  408.                         break;
  409.  
  410.                     case PHPExcel_Worksheet::BREAK_NONE:
  411.                     default:
  412.                         // Nothing to do
  413.                         break;
  414.                 }
  415.             }
  416.             $worksheet->setVPagebreaks($vBreaks);
  417.             $worksheet->setHPagebreaks($hBreaks);
  418.         }
  419.  
  420.         PHPExcel_Calculation_Functions::setReturnDateType($saveDateReturnType);
  421.  
  422.         $workbook->close();
  423.     }
  424.  
  425.     /**
  426.      * Add color
  427.      */
  428.     private function _addColor($workbook$rgb{
  429.         if (!isset($this->_colors[$rgb])) {
  430.             $workbook->setCustomColor(count($this->_colors)hexdec(substr($rgb02))hexdec(substr($rgb22))hexdec(substr($rgb4)));
  431.             $this->_colors[$rgbcount($this->_colors);
  432.         }
  433.         return $this->_colors[$rgb];
  434.     }
  435.  
  436.     /**
  437.      * Map border style
  438.      */
  439.     private function _mapBorderStyle($borderStyle{
  440.         switch ($borderStyle{
  441.             case PHPExcel_Style_Border::BORDER_NONEreturn 0;
  442.             case PHPExcel_Style_Border::BORDER_THICKreturn 2;
  443.             defaultreturn 1// map others to thin
  444.         }
  445.     }
  446.  
  447.     /**
  448.      * Map underline
  449.      */
  450.     private function _mapUnderline($underline{
  451.         switch ($underline{
  452.             case PHPExcel_Style_Font::UNDERLINE_NONE:
  453.                 return 0;
  454.             case PHPExcel_Style_Font::UNDERLINE_DOUBLE:
  455.             case PHPExcel_Style_Font::UNDERLINE_DOUBLEACCOUNTING:
  456.                 return 2;
  457.             default:
  458.                 return 1// map others to single
  459.         }
  460.     }
  461.  
  462.     /**
  463.      * Map fill type
  464.      */
  465.     private function _mapFillType($fillType{
  466.         switch ($fillType// just a guess
  467.             case PHPExcel_Style_Fill::FILL_NONEreturn 0;
  468.             case PHPExcel_Style_Fill::FILL_SOLIDreturn 1;
  469.             case PHPExcel_Style_Fill::FILL_GRADIENT_LINEARreturn 2;
  470.             case PHPExcel_Style_Fill::FILL_GRADIENT_PATHreturn 3;
  471.             case PHPExcel_Style_Fill::FILL_PATTERN_DARKDOWNreturn 4;
  472.             case PHPExcel_Style_Fill::FILL_PATTERN_DARKGRAYreturn 5;
  473.             case PHPExcel_Style_Fill::FILL_PATTERN_DARKGRIDreturn 6;
  474.             case PHPExcel_Style_Fill::FILL_PATTERN_DARKHORIZONTALreturn 7;
  475.             case PHPExcel_Style_Fill::FILL_PATTERN_DARKTRELLISreturn 8;
  476.             case PHPExcel_Style_Fill::FILL_PATTERN_DARKUPreturn 9;
  477.             case PHPExcel_Style_Fill::FILL_PATTERN_DARKVERTICALreturn 10;
  478.             case PHPExcel_Style_Fill::FILL_PATTERN_GRAY0625return 11;
  479.             case PHPExcel_Style_Fill::FILL_PATTERN_GRAY125return 12;
  480.             case PHPExcel_Style_Fill::FILL_PATTERN_LIGHTDOWNreturn 13;
  481.             case PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRAYreturn 14;
  482.             case PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRIDreturn 15;
  483.             case PHPExcel_Style_Fill::FILL_PATTERN_LIGHTHORIZONTALreturn 16;
  484.             case PHPExcel_Style_Fill::FILL_PATTERN_LIGHTTRELLISreturn 17;
  485.             case PHPExcel_Style_Fill::FILL_PATTERN_LIGHTUPreturn 18;
  486.             case PHPExcel_Style_Fill::FILL_PATTERN_LIGHTVERTICALreturn 19;
  487.             case PHPExcel_Style_Fill::FILL_PATTERN_MEDIUMGRAYreturn 20;
  488.         }
  489.  
  490.         return 0;
  491.     }
  492.  
  493.     /**
  494.      * Map VAlign
  495.      */
  496.     private function _mapVAlign($vAlign{
  497.         return ($vAlign == 'center' || $vAlign == 'justify' 'v' ''$vAlign;
  498.     }
  499.  
  500.     /**
  501.      * Map Error code
  502.      */
  503.     private function _mapErrorCode($errorCode{
  504.         switch ($errorCode{
  505.             case '#NULL!':    return 0x00;
  506.             case '#DIV/0!':    return 0x07;
  507.             case '#VALUE!':    return 0x0F;
  508.             case '#REF!':    return 0x17;
  509.             case '#NAME?':    return 0x1D;
  510.             case '#NUM!':    return 0x24;
  511.             case '#N/A':    return 0x2A;
  512.         }
  513.  
  514.         return 0;
  515.     }
  516.  
  517.     /**
  518.      * Get an array of all styles
  519.      *
  520.      * @param    PHPExcel                $pPHPExcel 
  521.      * @return    PHPExcel_Style[]        All styles in PHPExcel
  522.      * @throws    Exception
  523.      */
  524.     private function _allStyles(PHPExcel $pPHPExcel null)
  525.     {
  526.         // Get an array of all styles
  527.         $aStyles        array();
  528.  
  529.         for ($i 0$i $pPHPExcel->getSheetCount()++$i{
  530.             foreach ($pPHPExcel->getSheet($i)->getStyles(as $style{
  531.                 $aStyles[$style;
  532.             }
  533.         }
  534.  
  535.         return $aStyles;
  536.     }
  537.  
  538.     /**
  539.      * Get temporary storage directory
  540.      *
  541.      * @return string 
  542.      */
  543.     public function getTempDir({
  544.         return $this->_tempDir;
  545.     }
  546.  
  547.     /**
  548.      * Set temporary storage directory
  549.      *
  550.      * @param    string    $pValue        Temporary storage directory
  551.      * @throws    Exception    Exception when directory does not exist
  552.      */
  553.     public function setTempDir($pValue ''{
  554.         if (is_dir($pValue)) {
  555.             $this->_tempDir = $pValue;
  556.         else {
  557.             throw new Exception("Directory does not exist: $pValue");
  558.         }
  559.     }
  560. }

Documentation generated on Mon, 27 Oct 2008 08:38:22 +0100 by phpDocumentor 1.4.1