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

When calling Save more than once on an already formatted Excel, the values are saved on unexpected cells #1906

Closed
DennyHecht opened this issue May 24, 2024 · 2 comments
Labels
bug Something isn't working
Projects

Comments

@DennyHecht
Copy link

Description

I have an empty Excel file I want to fill which contains cells with formatting.
Now my application either calls a function which saves less data (one save call) or more data (more than one save call).
In the first use case everything works as expected.
In the second use case where my application has more than one save calls, excelize will save the values on unexpected cells.
But only the values after the first save call are found on the wrong cells.

Steps to reproduce the issue:

  1. Open a formatted excel file
  2. Set some values and call Save()
  3. Set more values and call Save() again

Describe the results you received:
After first Save() call the values are saved on unexpected cell.
For example: Save a value on Z12 will save the value on AS12.

Describe the results you expected:
Save a value on Z12 should be found on Z12.

Output of go version:
tested with go1.22

Excelize version or commit ID:

v2.5.0 the bug exist
<= v2.5.0 the bug doesn't exist

bug reason
I could break down your code to

if _, ok = f.checked.Load(name); !ok {

Before the first Save() call f.checked.Load will return false and than ws.checkRow will fill ws.sheetData.R.C with the missing cells.
After the first Save() call f.checked.Load will return true and ws.checkRow will not be called.
This is the reason why the SetCellStr will write on the wrong cell because only the formatted cells are found in ws.sheetData.R.C.

I attached you my sample project to reproduce the issue.
I'm curious to here from you.

bug.zip

@xuri xuri added the bug Something isn't working label May 24, 2024
@xuri xuri closed this as completed in 42ad4d6 May 24, 2024
@xuri xuri added this to Bugfix in v2.9.0 May 24, 2024
@xuri
Copy link
Member

xuri commented May 24, 2024

Thanks for your issue. This issue was introduced by commit d9a0da7 sheet.go:L170 in v2.8.1, the v2.8.0 works well. I have fixed it, please upgrade to the master branch code, and this path will be released in the next version.

@DennyHecht
Copy link
Author

Thanks for the quick support!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
v2.9.0
Bugfix
Development

No branches or pull requests

2 participants