You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Setting a cell value to NaN (i.e. math.NaN()) leads to an error when the resulting file is opened in Excel.
Note: Old issue #119 looks pretty much identical, xuri mentioned the library handled this OK in xlsx files but that does not appear to be the case (or an issue has been introduced in the interim). Excel does not really support NaN values so the solution to this is not obvious.
Steps to reproduce the issue:
Run code below:
package main
import (
"fmt"
excelize "github.com/xuri/excelize/v2"
"math"
)
func main() {
f := excelize.NewFile()
if err := f.SetCellValue("Sheet1", "A1", math.NaN()); err != nil {
panic(err)
}
if err := f.SaveAs("Book1.xlsx"); err != nil {
fmt.Println(err)
}
}
Describe the results you received:.
Error when opening resulting file in Excel.
Describe the results you expected:
Either:
An error from SetCellValue
Excel file that opens and the cell contains either (not a perfect option here as Excel does not really support NaN)
The text NaN
#N/A error (perhaps =NA() formula).
I wonder if the first option is better as that leaves it up to the developer to resolve this.
Output of go version:
go version go1.22.4 windows/amd64
Excelize version or commit ID:
v2.8.1
Environment details (OS, Microsoft Excel™ version, physical, etc.):
Windows 11, Excel for Microsoft 365 (Version 2406 build 16.0.17726.20078) 64-Bit
The text was updated successfully, but these errors were encountered:
MattBrittan
changed the title
119
Setting Cell to NaN leads to "problem with some content" dialog in Excel
Jul 18, 2024
Thanks for your feedback. This issue has been fixed, now cell value will be represent in string or inline string for any IEEE 754 "not-a-number" value or infinity numeric. Please upgrade to the master branch code by go get -u github.com/xuri/excelize/v2@master, and this patch will be released in the next version.
Description
Setting a cell value to
NaN
(i.e.math.NaN()
) leads to an error when the resulting file is opened in Excel.Note: Old issue #119 looks pretty much identical, xuri mentioned the library handled this OK in xlsx files but that does not appear to be the case (or an issue has been introduced in the interim). Excel does not really support NaN values so the solution to this is not obvious.
Steps to reproduce the issue:
Run code below:
Describe the results you received:.
Error when opening resulting file in Excel.
Describe the results you expected:
Either:
SetCellValue
NaN
#N/A
error (perhaps=NA()
formula).I wonder if the first option is better as that leaves it up to the developer to resolve this.
Output of
go version
:Excelize version or commit ID:
Environment details (OS, Microsoft Excel™ version, physical, etc.):
Windows 11, Excel for Microsoft 365 (Version 2406 build 16.0.17726.20078) 64-Bit
The text was updated successfully, but these errors were encountered: