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

function MergeCell() didn't truly merge #1922

Closed
Noah-Chiu opened this issue Jun 12, 2024 · 2 comments
Closed

function MergeCell() didn't truly merge #1922

Noah-Chiu opened this issue Jun 12, 2024 · 2 comments

Comments

@Noah-Chiu
Copy link

Noah-Chiu commented Jun 12, 2024

Description

Steps to reproduce the issue:
1.

file := excelize.NewFile()
file.SetCellValue("Sheet1", "A1", 9.69)
file.SetCellValue("Sheet1", "A2", 9.69)
file.MergeCell("Sheet1","A1","A2")
if err := file.SaveAs(filePath + fileName); err != nil {
    log.Println("Save file error", err)
    return
}
  1. Open the excel I saved

Describe the results you received:
When I select the merge cell and it display that there are 2 cells in my selection
image
And when I unmerged the cell, it still got two cells in the sheet instead of one cell
image
Still count 2 when I use excel formula to count
image
Still sum 19.38 when I use excel formula to sum
image

Describe the results you expected:
It should be one cell in my selection
image
And when I unmerge it, it should be only be cell have the value
image

Output of go version:

go 1.19

Excelize version or commit ID:

v2.6.0 and v2.8.1 both

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

@xuri
Copy link
Member

xuri commented Jun 12, 2024

Thanks for your issue. The MergeCell function doesn't remove cell value except for the upper-left cell in the merging cell range, so this behavior is expected. If you need to clear cell value, please use the SetCellValue or another function to set nil value for these cells before merging cells.

@xuri
Copy link
Member

xuri commented Jun 17, 2024

I've closed this issue. If you have any questions, please let me know, and you can reopen this anytime.

@xuri xuri closed this as completed Jun 17, 2024
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