Example #1
0
 /**
  * Write relationships for additional objects of custom UI (ribbon)
  *
  * @param \PHPExcel\SpreadSheet $pPHPExcel
  * @return string XML Output
  * @throws     \PHPExcel\Writer\Exception
  */
 public function writeRibbonRelationships(\PHPExcel\SpreadSheet $pPHPExcel = null)
 {
     // Create XML writer
     $objWriter = null;
     if ($this->getParentWriter()->getUseDiskCaching()) {
         $objWriter = new \PHPExcel\Shared\XMLWriter(\PHPExcel\Shared\XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
     } else {
         $objWriter = new \PHPExcel\Shared\XMLWriter(\PHPExcel\Shared\XMLWriter::STORAGE_MEMORY);
     }
     // XML header
     $objWriter->startDocument('1.0', 'UTF-8', 'yes');
     // Relationships
     $objWriter->startElement('Relationships');
     $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
     $localRels = $pPHPExcel->getRibbonBinObjects('names');
     if (is_array($localRels)) {
         foreach ($localRels as $aId => $aTarget) {
             $objWriter->startElement('Relationship');
             $objWriter->writeAttribute('Id', $aId);
             $objWriter->writeAttribute('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image');
             $objWriter->writeAttribute('Target', $aTarget);
             $objWriter->endElement();
         }
     }
     $objWriter->endElement();
     return $objWriter->getData();
 }
Example #2
0
 /**
  * Write relationships for a signed VBA Project
  *
  * @param \PHPExcel\SpreadSheet $pPHPExcel
  * @return string  XML Output
  * @throws     \PHPExcel\Writer\Exception
  */
 public function writeVBARelationships(\PHPExcel\SpreadSheet $pPHPExcel = null)
 {
     // Create XML writer
     $objWriter = null;
     if ($this->getParentWriter()->getUseDiskCaching()) {
         $objWriter = new \PHPExcel\Shared\XMLWriter(\PHPExcel\Shared\XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
     } else {
         $objWriter = new \PHPExcel\Shared\XMLWriter(\PHPExcel\Shared\XMLWriter::STORAGE_MEMORY);
     }
     // XML header
     $objWriter->startDocument('1.0', 'UTF-8', 'yes');
     // Relationships
     $objWriter->startElement('Relationships');
     $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
     $objWriter->startElement('Relationship');
     $objWriter->writeAttribute('Id', 'rId1');
     $objWriter->writeAttribute('Type', 'http://schemas.microsoft.com/office/2006/relationships/vbaProjectSignature');
     $objWriter->writeAttribute('Target', 'vbaProjectSignature.bin');
     $objWriter->endElement();
     $objWriter->endElement();
     return $objWriter->getData();
 }
Example #3
0
 /**
  * Write docProps/custom.xml to XML format
  *
  * @param \PHPExcel\SpreadSheet $pPHPExcel
  * @return string  XML Output
  * @throws     \PHPExcel\Writer\Exception
  */
 public function writeDocPropsCustom(\PHPExcel\SpreadSheet $pPHPExcel = null)
 {
     $customPropertyList = $pPHPExcel->getProperties()->getCustomProperties();
     if (empty($customPropertyList)) {
         return;
     }
     // Create XML writer
     $objWriter = null;
     if ($this->getParentWriter()->getUseDiskCaching()) {
         $objWriter = new \PHPExcel\Shared\XMLWriter(\PHPExcel\Shared\XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
     } else {
         $objWriter = new \PHPExcel\Shared\XMLWriter(\PHPExcel\Shared\XMLWriter::STORAGE_MEMORY);
     }
     // XML header
     $objWriter->startDocument('1.0', 'UTF-8', 'yes');
     // cp:coreProperties
     $objWriter->startElement('Properties');
     $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/officeDocument/2006/custom-properties');
     $objWriter->writeAttribute('xmlns:vt', 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes');
     foreach ($customPropertyList as $key => $customProperty) {
         $propertyValue = $pPHPExcel->getProperties()->getCustomPropertyValue($customProperty);
         $propertyType = $pPHPExcel->getProperties()->getCustomPropertyType($customProperty);
         $objWriter->startElement('property');
         $objWriter->writeAttribute('fmtid', '{D5CDD505-2E9C-101B-9397-08002B2CF9AE}');
         $objWriter->writeAttribute('pid', $key + 2);
         $objWriter->writeAttribute('name', $customProperty);
         switch ($propertyType) {
             case 'i':
                 $objWriter->writeElement('vt:i4', $propertyValue);
                 break;
             case 'f':
                 $objWriter->writeElement('vt:r8', $propertyValue);
                 break;
             case 'b':
                 $objWriter->writeElement('vt:bool', $propertyValue ? 'true' : 'false');
                 break;
             case 'd':
                 $objWriter->startElement('vt:filetime');
                 $objWriter->writeRawData(date(DATE_W3C, $propertyValue));
                 $objWriter->endElement();
                 break;
             default:
                 $objWriter->writeElement('vt:lpwstr', $propertyValue);
                 break;
         }
         $objWriter->endElement();
     }
     $objWriter->endElement();
     return $objWriter->getData();
 }