Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Excel file created by templater-json.jar is not a valid zip file #70

Open
asmaier opened this issue May 16, 2024 · 2 comments
Open

Excel file created by templater-json.jar is not a valid zip file #70

asmaier opened this issue May 16, 2024 · 2 comments

Comments

@asmaier
Copy link

asmaier commented May 16, 2024

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
Screenshot 2024-05-16 at 10 15 57
Screenshot 2024-05-16 at 10 16 19

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.

@asmaier
Copy link
Author

asmaier commented May 16, 2024

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.

@zapov
Copy link
Member

zapov commented May 21, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants