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

- Update unit tests

Co-authored-by: jayhoo <hujie@ynningneng.com>
pull/2/head
devloppper 2 years ago committed by xuri
parent aa80fa4179
commit dde6b9c001
No known key found for this signature in database
GPG Key ID: BA5E5BB1C948EDF7

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

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

Loading…
Cancel
Save