qax-os / excelize

Go language library for reading and writing Microsoft Excel™ (XLAM / XLSM / XLSX / XLTM / XLTX) spreadsheets
https://xuri.me/excelize
BSD 3-Clause "New" or "Revised" License
17.62k stars 1.68k forks source link

function MergeCell() didn't truly merge #1922

Closed Noah-Chiu closed 2 weeks ago

Noah-Chiu commented 3 weeks ago

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
    }
  2. 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 commented 3 weeks ago

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 commented 2 weeks ago

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