Merge pull request #63 from simon3z/master
Add Date Format support to NumberCol
This commit is contained in:
commit
60fcb0b22c
9
col.go
9
col.go
@ -8,7 +8,7 @@ import (
|
|||||||
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/extrame/goyymmdd"
|
yymmdd "github.com/extrame/goyymmdd"
|
||||||
)
|
)
|
||||||
|
|
||||||
//content type
|
//content type
|
||||||
@ -54,7 +54,7 @@ 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 {
|
||||||
@ -63,7 +63,6 @@ func (xf *XfRk) String(wb *WorkBook) string {
|
|||||||
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -162,6 +161,10 @@ type NumberCol struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *NumberCol) String(wb *WorkBook) []string {
|
func (c *NumberCol) String(wb *WorkBook) []string {
|
||||||
|
if fNo := wb.Xfs[c.Index].formatNo(); fNo != 0 {
|
||||||
|
t := timeFromExcelTime(c.Float, wb.dateMode == 1)
|
||||||
|
return []string{yymmdd.Format(t, wb.Formats[fNo].str)}
|
||||||
|
}
|
||||||
return []string{strconv.FormatFloat(c.Float, 'f', -1, 64)}
|
return []string{strconv.FormatFloat(c.Float, 'f', -1, 64)}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user