Excel file created by templater-json.jar is not a valid zip file
I'm running the following command using templater 8.0.0 on Mac OS X 14.5 with java openjdk 21.0.2 2024-01-16 and zsh 5.9:
$ java -jar templater-json.jar templater_test.xlsx templater_test.json > templater_out.xlsx
When I try to unzip the output file I get
$ unzip templater_out.xlsx
Archive: templater_out.xlsx
End-of-central-directory signature not found. Either this file is not
a zipfile, or it constitutes one disk of a multi-part archive. In the
latter case the central directory and zipfile comment will be found on
the last disk(s) of this archive.
unzip: cannot find zipfile directory in one of templater_out.xlsx or
templater_out.xlsx.zip, and cannot find templater_out.xlsx.ZIP, period.
However I was also able to unzip the file using
$ jar xvf templater_out2.xlsx
inflated: [Content_Types].xml
inflated: _rels/.rels
inflated: xl/_rels/workbook.xml.rels
inflated: xl/workbook.xml
inflated: xl/sharedStrings.xml
inflated: xl/styles.xml
inflated: xl/worksheets/sheet1.xml
inflated: xl/theme/theme1.xml
inflated: docProps/app.xml
inflated: docProps/core.xml
inflated: xl/worksheets/sheet2.xml
(see https://askubuntu.com/questions/54904/unzip-error-end-of-central-directory-signature-not-found)
And when I open the file Excel will also complain, but it is able to repair the file, see screenshots
Still it would be nice, if this issue could be fixed. Because many non-Excel tools will not be able to open the Excel file created by templater-json.jar, because it is not a valid zipfile.
Ah, it seems the issue just occurs when using the redirection symbol > . When I simply run
$ java -jar templater-json.jar templater_test.xlsx templater_test.json templater_out.xlsx
the resulting file is valid. So this is more a documentation bug. The example usage described at https://github.com/ngs-doo/TemplaterExamples/tree/master/Intermediate/TemplaterJson should only describe the command without redirection.
Eh, I think it works like that on some systems, but didn't test on various others. Tnx for the report. I'll look into updating descriptions and mention piping separately from main usage