From 66349f8ec039351770536b83b87c455543c0cf8a Mon Sep 17 00:00:00 2001 From: Ri Xu Date: Fri, 5 May 2017 19:15:39 +0800 Subject: [PATCH] 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 257ec27781172ba877379eaebc6fbcb9c3c6ce44..909887af20296dd73d1d3030f2b929cf8c8784e7 100644 GIT binary patch delta 2433 zcmZvdc{r4N8^>p1kT*0K$2KDwvJJ9?Nf->ql4F@MMUfIkjzPv!!&GGK9;uL0gPMd) zme-K2g~-w(>mgKRkHa~aaF}`LTwT|D{`%a{{rg_u=YHioKYn;*B3ts7{G7~E` z>p+bcDpT_|U}a^%MEbJ|l@^tMAp!grmaL$!-lozop?D}it!hA*@>J!y5=bH%u9f-_ z@B4s_{^YsP&JgZbXO8#BJ$UUxVvKnmQ|oFmW+1O9xb2}{+0%U<(()v_fn|DYQralo zQr1vDQCg`WwICa(QSW0BJ~B5^+FadYLv_|iS7~)3o32*w55Qw8X^t%_0?cX8QtIne z{4FmLXw@JqW9v}6<$oJdO5Kr|u)9k)h41N#x)>`a8n%Rc**$^E3A8QAHz2;J+Rf$I ztPx$lxrNhZ15OHM*{ez)$N+rX<4sP>m#>u>Exg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