public function PHPExcel_Writer_Excel2007_DocProps::writeDocPropsCustom in Loft Data Grids 6.2
Same name and namespace in other branches
- 7.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel2007/DocProps.php \PHPExcel_Writer_Excel2007_DocProps::writeDocPropsCustom()
* Write docProps/custom.xml to XML format * *
Parameters
PHPExcel $pPHPExcel: * @return string XML Output * @throws PHPExcel_Writer_Exception
File
- vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Writer/ Excel2007/ DocProps.php, line 209
Class
- PHPExcel_Writer_Excel2007_DocProps
- PHPExcel_Writer_Excel2007_DocProps
Code
public function writeDocPropsCustom(PHPExcel $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
return $objWriter
->getData();
}