openspout / openspout

Read and write spreadsheet files (CSV, XLSX and ODS), in a fast and scalable way
https://github.com/openspout/openspout/tree/4.x/docs
MIT License
788 stars 100 forks source link

How to setup excel file properties #154

Open APU-SteveRogers opened 1 year ago

APU-SteveRogers commented 1 year ago

I just wanted to check if there is possibility of setting up file properties for excel files. Excel Properties

Slamdunk commented 1 year ago

XLSX are just zipped XMLs: dive into an XLSX with that information already set, you should easily spot the place. After that, I would happily accept a PR that add an API to set that info :muscle:

lekoala commented 9 months ago

I'm wondering as well Seems indeed simple enough

This

https://github.com/openspout/openspout/blob/6bc4ec81ef553e8f26c90e587ca86d0e6948e49d/src/Writer/XLSX/Helper/FileSystemHelper.php#L587-L591

Could look like this

<cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" 
  xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" 
  xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <dcterms:created xsi:type="dcterms:W3CDTF">{DATE}</dcterms:created>
    <dc:title>{TITLE}</dc:title>
    <dc:subject>{SUBJECT}</dc:subject>
    <dc:creator>{AUTHOR}</dc:creator>
    <cp:lastModifiedBy>{LAST_MODIFY_BY}</cp:lastModifiedBy>
    <cp:keywords>{KEYWORD}</cp:keywords>
    <dc:description>{DESCRIPTION}</dc:description>
    <cp:category>{CATEGORY}</cp:category>
    <dc:language>{LANGUAGE}</dc:language>
    <dcterms:modified xsi:type="dcterms:W3CDTF">{DATE}</dcterms:modified>
    <cp:revision>1</cp:revision>
</cp:coreProperties>

And then simply replace values or use empty strings upon generation