-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathu_excel_test.go
61 lines (57 loc) · 1.71 KB
/
u_excel_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package kerbalwzygo
import (
"testing"
"time"
)
func TestSheetData(t *testing.T) {
sheet := ExcelSheet{
Name: "测试",
}
sheet.SetSafeLimit(2)
sheet.Content = append(sheet.Content, []interface{}{1, 3})
sheet.Content = append(sheet.Content, []interface{}{1.2, 3})
sheet.Content = append(sheet.Content, []interface{}{"hao", 3})
sheet.Content = append(sheet.Content, []interface{}{true, 3})
sheet.Content = append(sheet.Content, []interface{}{time.Now(), 3})
t.Log(sheet.Len())
t.Log(len(sheet.Safe()))
}
func TestMakeExcelFp(t *testing.T) {
sheet := ExcelSheet{
Name: "测试",
}
sheet.SetSafeLimit(2)
sheet.Content = append(sheet.Content, []interface{}{1, 3})
sheet.Content = append(sheet.Content, []interface{}{1.2, 3})
sheet.Content = append(sheet.Content, []interface{}{"hao", 3})
sheet.Content = append(sheet.Content, []interface{}{true, 3})
sheet.Content = append(sheet.Content, []interface{}{time.Now().Format("2006-01-02 15:04:05"), 3})
t.Log(sheet.Len())
t.Log(len(sheet.Safe()))
fp, err := MakeExcelFp(sheet.Safe()...)
if nil != err {
t.Fatal(err)
} else {
t.Log(&fp)
fp.SaveAs("u_excel_test.xlsx")
}
}
func TestSafeMakeExcelFp(t *testing.T) {
sheet := ExcelSheet{
Name: "测试",
}
sheet.SetSafeLimit(2)
sheet.Content = append(sheet.Content, []interface{}{1, 3})
sheet.Content = append(sheet.Content, []interface{}{1.2, 3})
sheet.Content = append(sheet.Content, []interface{}{"hao", 3})
sheet.Content = append(sheet.Content, []interface{}{true, 3})
sheet.Content = append(sheet.Content, []interface{}{time.Now().Format("2006-01-02 15:04:05"), 3})
t.Log(sheet.Len())
fp, err := SafeMakeExcelFp(sheet)
if nil != err {
t.Fatal(err)
} else {
t.Log(&fp)
fp.SaveAs("u_excel_test.xlsx")
}
}