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

SetColWidth Creates All 16,384 Columns #1057

Closed
teschste opened this issue Nov 11, 2021 · 1 comment
Closed

SetColWidth Creates All 16,384 Columns #1057

teschste opened this issue Nov 11, 2021 · 1 comment
Labels
confirmed This issue can be reproduced

Comments

@teschste
Copy link

teschste commented Nov 11, 2021

I have not been able to duplicate this with a new file or with some existing files but I have at least one that, when I use SetColWidth, creates entries for all 16,384 columns in the xl\worksheets\sheet1.xml file; I am certain this has to be happening for others as well.

Before updating the file, the <cols> tag only contains the columns that had been defined by the user.
After updating the file, the <cols> tag now contains 16,384 entries as follows:

<col max="10" min="10" style="1" width="9.140625"/>
<col max="11" min="11" style="1" width="9.140625"/>
<col max="12" min="12" style="1" width="9.140625"/>
.
.
.
<col max="16382" min="16382" style="1" width="9.140625"/>
<col max="16383" min="16383" style="1" width="9.140625"/>
<col max="16384" min="16384" style="1" width="9.140625"/>

On the surface, this is a minor annoyance because as soon as you open the file in Excel and save it, the extra columns are removed but when you are updating and emailing files as I am, the file size is larger than necessary. For example, using an empty version of the file I have that has this issue, the original file size is 12,345 bytes but after executing SetColWidth with no other changes, the file size it now 95,684 bytes.

Steps to reproduce the issue:
Using the Empty.xlsx file I have attached, execute the following code:

xlsx, _ := excelize.OpenFile([path-to-file])
sheetName := xlsx.GetSheetName(0)
xlsx.SetColWidth(sheetName, "A", "A", 15)
xlsx.Save()

Describe the results you received:
As noted above, the saved file now has <cols> entries for all 16,384 columns.

Describe the results you expected:
The <cols> tag should only have entries for the the necessary/defined columns.

Output of go version:

go1.15.10 windows/amd64
We cannot currently update beyond this version until we update some internal tools.

Excelize version or commit ID:

I have no idea how to determine this.  there does not appear to be an easy way to get this
information (i.e. Google and I are stumped).

Environment details (OS, Microsoft Excel™ version, physical, etc.):

Windows 10 Pro 64-bit, OS Build: 19043.1288
Microsoft Excel 2016 (16.0.5239.1001) MSO (16.0.5215.1000) 64-bit

Empty.xlsx

@xuri xuri added confirmed This issue can be reproduced in progress Working in progress labels Nov 13, 2021
@xuri xuri closed this as completed in 57275db Nov 13, 2021
@xuri
Copy link
Member

xuri commented Nov 13, 2021

Thanks for your issue, I have fixed it, please upgrade to the master branch code, and this patch will be released in the next version.

@xuri xuri removed the in progress Working in progress label Nov 13, 2021
jenbonzhang pushed a commit to jenbonzhang/excelize that referenced this issue Oct 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed This issue can be reproduced
Projects
None yet
Development

No branches or pull requests

2 participants