#2439·excelize

Don't SUM numeric text and logical values from cell references

Author: zac-scheiweCreated Oct 1, 2026Updated Oct 1, 2026

Description

Excel context

Excel's SUM function adds the numeric inputs given as arguments. SUM(2, "5", TRUE) = 8 but SUM(A1, B1, C1) = 2 when A1 = 2, B1 = "5", C1 = TRUE. Excel's SUM does not add references to numeric text. It also does not add references to booleans.

Excelize behaviour

Excelize's SUM incorrectly calculates SUM(A1, B1, C1) = 8. It should return 2.

Steps to reproduce the issue

go
package main

import (
      "fmt"

      "github.com/xuri/excelize/v2"
)

func main() {
      f := excelize.NewFile()
      f.SetCellValue("Sheet1", "A1", 2)
      f.SetCellValue("Sheet1", "B1", "5")
      f.SetCellValue("Sheet1", "C1", true)
      for _, formula := range []string{
              "=SUM(B1)",
              "=SUM(C1)",
              "=SUM(A1,B1,C1)",
              "=SUM(A1:C1)",
      } {
              f.SetCellFormula("Sheet1", "E1", formula)
              result, err := f.CalcCellValue("Sheet1", "E1")
              fmt.Printf("%-20s %-6q %v\n", formula,
      }
}

Describe the results you received

=SUM(B1)             "5"    <nil>
=SUM(C1)             "1"    <nil>
=SUM(A1,B1,C1)       "8"    <nil>
=SUM(A1:C1)          "8"    <nil>

Describe the results you expected

=SUM(B1)             "0"    <nil>
=SUM(C1)             "0"    <nil>
=SUM(A1,B1,C1)       "2"    <nil>
=SUM(A1:C1)          "2"    <nil>

Go version

1.27.1

Excelize version or commit ID

2.11.0

Environment

bash
macOS darwin/arm64
Microsoft Excel for Mac 16.113.3 (build 16.113.26092714)

Validations

  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • The provided reproduction is a minimal reproducible example of the bug.