protected function Xls::setMetaData in Excel Serialization 8
Set any available metadata.
Parameters
\PhpOffice\PhpSpreadsheet\Document\Properties $document_properties: The document properties object.
array $metadata: An associative array of metadata to set on the document. The array can contain any of the following keys (with corresponding values).
- 'creator': The document creator.
- 'last_modified_by': The name of the person to last modify.
- 'created': The time the document was created.
- 'modified': The time the document was modified.
- 'title': The document title.
- 'description': The document description.
- 'subject': The document subject.
- 'keywords': Any keywords for the document.
- 'category': The document category.
- 'manager': The document manager.
- 'company': The company that created the document.
- 'custom_properties': An associative array of property name mapping to
property value. If the value is an array, the first item should be the
value, and the second item the property type:
- 'i': integer
- 'f': floating point
- 's': string (default)
- 'd': 'date/time'
- 'b': boolean.
1 call to Xls::setMetaData()
- Xls::encode in src/
Encoder/ Xls.php - Encodes data into the given format.
File
- src/
Encoder/ Xls.php, line 203
Class
- Xls
- Adds XLS encoder support for the Serialization API.
Namespace
Drupal\xls_serialization\EncoderCode
protected function setMetaData(Properties $document_properties, array $metadata) {
if (isset($metadata['creator'])) {
$document_properties
->setCreator($metadata['creator']);
}
if (isset($metadata['last_modified_by'])) {
$document_properties
->setLastModifiedBy($metadata['last_modified_by']);
}
if (isset($metadata['created'])) {
$document_properties
->setCreated($metadata['created']);
}
if (isset($metadata['modified'])) {
$document_properties
->setModified($metadata['modified']);
}
if (isset($metadata['title'])) {
$document_properties
->setTitle($metadata['title']);
}
if (isset($metadata['description'])) {
$document_properties
->setDescription($metadata['description']);
}
if (isset($metadata['subject'])) {
$document_properties
->setSubject($metadata['subject']);
}
if (isset($metadata['keywords'])) {
$document_properties
->setKeywords($metadata['keywords']);
}
if (isset($metadata['category'])) {
$document_properties
->setCategory($metadata['category']);
}
if (isset($metadata['manager'])) {
$document_properties
->setManager($metadata['manager']);
}
if (isset($metadata['company'])) {
$document_properties
->setCompany($metadata['company']);
}
if (isset($metadata['custom_properties'])) {
foreach ($metadata['custom_properties'] as $name => $value) {
$type = 's';
if (is_array($value)) {
$type = array_pop($value);
$value = reset($value);
}
$document_properties
->setCustomProperty($name, $value, $type);
}
}
}