This closes #1396, fix formula fn ADDRESS result error with empty worksheet name (#1397)

- Update unit tests

Co-authored-by: jayhoo <hujie@ynningneng.com>
This commit is contained in:
devloppper 2022-11-22 00:14:03 +08:00 committed by xuri
parent aa80fa4179
commit dde6b9c001
No known key found for this signature in database
GPG Key ID: BA5E5BB1C948EDF7
2 changed files with 12 additions and 6 deletions

View File

@ -13960,13 +13960,10 @@ func (fn *formulaFuncs) ADDRESS(argsList *list.List) formulaArg {
}
var sheetText string
if argsList.Len() == 5 {
sheetText = trimSheetName(argsList.Back().Value.(formulaArg).Value())
}
if len(sheetText) > 0 {
sheetText = fmt.Sprintf("%s!", sheetText)
sheetText = fmt.Sprintf("%s!", trimSheetName(argsList.Back().Value.(formulaArg).Value()))
}
formatter := addressFmtMaps[fmt.Sprintf("%d_%s", int(absNum.Number), a1.Value())]
addr, err := formatter(int(colNum.Number), int(colNum.Number))
addr, err := formatter(int(colNum.Number), int(rowNum.Number))
if err != nil {
return newErrorFormulaArg(formulaErrorVALUE, formulaErrorVALUE)
}

View File

@ -1800,14 +1800,23 @@ func TestCalcCellValue(t *testing.T) {
// Excel Lookup and Reference Functions
// ADDRESS
"=ADDRESS(1,1,1,TRUE)": "$A$1",
"=ADDRESS(1,2,1,TRUE)": "$B$1",
"=ADDRESS(1,1,1,FALSE)": "R1C1",
"=ADDRESS(1,2,1,FALSE)": "R1C2",
"=ADDRESS(1,1,2,TRUE)": "A$1",
"=ADDRESS(1,2,2,TRUE)": "B$1",
"=ADDRESS(1,1,2,FALSE)": "R1C[1]",
"=ADDRESS(1,2,2,FALSE)": "R1C[2]",
"=ADDRESS(1,1,3,TRUE)": "$A1",
"=ADDRESS(1,2,3,TRUE)": "$B1",
"=ADDRESS(1,1,3,FALSE)": "R[1]C1",
"=ADDRESS(1,2,3,FALSE)": "R[1]C2",
"=ADDRESS(1,1,4,TRUE)": "A1",
"=ADDRESS(1,2,4,TRUE)": "B1",
"=ADDRESS(1,1,4,FALSE)": "R[1]C[1]",
"=ADDRESS(1,1,4,TRUE,\"\")": "A1",
"=ADDRESS(1,2,4,FALSE)": "R[1]C[2]",
"=ADDRESS(1,1,4,TRUE,\"\")": "!A1",
"=ADDRESS(1,2,4,TRUE,\"\")": "!B1",
"=ADDRESS(1,1,4,TRUE,\"Sheet1\")": "Sheet1!A1",
// CHOOSE
"=CHOOSE(4,\"red\",\"blue\",\"green\",\"brown\")": "brown",