29 if (isset($xml->DocumentProperties[0])) {
30 $docProps = $this->spreadsheet->getProperties();
32 foreach ($xml->DocumentProperties[0] as $propertyName => $propertyValue) {
33 $propertyValue = (string) $propertyValue;
42 if (isset($xml->CustomDocumentProperties)) {
43 $docProps = $this->spreadsheet->getProperties();
45 foreach ($xml->CustomDocumentProperties[0] as $propertyName => $propertyValue) {
46 $propertyAttributes = self::getAttributes($propertyValue, $namespaces[
'dt']);
47 $propertyName = preg_replace_callback(
'/_x([0-9a-f]{4})_/i', [$this,
'hex2str'], $propertyName);
59 switch ($propertyName) {
61 $docProps->setTitle($stringValue);
65 $docProps->setSubject($stringValue);
69 $docProps->setCreator($stringValue);
73 $docProps->setCreated($stringValue);
77 $docProps->setLastModifiedBy($stringValue);
81 $docProps->setModified($stringValue);
85 $docProps->setCompany($stringValue);
89 $docProps->setCategory($stringValue);
93 $docProps->setManager($stringValue);
97 $docProps->setKeywords($stringValue);
101 $docProps->setDescription($stringValue);
109 string $propertyName,
113 $propertyType = DocumentProperties::PROPERTY_TYPE_UNKNOWN;
115 switch ((
string) $propertyAttributes) {
117 $propertyType = DocumentProperties::PROPERTY_TYPE_STRING;
118 $propertyValue = trim((
string) $propertyValue);
122 $propertyType = DocumentProperties::PROPERTY_TYPE_BOOLEAN;
123 $propertyValue = (bool) $propertyValue;
127 $propertyType = DocumentProperties::PROPERTY_TYPE_INTEGER;
128 $propertyValue = (int) $propertyValue;
132 $propertyType = DocumentProperties::PROPERTY_TYPE_FLOAT;
133 $propertyValue = (float) $propertyValue;
137 $propertyType = DocumentProperties::PROPERTY_TYPE_DATE;
138 $propertyValue = trim((
string) $propertyValue);
143 $docProps->setCustomProperty($propertyName, $propertyValue, $propertyType);
146 protected function hex2str(array $hex): string
148 return mb_chr((
int) hexdec($hex[1]),
'UTF-8');
153 return ($simple === null)
static getAttributes(?SimpleXMLElement $simple, string $node)
readCustomProperties(SimpleXMLElement $xml, array $namespaces)
__construct(Spreadsheet $spreadsheet)
readProperties(SimpleXMLElement $xml, array $namespaces)
processStandardProperty(DocumentProperties $docProps, string $propertyName, string $stringValue)
processCustomProperty(DocumentProperties $docProps, string $propertyName, ?SimpleXMLElement $propertyValue, SimpleXMLElement $propertyAttributes)
readStandardProperties(SimpleXMLElement $xml)