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

Documentation generated on Tue, 01 Jun 2010 17:02:46 +0200 by phpDocumentor 1.4.3