Applying themes to xlsx files

51 views
Skip to first unread message

John Pickard

unread,
Mar 4, 2015, 3:32:27 PM3/4/15
to spreadsheet...@googlegroups.com
Hey,

I just came across the need to apply an existing theme (encapsulated in a .thmx file) to xlsx files we generate using Excel::Writer::XLSX. I poked around a while in the pod / source code and didn't see any thing in the interface. Also, this post: https://groups.google.com/forum/#!searchin/spreadsheet-writeexcel/theme/spreadsheet-writeexcel/4J6IFO5jaL0/kddsUSZGvNMJ, implied that applying arbitrary themes were not part of Excel::Writer::XLSX. Luckily for me, the xlsx files we generate don't have anything that complicated (like charts, graphs, etc.).

So, I played around with the various xml files and found a simple solution that seems to work (in my limited and not complicated test cases). Thought I'd share it, for what it's worth. After closing the workbook object do the following manipulations on the unzipped xlsx file:
1) remove the defaultThemeVersion attribute of workbookPr node in xl/workbook.xml. In my case that node is now empty: <workbookPr/>
2) copy the theme1.xml file from the .thmx file (theme/theme/theme1.xml) to the workbook's xl/theme/theme1.xml. This overwrites the workbook's theme1.xml.
3) zip the files back up into a xlsx file


jmcnamara

unread,
Mar 14, 2015, 5:32:06 PM3/14/15
to spreadsheet...@googlegroups.com


On Wednesday, 4 March 2015 20:32:27 UTC, John Pickard wrote:
Hey,

I just came across the need to apply an existing theme (encapsulated in a .thmx file) to xlsx files we generate using Excel::Writer::XLSX. I poked around a while in the pod / source code and didn't see any thing in the interface. Also, this post: https://groups.google.com/forum/#!searchin/spreadsheet-writeexcel/theme/spreadsheet-writeexcel/4J6IFO5jaL0/kddsUSZGvNMJ, implied that applying arbitrary themes were not part of Excel::Writer::XLSX. Luckily for me, the xlsx files we generate don't have anything that complicated (like charts, graphs, etc.).


Hi,

I was playing around recently with the idea of letting the user specify a theme file via the interface. I did a bit of the initial work but parked it when I got busy.

If anyone would like this feature they should open a feature request issue on GitHub.

John
 
Reply all
Reply to author
Forward
0 new messages