diff options
author | xuri <xuri.me@gmail.com> | 2021-12-31 00:00:01 +0800 |
---|---|---|
committer | xuri <xuri.me@gmail.com> | 2021-12-31 00:00:01 +0800 |
commit | e37e060d6f97274c1e967cea40609623493bce25 (patch) | |
tree | c40a114bf545dfe0290e83fd5f81f27ca3ac55d7 /stream.go | |
parent | c5990ea3484932fd6066c04e36c63735889a8228 (diff) |
This closes #1107, stream writer will create a time number format for time type cells
Unit test coverage improved
Diffstat (limited to 'stream.go')
-rw-r--r-- | stream.go | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -341,7 +341,7 @@ func (sw *StreamWriter) SetRow(axis string, values []interface{}, opts ...RowOpt val = v.Value setCellFormula(&c, v.Formula) } - if err = setCellValFunc(&c, val); err != nil { + if err = sw.setCellValFunc(&c, val); err != nil { _, _ = sw.rawData.WriteString(`</row>`) return err } @@ -424,7 +424,7 @@ func setCellFormula(c *xlsxC, formula string) { } // setCellValFunc provides a function to set value of a cell. -func setCellValFunc(c *xlsxC, val interface{}) (err error) { +func (sw *StreamWriter) setCellValFunc(c *xlsxC, val interface{}) (err error) { switch val := val.(type) { case int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64: err = setCellIntFunc(c, val) @@ -439,7 +439,12 @@ func setCellValFunc(c *xlsxC, val interface{}) (err error) { case time.Duration: c.T, c.V = setCellDuration(val) case time.Time: - c.T, c.V, _, err = setCellTime(val) + var isNum bool + c.T, c.V, isNum, err = setCellTime(val) + if isNum && c.S == 0 { + style, _ := sw.File.NewStyle(&Style{NumFmt: 22}) + c.S = style + } case bool: c.T, c.V = setCellBool(val) case nil: |