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

Source for file DocProps.php

Documentation is available at DocProps.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_Excel2007
  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.2, 2010-01-11
  26.  */
  27.  
  28.  
  29. /** PHPExcel root directory */
  30. if (!defined('PHPEXCEL_ROOT')) {
  31.     /**
  32.      * @ignore
  33.      */
  34.     define('PHPEXCEL_ROOT'dirname(__FILE__'/../../../');
  35. }
  36.  
  37. /** PHPExcel */
  38. require_once PHPEXCEL_ROOT 'PHPExcel.php';
  39.  
  40. /** PHPExcel_Writer_Excel2007 */
  41. require_once PHPEXCEL_ROOT 'PHPExcel/Writer/Excel2007.php';
  42.  
  43. /** PHPExcel_Writer_Excel2007_WriterPart */
  44. require_once PHPEXCEL_ROOT 'PHPExcel/Writer/Excel2007/WriterPart.php';
  45.  
  46. /** PHPExcel_Shared_XMLWriter */
  47. require_once PHPEXCEL_ROOT 'PHPExcel/Shared/XMLWriter.php';
  48.  
  49.  
  50. /**
  51.  * PHPExcel_Writer_Excel2007_DocProps
  52.  *
  53.  * @category   PHPExcel
  54.  * @package    PHPExcel_Writer_Excel2007
  55.  * @copyright  Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
  56.  */
  57. {
  58. /**
  59.      * Write docProps/app.xml to XML format
  60.      *
  61.      * @param     PHPExcel    $pPHPExcel 
  62.      * @return     string         XML Output
  63.      * @throws     Exception
  64.      */
  65.     public function writeDocPropsApp(PHPExcel $pPHPExcel null)
  66.     {
  67.         // Create XML writer
  68.         $objWriter null;
  69.         if ($this->getParentWriter()->getUseDiskCaching()) {
  70.             $objWriter new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK$this->getParentWriter()->getDiskCachingDirectory());
  71.         else {
  72.             $objWriter new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
  73.         }
  74.  
  75.         // XML header
  76.         $objWriter->startDocument('1.0','UTF-8','yes');
  77.  
  78.         // Properties
  79.         $objWriter->startElement('Properties');
  80.         $objWriter->writeAttribute('xmlns''http://schemas.openxmlformats.org/officeDocument/2006/extended-properties');
  81.         $objWriter->writeAttribute('xmlns:vt''http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes');
  82.  
  83.             // Application
  84.             $objWriter->writeElement('Application',     'Microsoft Excel');
  85.  
  86.             // DocSecurity
  87.             $objWriter->writeElement('DocSecurity',     '0');
  88.  
  89.             // ScaleCrop
  90.             $objWriter->writeElement('ScaleCrop',         'false');
  91.  
  92.             // HeadingPairs
  93.             $objWriter->startElement('HeadingPairs');
  94.  
  95.                 // Vector
  96.                 $objWriter->startElement('vt:vector');
  97.                 $objWriter->writeAttribute('size',         '2');
  98.                 $objWriter->writeAttribute('baseType',     'variant');
  99.  
  100.  
  101.                     // Variant
  102.                     $objWriter->startElement('vt:variant');
  103.                         $objWriter->writeElement('vt:lpstr',     'Worksheets');
  104.                     $objWriter->endElement();
  105.  
  106.                     // Variant
  107.                     $objWriter->startElement('vt:variant');
  108.                         $objWriter->writeElement('vt:i4',         $pPHPExcel->getSheetCount());
  109.                     $objWriter->endElement();
  110.  
  111.                 $objWriter->endElement();
  112.  
  113.             $objWriter->endElement();
  114.  
  115.             // TitlesOfParts
  116.             $objWriter->startElement('TitlesOfParts');
  117.  
  118.                 // Vector
  119.                 $objWriter->startElement('vt:vector');
  120.                 $objWriter->writeAttribute('size',         $pPHPExcel->getSheetCount());
  121.                 $objWriter->writeAttribute('baseType',    'lpstr');
  122.  
  123.                 $sheetCount $pPHPExcel->getSheetCount();
  124.                 for ($i 0$i $sheetCount++$i{
  125.                     $objWriter->writeElement('vt:lpstr'$pPHPExcel->getSheet($i)->getTitle());
  126.                 }
  127.  
  128.                 $objWriter->endElement();
  129.  
  130.             $objWriter->endElement();
  131.  
  132.             // Company
  133.             $objWriter->writeElement('Company',             $pPHPExcel->getProperties()->getCompany());
  134.  
  135.             // LinksUpToDate
  136.             $objWriter->writeElement('LinksUpToDate',         'false');
  137.  
  138.             // SharedDoc
  139.             $objWriter->writeElement('SharedDoc',             'false');
  140.  
  141.             // HyperlinksChanged
  142.             $objWriter->writeElement('HyperlinksChanged',     'false');
  143.  
  144.             // AppVersion
  145.             $objWriter->writeElement('AppVersion',             '12.0000');
  146.  
  147.         $objWriter->endElement();
  148.  
  149.         // Return
  150.         return $objWriter->getData();
  151.     }
  152.  
  153.     /**
  154.      * Write docProps/core.xml to XML format
  155.      *
  156.      * @param     PHPExcel    $pPHPExcel 
  157.      * @return     string         XML Output
  158.      * @throws     Exception
  159.      */
  160.     public function writeDocPropsCore(PHPExcel $pPHPExcel null)
  161.     {
  162.         // Create XML writer
  163.         $objWriter null;
  164.         if ($this->getParentWriter()->getUseDiskCaching()) {
  165.             $objWriter new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK$this->getParentWriter()->getDiskCachingDirectory());
  166.         else {
  167.             $objWriter new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
  168.         }
  169.  
  170.         // XML header
  171.         $objWriter->startDocument('1.0','UTF-8','yes');
  172.  
  173.         // cp:coreProperties
  174.         $objWriter->startElement('cp:coreProperties');
  175.         $objWriter->writeAttribute('xmlns:cp''http://schemas.openxmlformats.org/package/2006/metadata/core-properties');
  176.         $objWriter->writeAttribute('xmlns:dc''http://purl.org/dc/elements/1.1/');
  177.         $objWriter->writeAttribute('xmlns:dcterms''http://purl.org/dc/terms/');
  178.         $objWriter->writeAttribute('xmlns:dcmitype''http://purl.org/dc/dcmitype/');
  179.         $objWriter->writeAttribute('xmlns:xsi''http://www.w3.org/2001/XMLSchema-instance');
  180.  
  181.             // dc:creator
  182.             $objWriter->writeElement('dc:creator',            $pPHPExcel->getProperties()->getCreator());
  183.  
  184.             // cp:lastModifiedBy
  185.             $objWriter->writeElement('cp:lastModifiedBy',     $pPHPExcel->getProperties()->getLastModifiedBy());
  186.  
  187.             // dcterms:created
  188.             $objWriter->startElement('dcterms:created');
  189.             $objWriter->writeAttribute('xsi:type''dcterms:W3CDTF');
  190.             $objWriter->writeRaw(date(DATE_W3C,             $pPHPExcel->getProperties()->getCreated()));
  191.             $objWriter->endElement();
  192.  
  193.             // dcterms:modified
  194.             $objWriter->startElement('dcterms:modified');
  195.             $objWriter->writeAttribute('xsi:type''dcterms:W3CDTF');
  196.             $objWriter->writeRaw(date(DATE_W3C,             $pPHPExcel->getProperties()->getModified()));
  197.             $objWriter->endElement();
  198.  
  199.             // dc:title
  200.             $objWriter->writeElement('dc:title',             $pPHPExcel->getProperties()->getTitle());
  201.  
  202.             // dc:description
  203.             $objWriter->writeElement('dc:description',         $pPHPExcel->getProperties()->getDescription());
  204.  
  205.             // dc:subject
  206.             $objWriter->writeElement('dc:subject',             $pPHPExcel->getProperties()->getSubject());
  207.  
  208.             // cp:keywords
  209.             $objWriter->writeElement('cp:keywords',         $pPHPExcel->getProperties()->getKeywords());
  210.  
  211.             // cp:category
  212.             $objWriter->writeElement('cp:category',         $pPHPExcel->getProperties()->getCategory());
  213.  
  214.         $objWriter->endElement();
  215.  
  216.         // Return
  217.         return $objWriter->getData();
  218.     }
  219. }

Documentation generated on Mon, 11 Jan 2010 08:07:48 +0100 by phpDocumentor 1.4.1