21
0

fix format

This commit is contained in:
Federico Simoncelli 2020-03-27 21:08:23 +01:00
parent 539786826c
commit 0ecbf4c42c
2 changed files with 8 additions and 8 deletions

7
col.go
View File

@ -8,7 +8,7 @@ import (
"time" "time"
"github.com/extrame/goyymmdd" yymmdd "github.com/extrame/goyymmdd"
) )
//content type //content type
@ -54,16 +54,15 @@ 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 {
if (strings.Contains(formatter.str, "#") || strings.Contains(formatter.str, ".00")){ if strings.Contains(formatter.str, "#") || strings.Contains(formatter.str, ".00") {
//If format contains # or .00 then this is a number //If format contains # or .00 then this is a number
return xf.Rk.String() return xf.Rk.String()
}else{ } else {
i, f, isFloat := xf.Rk.number() i, f, isFloat := xf.Rk.number()
if !isFloat { if !isFloat {
f = float64(i) f = float64(i)
} }
t := timeFromExcelTime(f, wb.dateMode == 1) t := timeFromExcelTime(f, wb.dateMode == 1)
return yymmdd.Format(t, formatter.str) return yymmdd.Format(t, formatter.str)
} }
} }

View File

@ -6,6 +6,7 @@ import (
"io" "io"
"os" "os"
"unicode/utf16" "unicode/utf16"
"golang.org/x/text/encoding/charmap" "golang.org/x/text/encoding/charmap"
) )
@ -162,9 +163,9 @@ func (wb *WorkBook) parseBof(buf io.ReadSeeker, b *bof, pre *bof, offset_pre int
return return
} }
func decodeWindows1251(enc []byte) string { func decodeWindows1251(enc []byte) string {
dec := charmap.Windows1251.NewDecoder() dec := charmap.Windows1251.NewDecoder()
out, _ := dec.Bytes(enc) out, _ := dec.Bytes(enc)
return string(out) return string(out)
} }
func (w *WorkBook) get_string(buf io.ReadSeeker, size uint16) (res string, err error) { func (w *WorkBook) get_string(buf io.ReadSeeker, size uint16) (res string, err error) {
if w.Is5ver { if w.Is5ver {