summaryrefslogtreecommitdiff
path: root/excelize.go
diff options
context:
space:
mode:
authorRi Xu <xuri.me@gmail.com>2017-05-05 14:40:28 +0800
committerRi Xu <xuri.me@gmail.com>2017-05-05 14:40:28 +0800
commit8fbab474443393b8b996487cf7ade300a72d2e07 (patch)
treebd863a7e6066ce62ecc01db110e508145057d3c9 /excelize.go
parent7f30a6c9430476bcd5fc1662523ada0e95f60947 (diff)
- Formatted cell data support, fix issue #48;
- Function `SetCellValue()` support `time.Time` data type parameter, relate issue #49; - go doc and go test updated
Diffstat (limited to 'excelize.go')
-rw-r--r--excelize.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/excelize.go b/excelize.go
index 39adb87..18d08e2 100644
--- a/excelize.go
+++ b/excelize.go
@@ -4,11 +4,13 @@ import (
"archive/zip"
"bytes"
"encoding/xml"
+ "fmt"
"io"
"io/ioutil"
"os"
"strconv"
"strings"
+ "time"
)
// File define a populated XLSX file struct.
@@ -84,8 +86,13 @@ func (f *File) SetCellValue(sheet, axis string, value interface{}) {
f.SetCellStr(sheet, axis, t)
case []byte:
f.SetCellStr(sheet, axis, string(t))
- default:
+ case time.Time:
+ f.SetCellDefault(sheet, axis, strconv.FormatFloat(float64(timeToExcelTime(timeToUTCTime(value.(time.Time)))), 'f', -1, 32))
+ f.SetCellStyle(sheet, axis, axis, `{"number_format": 22}`)
+ case nil:
f.SetCellStr(sheet, axis, "")
+ default:
+ f.SetCellStr(sheet, axis, fmt.Sprintf("%v", value))
}
}