In answer to your questions:
- XLSX is just a collection of XML files in a zip container. There is no other magic.
- If you decompress/unzip a valid XLSX files and then recompress/zip it and you can't read the resulting output then the problem is with the zipping software or the files your rezipped. Try a different library/utility or check the default compression type and levels that it uses and try match it to whatever Excel uses. Or check the zip file to make sure the directory structure was maintained.
Example of the contents of an xlsx file:
unzip -l example.xlsx
Archive: example.xlsx
Length Date Time Name
-------- ---- ---- ----
769 10-15-14 09:23 xl/worksheets/sheet1.xml
550 10-15-14 09:22 xl/workbook.xml
201 10-15-14 09:22 xl/sharedStrings.xml
...
I regularly unzip XLSX files, make minor changes for testing and re-zip them without any issue.
Update: The important thing is to avoid zipping the parent directory. Here is an example using the zip
system utility on Linux or the OS X:
# Unzip an xlsx file into a directory.
unzip example.xlsx -d newdir
# Make some valid changes to the files.
cd newdir/
vi xl/worksheets/sheet1.xml
# Rezip the files *FROM* the unzipped directory.
# Note: you could also re-zip to the original file if required.
find . -type f | xargs zip ../newfile.xlsx
# Check the file looks okay.
cd ..
unzip -l newfile.xlsx
xdg-open newfile.xlsx
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…