diff --git a/calc.go b/calc.go index f3892fca38..3c449492c3 100644 --- a/calc.go +++ b/calc.go @@ -13282,24 +13282,13 @@ func (fn *formulaFuncs) CONCATENATE(argsList *list.List) formulaArg { // concat is an implementation of the formula functions CONCAT and // CONCATENATE. func (fn *formulaFuncs) concat(name string, argsList *list.List) formulaArg { - buf := bytes.Buffer{} + var buf bytes.Buffer for arg := argsList.Front(); arg != nil; arg = arg.Next() { - token := arg.Value.(formulaArg) - switch token.Type { - case ArgString: - buf.WriteString(token.String) - case ArgNumber: - if token.Boolean { - if token.Number == 0 { - buf.WriteString("FALSE") - } else { - buf.WriteString("TRUE") - } - } else { - buf.WriteString(token.Value()) + for _, cell := range arg.Value.(formulaArg).ToList() { + if cell.Type == ArgError { + return cell } - default: - return newErrorFormulaArg(formulaErrorVALUE, fmt.Sprintf("%s requires arguments to be strings", name)) + buf.WriteString(cell.Value()) } } return newStringFormulaArg(buf.String()) diff --git a/calc_test.go b/calc_test.go index 607289f2e4..24c6efa3e8 100644 --- a/calc_test.go +++ b/calc_test.go @@ -1663,8 +1663,12 @@ func TestCalcCellValue(t *testing.T) { "=CODE(\"\")": "0", // CONCAT "=CONCAT(TRUE(),1,FALSE(),\"0\",INT(2))": "TRUE1FALSE02", + "=CONCAT(MUNIT(2))": "1001", + "=CONCAT(A1:B2)": "1425", // CONCATENATE "=CONCATENATE(TRUE(),1,FALSE(),\"0\",INT(2))": "TRUE1FALSE02", + "=CONCATENATE(MUNIT(2))": "1001", + "=CONCATENATE(A1:B2)": "1425", // EXACT "=EXACT(1,\"1\")": "TRUE", "=EXACT(1,1)": "TRUE", @@ -3665,9 +3669,11 @@ func TestCalcCellValue(t *testing.T) { "=CODE()": {"#VALUE!", "CODE requires 1 argument"}, "=CODE(1,2)": {"#VALUE!", "CODE requires 1 argument"}, // CONCAT - "=CONCAT(MUNIT(2))": {"#VALUE!", "CONCAT requires arguments to be strings"}, + "=CONCAT(NA())": {"#N/A", "#N/A"}, + "=CONCAT(1,1/0)": {"#DIV/0!", "#DIV/0!"}, // CONCATENATE - "=CONCATENATE(MUNIT(2))": {"#VALUE!", "CONCATENATE requires arguments to be strings"}, + "=CONCATENATE(NA())": {"#N/A", "#N/A"}, + "=CONCATENATE(1,1/0)": {"#DIV/0!", "#DIV/0!"}, // EXACT "=EXACT()": {"#VALUE!", "EXACT requires 2 arguments"}, "=EXACT(1,2,3)": {"#VALUE!", "EXACT requires 2 arguments"},