As per summary, it seems not to be possible to save a spreadsheet as .xltx ( = a template file in .xlsx format )
I can open a file saved in Excel with .xltx extension and it'll correctly open as a new, untitled document, it's just saving into this format that is missing.
It works with binary .xlt, as well as native .ots and, as far as I can see, it's always been like that (inherited from OOo)
The same applies for dotx, dotm and potx, but not for potm :)
*** Bug 118462 has been marked as a duplicate of this bug. ***
If you want to see the trivial code to solve the issue look at bug 118462.
<?xml version="1.0" encoding="UTF-8" standalone="true"?>
<Override ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml" PartName="/xl/workbook.xml"/>
<Override ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml" PartName="/xl/workbook.xml"/>
<Override ContentType="application/vnd.ms-excel.sheet.macroEnabled.main+xml" PartName="/xl/workbook.xml"/>
<Override ContentType="application/vnd.ms-excel.template.macroEnabled.main+xml" PartName="/xl/workbook.xml"/>
Vasily Melenchuk committed a patch related to this issue.
It has been pushed to "master":
tdf#99438: sc: support for .xltx export
It will be available in 6.3.0.
The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
Affected users are encouraged to test the fix and report feedback.
Still no Excel 2007-2019 (macro-enabled template)(*.xltm). More than original issue but was marked as duplicate and closed so incorporated into this issue.
Just to be clear - not expecting to write or run code, just save existing code if workbook template changed. One use case might be edit and save existing macro-enabled spreadsheet as macro-enabled template.
Same functionality is appropriate in other modules, especially Writer, and file type description should be exactly consistent across all modules.