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

Reduce generated workbook file size 减小Excelize生成的Excel文件尺寸 #1804

Open
realzuojianxiang opened this issue Feb 2, 2024 · 1 comment

Comments

@realzuojianxiang
Copy link
Contributor

Description
我发现在使用Excelize库生成Excel文件时,文件尺寸相对较大。我希望Excelize能够提供一种方法或功能,以减小生成的Excel文件的尺寸,从而减少存储和传输成本。

Steps to reproduce the issue
使用Excelize库创建一个包含大量数据和样式的Excel文件。
将该文件保存到磁盘或进行传输。
Describe the results you received (你收到的结果)
生成的Excel文件相对较大,导致存储和传输时占用较多的资源。

Describe the results you expected
我期望Excelize能够提供一种方法或功能,通过优化生成的Excel文件,减小文件尺寸,以减少资源占用。

go version
go version go1.21.1 windows/amd64

Excelize version or commit ID
我使用的Excelize版本是v2.8.0

Environment details
操作系统: Windows 10
Microsoft Excel™版本: Office 365

@xuri xuri changed the title 减小Excelize生成的Excel文件尺寸 Reduce generated workbook file size 减小Excelize生成的Excel文件尺寸 Feb 4, 2024
@xuri
Copy link
Member

xuri commented Feb 4, 2024

Thanks for your issue. There are 2 kinds of function modes in this library, the normal mode function and the stream mode function. Which mode function are you using? In the stream mode, the stream writer will store each cell value as an inline string instead of a shared string table (SST) item for better performance. If you need to get more small file size, please use the normal function. In addition, there some other 2 reasons that will impact the generated workbook file size:

  1. The value of the workbook internal XML attributes in boolean data type will be storage as true or false, but the Excel application will be storage that as 1 or 0
  2. All the workbook internal XML tags were explicitly closed, but the Excel application will store those self-closing tags if any element has no content.

These 2 reasons will cause the internal XML file size to be large, but the impact of the generated workbook file size was very little after the ZIP archive. Please also reference the related issue #1377.

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