Feature: Support for Extended and User-defined Workbook Properties in Excel2007 Writer
git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@61018 2327b42d-5241-43d6-9e2a-de5ac946f064
This commit is contained in:
parent
c6a3679d77
commit
388d2c80d1
|
@ -242,6 +242,10 @@ class PHPExcel_Writer_Excel2007 implements PHPExcel_Writer_IWriter
|
||||||
// Add document properties to ZIP file
|
// Add document properties to ZIP file
|
||||||
$objZip->addFromString('docProps/app.xml', $this->getWriterPart('DocProps')->writeDocPropsApp($this->_spreadSheet));
|
$objZip->addFromString('docProps/app.xml', $this->getWriterPart('DocProps')->writeDocPropsApp($this->_spreadSheet));
|
||||||
$objZip->addFromString('docProps/core.xml', $this->getWriterPart('DocProps')->writeDocPropsCore($this->_spreadSheet));
|
$objZip->addFromString('docProps/core.xml', $this->getWriterPart('DocProps')->writeDocPropsCore($this->_spreadSheet));
|
||||||
|
$customPropertiesPart = $this->getWriterPart('DocProps')->writeDocPropsCustom($this->_spreadSheet);
|
||||||
|
if (!is_null($customPropertiesPart)) {
|
||||||
|
$objZip->addFromString('docProps/custom.xml', $customPropertiesPart);
|
||||||
|
}
|
||||||
|
|
||||||
// Add theme to ZIP file
|
// Add theme to ZIP file
|
||||||
$objZip->addFromString('xl/theme/theme1.xml', $this->getWriterPart('Theme')->writeTheme($this->_spreadSheet));
|
$objZip->addFromString('xl/theme/theme1.xml', $this->getWriterPart('Theme')->writeTheme($this->_spreadSheet));
|
||||||
|
|
|
@ -98,6 +98,13 @@ class PHPExcel_Writer_Excel2007_ContentTypes extends PHPExcel_Writer_Excel2007_W
|
||||||
$objWriter, '/docProps/core.xml', 'application/vnd.openxmlformats-package.core-properties+xml'
|
$objWriter, '/docProps/core.xml', 'application/vnd.openxmlformats-package.core-properties+xml'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$customPropertyList = $pPHPExcel->getProperties()->getCustomProperties();
|
||||||
|
if (count($customPropertyList) > 0) {
|
||||||
|
$this->_writeOverrideContentType(
|
||||||
|
$objWriter, '/docProps/custom.xml', 'application/vnd.openxmlformats-officedocument.custom-properties+xml'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Worksheets
|
// Worksheets
|
||||||
$sheetCount = $pPHPExcel->getSheetCount();
|
$sheetCount = $pPHPExcel->getSheetCount();
|
||||||
for ($i = 0; $i < $sheetCount; ++$i) {
|
for ($i = 0; $i < $sheetCount; ++$i) {
|
||||||
|
|
|
@ -57,8 +57,8 @@ class PHPExcel_Writer_Excel2007_DocProps extends PHPExcel_Writer_Excel2007_Write
|
||||||
|
|
||||||
// Properties
|
// Properties
|
||||||
$objWriter->startElement('Properties');
|
$objWriter->startElement('Properties');
|
||||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/officeDocument/2006/extended-properties');
|
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/officeDocument/2006/extended-properties');
|
||||||
$objWriter->writeAttribute('xmlns:vt', 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes');
|
$objWriter->writeAttribute('xmlns:vt', 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes');
|
||||||
|
|
||||||
// Application
|
// Application
|
||||||
$objWriter->writeElement('Application', 'Microsoft Excel');
|
$objWriter->writeElement('Application', 'Microsoft Excel');
|
||||||
|
@ -74,9 +74,8 @@ class PHPExcel_Writer_Excel2007_DocProps extends PHPExcel_Writer_Excel2007_Write
|
||||||
|
|
||||||
// Vector
|
// Vector
|
||||||
$objWriter->startElement('vt:vector');
|
$objWriter->startElement('vt:vector');
|
||||||
$objWriter->writeAttribute('size', '2');
|
$objWriter->writeAttribute('size', '2');
|
||||||
$objWriter->writeAttribute('baseType', 'variant');
|
$objWriter->writeAttribute('baseType', 'variant');
|
||||||
|
|
||||||
|
|
||||||
// Variant
|
// Variant
|
||||||
$objWriter->startElement('vt:variant');
|
$objWriter->startElement('vt:variant');
|
||||||
|
@ -97,13 +96,13 @@ class PHPExcel_Writer_Excel2007_DocProps extends PHPExcel_Writer_Excel2007_Write
|
||||||
|
|
||||||
// Vector
|
// Vector
|
||||||
$objWriter->startElement('vt:vector');
|
$objWriter->startElement('vt:vector');
|
||||||
$objWriter->writeAttribute('size', $pPHPExcel->getSheetCount());
|
$objWriter->writeAttribute('size', $pPHPExcel->getSheetCount());
|
||||||
$objWriter->writeAttribute('baseType', 'lpstr');
|
$objWriter->writeAttribute('baseType', 'lpstr');
|
||||||
|
|
||||||
$sheetCount = $pPHPExcel->getSheetCount();
|
$sheetCount = $pPHPExcel->getSheetCount();
|
||||||
for ($i = 0; $i < $sheetCount; ++$i) {
|
for ($i = 0; $i < $sheetCount; ++$i) {
|
||||||
$objWriter->writeElement('vt:lpstr', $pPHPExcel->getSheet($i)->getTitle());
|
$objWriter->writeElement('vt:lpstr', $pPHPExcel->getSheet($i)->getTitle());
|
||||||
}
|
}
|
||||||
|
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
|
@ -155,11 +154,11 @@ class PHPExcel_Writer_Excel2007_DocProps extends PHPExcel_Writer_Excel2007_Write
|
||||||
|
|
||||||
// cp:coreProperties
|
// cp:coreProperties
|
||||||
$objWriter->startElement('cp:coreProperties');
|
$objWriter->startElement('cp:coreProperties');
|
||||||
$objWriter->writeAttribute('xmlns:cp', 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties');
|
$objWriter->writeAttribute('xmlns:cp', 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties');
|
||||||
$objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
|
$objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
|
||||||
$objWriter->writeAttribute('xmlns:dcterms', 'http://purl.org/dc/terms/');
|
$objWriter->writeAttribute('xmlns:dcterms', 'http://purl.org/dc/terms/');
|
||||||
$objWriter->writeAttribute('xmlns:dcmitype', 'http://purl.org/dc/dcmitype/');
|
$objWriter->writeAttribute('xmlns:dcmitype', 'http://purl.org/dc/dcmitype/');
|
||||||
$objWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
|
$objWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
|
||||||
|
|
||||||
// dc:creator
|
// dc:creator
|
||||||
$objWriter->writeElement('dc:creator', $pPHPExcel->getProperties()->getCreator());
|
$objWriter->writeElement('dc:creator', $pPHPExcel->getProperties()->getCreator());
|
||||||
|
@ -169,14 +168,14 @@ class PHPExcel_Writer_Excel2007_DocProps extends PHPExcel_Writer_Excel2007_Write
|
||||||
|
|
||||||
// dcterms:created
|
// dcterms:created
|
||||||
$objWriter->startElement('dcterms:created');
|
$objWriter->startElement('dcterms:created');
|
||||||
$objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF');
|
$objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF');
|
||||||
$objWriter->writeRaw(date(DATE_W3C, $pPHPExcel->getProperties()->getCreated()));
|
$objWriter->writeRaw(date(DATE_W3C, $pPHPExcel->getProperties()->getCreated()));
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
// dcterms:modified
|
// dcterms:modified
|
||||||
$objWriter->startElement('dcterms:modified');
|
$objWriter->startElement('dcterms:modified');
|
||||||
$objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF');
|
$objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF');
|
||||||
$objWriter->writeRaw(date(DATE_W3C, $pPHPExcel->getProperties()->getModified()));
|
$objWriter->writeRaw(date(DATE_W3C, $pPHPExcel->getProperties()->getModified()));
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
// dc:title
|
// dc:title
|
||||||
|
@ -199,4 +198,75 @@ class PHPExcel_Writer_Excel2007_DocProps extends PHPExcel_Writer_Excel2007_Write
|
||||||
// Return
|
// Return
|
||||||
return $objWriter->getData();
|
return $objWriter->getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write docProps/custom.xml to XML format
|
||||||
|
*
|
||||||
|
* @param PHPExcel $pPHPExcel
|
||||||
|
* @return string XML Output
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function writeDocPropsCustom(PHPExcel $pPHPExcel = null)
|
||||||
|
{
|
||||||
|
$customPropertyList = $pPHPExcel->getProperties()->getCustomProperties();
|
||||||
|
if (count($customPropertyList) == 0) {
|
||||||
|
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->writeRaw(date(DATE_W3C, $propertyValue));
|
||||||
|
$objWriter->endElement();
|
||||||
|
break;
|
||||||
|
default :
|
||||||
|
$objWriter->writeElement('vt:lpwstr', $propertyValue);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$objWriter->endElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$objWriter->endElement();
|
||||||
|
|
||||||
|
// Return
|
||||||
|
return $objWriter->getData();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,18 @@ class PHPExcel_Writer_Excel2007_Rels extends PHPExcel_Writer_Excel2007_WriterPar
|
||||||
$objWriter->startElement('Relationships');
|
$objWriter->startElement('Relationships');
|
||||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
|
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
|
||||||
|
|
||||||
|
$customPropertyList = $pPHPExcel->getProperties()->getCustomProperties();
|
||||||
|
if (count($customPropertyList) > 0) {
|
||||||
|
// Relationship docProps/app.xml
|
||||||
|
$this->_writeRelationship(
|
||||||
|
$objWriter,
|
||||||
|
4,
|
||||||
|
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties',
|
||||||
|
'docProps/custom.xml'
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Relationship docProps/app.xml
|
// Relationship docProps/app.xml
|
||||||
$this->_writeRelationship(
|
$this->_writeRelationship(
|
||||||
$objWriter,
|
$objWriter,
|
||||||
|
|
Binary file not shown.
|
@ -28,7 +28,7 @@ Fixed in SVN:
|
||||||
- Feature: (MBaker) Work item 8769 - Implement Gnumeric File Format
|
- Feature: (MBaker) Work item 8769 - Implement Gnumeric File Format
|
||||||
Initial work on Gnumeric Reader (Worksheet Data, Document Properties and basic Formatting)
|
Initial work on Gnumeric Reader (Worksheet Data, Document Properties and basic Formatting)
|
||||||
- Feature: (MBaker) Support for Extended Workbook Properties in Excel2007, Excel5 and OOCalc Readers; support for User-defined Workbook Properties in Excel2007 and OOCalc Readers
|
- Feature: (MBaker) Support for Extended Workbook Properties in Excel2007, Excel5 and OOCalc Readers; support for User-defined Workbook Properties in Excel2007 and OOCalc Readers
|
||||||
- Feature: (MBaker) Support for Extended Workbook Properties in Excel2007 Writer
|
- Feature: (MBaker) Support for Extended and User-defined Workbook Properties in Excel2007 Writer
|
||||||
- Feature: (MBaker) Provided a setGenerateSheetNavigationBlock(false); option to suppress generation of the sheet navigation block when writing multiple worksheets to HTML
|
- Feature: (MBaker) Provided a setGenerateSheetNavigationBlock(false); option to suppress generation of the sheet navigation block when writing multiple worksheets to HTML
|
||||||
- Bugfix: (Progi1984) Workitem 7895 - Excel5 : Formula : Percent
|
- Bugfix: (Progi1984) Workitem 7895 - Excel5 : Formula : Percent
|
||||||
- Bugfix: (MB) Work item 14143 - NA() doesn't propagate in matrix calc - quick fix in JAMA/Matrix.php
|
- Bugfix: (MB) Work item 14143 - NA() doesn't propagate in matrix calc - quick fix in JAMA/Matrix.php
|
||||||
|
|
Loading…
Reference in New Issue