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

DuplicateRow() causes the parentheses to be lost in the formula of the row being duplicated #1914

Closed iciness closed 1 month ago

iciness commented 1 month ago

Description

DuplicateRow() causes the parentheses to be lost in the formula of the row being duplicated

Steps to reproduce the issue:

i := 2

for j := 0; j <= 10; j++ {  
    f.SetCellValue("Sheet2", "A"+strconv.Itoa(i), "1000")
    f.SetCellFormula("Sheet2", "B"+strconv.Itoa(i), "=(A"+strconv.Itoa(i)+"-800)*20%")
        f.DuplicateRow("Sheet2", i)
    i++
}

Describe the results you received: After excel opens the file, the formula of A2 becomes = A2-800 * 20% Book1.xlsx

Describe the results you expected: The brackets in the formula are not lost

Output of go version:

go version go1.22.3 windows/amd64

Excelize version or commit ID:

v2.8.1

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

windows 11 pro 23H2 22631.3672 execl 2405 Build 16.0.17628.20006 64bit

xuri commented 1 month ago

Thanks for your feedback. This problem was duplicated with issue #1861, and already has been fixed in commit 703b737. Please upgrade to the master branch code by got get -u github.com/xuri/excelize/v2@master, and this patch will be released in the next version. I closed this issue, if you have any questions, please let me know and you can reopen this anytime.