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

Documentation generated on Mon, 05 Jan 2009 20:36:48 +0100 by phpDocumentor 1.4.1