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

Add ZIP64 support for huge files #3

Closed
easysummer opened this issue May 12, 2021 · 4 comments
Closed

Add ZIP64 support for huge files #3

easysummer opened this issue May 12, 2021 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@easysummer
Copy link

Hello!

Thanks for such a cool little library.

I got an exception when trying to write a huge file.

System.NotSupportedException: "Attempted to write a stream that is larger than 4GiB without setting the zip64 option"
  at SharpCompress.Writers.Zip.ZipWriter.ZipWritingStream.Write(Byte[] buffer, Int32 offset, Int32 count)
at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
at System.IO.StreamWriter.Write(String value)
at System.IO.StreamWriter.Write(String format, Object[] arg)
at LargeXlsx.Worksheet.Write(String value, XlsxStyle style)
at LargeXlsx.XlsxWriter.DoOnWorksheet(Action action)
at testApp.Program.Main(String[] args) in /.../csharp/testApp/Program.cs:49

I have not found a parameter on using the zip64 flag in the library API.
Can you tell me how to solve this problem?

I used .NET Core 5 version. Also tried to use .NET 4.6.2 on a Windows machine - same exception.
Version library - latest (1.2.0).

❯ dotnet --info
.NET SDK (reflecting any global.json):

Version:   5.0.100
 Commit:    5044b93829

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.15
 OS Platform: Darwin
 RID:         osx.10.15-x64
 Base Path:   /usr/local/share/dotnet/sdk/5.0.100/

Host (useful for support):
  Version: 5.0.0
  Commit:  cf258a14b7

.NET SDKs installed:
  3.1.404 [/usr/local/share/dotnet/sdk]
  5.0.100 [/usr/local/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 3.1.10 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.10 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
@salvois
Copy link
Owner

salvois commented May 17, 2021

Hello @easysummer
thanks for reporting this issue!
I'm having a look and be back to you as soon as possible.

@salvois salvois self-assigned this May 17, 2021
@salvois
Copy link
Owner

salvois commented May 22, 2021

Hello @easysummer
looks like enabling the ZIP64 format is not enough to support your use case.
The SharpCompress library, used by LargeXlsx, appears to produce a ZIP file that is not compatible with Excel when enabling ZIP64. Excel complains about a corrupted file but it is able to repair it (LibreOffice, on the other hand, appears to have no support for ZIP64 altogether).
I will try to understand what Excel considers wrong about the generated file (looks like https://rzymek.github.io/post/excel-zip64/ may be a good start) and try to patch SharpCompress.
Thanks,
Salvo

@salvois salvois added the enhancement New feature or request label May 22, 2021
@salvois
Copy link
Owner

salvois commented May 23, 2021

Hello @easysummer
I've just opened a pull request to SharpCompress that solves the issue (adamhathcock/sharpcompress#601), letting us to enable ZIP64.
Hope it is considered for merge, so that a next version of LargeXlsx can take advantage of it.
Thanks,
Salvo

@salvois salvois changed the title Exception when trying to write a huge file Add ZIP64 support for huge files May 29, 2021
@salvois
Copy link
Owner

salvois commented Jun 24, 2021

Hello @easysummer
I have just released version 1.3.0 of LargeXlsx, which lets you enable the ZIP64 compression.
Please see the updated documentation about constructing an XlsxWriter.

I have tested ZIP64 both on small files with Excel and LibreOffice with no problems, and on a file larger than 4 GiB uncompressed, which works fine in Excel but it is reported as corrupt in LibreOffice. I don't know the reason for the latter and further testing could be helpful.

Look forward to your feedback!
Thanks,
Salvo

@salvois salvois closed this as completed Jun 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants