This project is read-only.

using Zip.ZipFile for xlsx files

Nov 11, 2011 at 1:19 PM

Hi everybody, 
I have an application that create an xlsx file. After the definition of all xml files i use ZipFile to create the wrapped myfile.xlsx
If i open the file in Excel it's ok and no warnings were displayed, but i got I/O error on opening it in openoffice or in google docs. The strange is: 1)open myfile.xlsx with winRar 2)save xmls files and create a new archive with winrar without making any change of the original xml files 
3)the new archive it'ok ok for excel, openoffice and google doc. ???
I tried different types of encoding during creation of the file but it's always the same...
Any idea??
Many thanks in advance

Nov 11, 2011 at 2:32 PM

I don't know, but... you might do well to do a binary comparison of the .xlsx that works, with the one that does not work.

There are a number of options available in creating zip files. DotNetZip makes some formatting decisions, which are generally benign. For example, DotNetZip encodes into each Zip entry, a high-precision NTFS timestamp for each file, by default.  It could be that some other tools do not handle the results of these decisions. 

a binary comparison of the files would show you the differences.

Another option for you is to perform various trials, turning things off.  For example, set the property EmitTimesInWindowsFormatWhenSaving to false.  Then, see if it makes a difference for openoffice.

Nov 11, 2011 at 3:49 PM

Many Thanks for your prompt reply..  :-)

I don't know exactly why but with this configuration it works perfectly.

zf = new Ionic.Zip.ZipFile(fileName, Encoding.UTF8);

zf.Encryption = Ionic.Zip.EncryptionAlgorithm.None; 
zf.EmitTimesInUnixFormatWhenSaving = false;
zf.EmitTimesInWindowsFormatWhenSaving = false;

zf.UseZip64WhenSaving = Ionic.Zip.Zip64Option.Never;
zf.CompressionMethod = Ionic.Zip.CompressionMethod.None;
zf.CompressionLevel = Ionic.Zlib.CompressionLevel.Level3;



Nov 11, 2011 at 6:52 PM

I'm pretty sure you can use DEFLATE Compression. 

You can probably leave that line out.

zf.CompressionMethod = Ionic.Zip.CompressionMethod.None;

Also, you should use a using() clause. Every time.  Every example shows this.