From 66349f8ec039351770536b83b87c455543c0cf8a Mon Sep 17 00:00:00 2001 From: Ri Xu Date: Fri, 5 May 2017 19:15:39 +0800 Subject: Handle number formats out of built-in range exception by returning raw value, relate issue #50. --- cell.go | 6 +++++- test/Workbook1.xlsx | Bin 22922 -> 22954 bytes 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cell.go b/cell.go index 59a9947..a452215 100644 --- a/cell.go +++ b/cell.go @@ -66,7 +66,11 @@ func (f *File) formattedValue(s int, v string) string { } var styleSheet xlsxStyleSheet xml.Unmarshal([]byte(f.readXML("xl/styles.xml")), &styleSheet) - return builtInNumFmtFunc[styleSheet.CellXfs.Xf[s].NumFmtID](styleSheet.CellXfs.Xf[s].NumFmtID, v) + ok := builtInNumFmtFunc[styleSheet.CellXfs.Xf[s].NumFmtID] + if ok != nil { + return ok(styleSheet.CellXfs.Xf[s].NumFmtID, v) + } + return v } // GetCellFormula provides function to get formula from cell by given sheet diff --git a/test/Workbook1.xlsx b/test/Workbook1.xlsx index 257ec27..909887a 100644 Binary files a/test/Workbook1.xlsx and b/test/Workbook1.xlsx differ -- cgit v1.2.1