Malformed zip file generated
See original GitHub issueHi,
I’m using salvois/LargeXlsx library for generating Excel files (which are essentialy zip files) that uses this library. When I try to open a generated file in Excel it says that it’s corrupt. If I try to open the file with any unzip tool there are no errors. When I use the built-in ZipArchive class from .NET Core everything works as expected. I’ve dug a little deeper into the files generated by this library and the .NET one I see that every 16 kB I get 5 bytes inputed into the output stream. I don’t know if this is some special marker but Excel doesn’t recognize it and it messes up the content for it i.e. instead of ‘s=“0”’ i have ‘s=“0 ý€”’.
a simple way to reproduce it:
var ms = new MemoryStream();
var zw = new ZipWriter(ms, new ZipWriterOptions(compressionType: CompressionType.Deflate) { DeflateCompressionLevel = CompressionLevel.None });
var payload = new string('\n', 100000);
using (var stream = zw.WriteToStream("test.txt", new ZipWriterEntryOptions()))
using (var streamWriter = new StreamWriter(stream: stream))
{
streamWriter.Write(value: payload);
}
sequences are at offsets: 38, 32811, 65584,98357
Linking salvois/LargeXlsx#9
Issue Analytics
- State:
- Created a year ago
- Comments:13 (8 by maintainers)
Thank you, that does make excel unhappy, I will investigate
I’m closing this issue after confirming it’s now working.