20
0

Issue: Numbers with some special formats reads as date

This commit is contained in:
korv1982 2017-10-23 11:25:56 +03:00
parent 18a6340e66
commit 86ef51ec15

17
col.go
View File

@ -4,6 +4,7 @@ import (
"fmt" "fmt"
"math" "math"
"strconv" "strconv"
"strings"
"time" "time"
@ -53,12 +54,18 @@ func (xf *XfRk) String(wb *WorkBook) string {
fNo := wb.Xfs[idx].formatNo() fNo := wb.Xfs[idx].formatNo()
if fNo >= 164 { // user defined format if fNo >= 164 { // user defined format
if formatter := wb.Formats[fNo]; formatter != nil { if formatter := wb.Formats[fNo]; formatter != nil {
i, f, isFloat := xf.Rk.number() if (strings.Contains(formatter.str, "#") || strings.Contains(formatter.str, ".00")){
if !isFloat { //If format contains # or .00 then this is a number
f = float64(i) return xf.Rk.String()
}else{
i, f, isFloat := xf.Rk.number()
if !isFloat {
f = float64(i)
}
t := timeFromExcelTime(f, wb.dateMode == 1)
return yymmdd.Format(t, formatter.str)
} }
t := timeFromExcelTime(f, wb.dateMode == 1)
return yymmdd.Format(t, formatter.str)
} }
// see http://www.openoffice.org/sc/excelfileformat.pdf Page #174 // see http://www.openoffice.org/sc/excelfileformat.pdf Page #174
} else if 14 <= fNo && fNo <= 17 || fNo == 22 || 27 <= fNo && fNo <= 36 || 50 <= fNo && fNo <= 58 { // jp. date format } else if 14 <= fNo && fNo <= 17 || fNo == 22 || 27 <= fNo && fNo <= 36 || 50 <= fNo && fNo <= 58 { // jp. date format