11package excelize
22
33import (
4- "fmt"
54 "strconv"
65 "testing"
76)
@@ -10,7 +9,7 @@ func TestExcelize(t *testing.T) {
109 // Test update a XLSX file
1110 file , err := OpenFile ("./test/Workbook1.xlsx" )
1211 if err != nil {
13- fmt . Println (err )
12+ t . Error (err )
1413 }
1514 file = SetCellInt (file , "SHEET2" , "B2" , 100 )
1615 file = SetCellStr (file , "SHEET2" , "C11" , "Knowns" )
@@ -19,21 +18,31 @@ func TestExcelize(t *testing.T) {
1918 file = SetCellStr (file , "SHEET3" , "b230" , "10" )
2019 file = SetActiveSheet (file , 2 )
2120 if err != nil {
22- fmt . Println (err )
21+ t . Error (err )
2322 }
2423 for i := 1 ; i <= 300 ; i ++ {
25- file = SetCellStr (file , "SHEET3" , fmt . Sprintf ( "c%d" , i ), strconv .Itoa (i ))
24+ file = SetCellStr (file , "SHEET3" , "c" + strconv . Itoa ( i ), strconv .Itoa (i ))
2625 }
2726 err = Save (file , "./test/Workbook_2.xlsx" )
2827
2928 // Test create a XLSX file
3029 file2 := CreateFile ()
31- file2 = NewSheet (file2 , 2 , "SHEETxxx " )
32- file2 = NewSheet (file2 , 3 , "asd " )
30+ file2 = NewSheet (file2 , 2 , "TestSheet2 " )
31+ file2 = NewSheet (file2 , 3 , "TestSheet3 " )
3332 file2 = SetCellInt (file2 , "Sheet2" , "A23" , 10 )
3433 file2 = SetCellStr (file2 , "SHEET1" , "B20" , "10" )
3534 err = Save (file2 , "./test/Workbook_3.xlsx" )
3635 if err != nil {
37- fmt . Println (err )
36+ t . Error (err )
3837 }
38+
39+ // Test read cell value
40+ file , err = OpenFile ("./test/Workbook1.xlsx" )
41+ if err != nil {
42+ t .Error (err )
43+ }
44+ GetCellValue (file , "Sheet2" , "a5" )
45+ GetCellValue (file , "Sheet2" , "D11" )
46+ GetCellValue (file , "Sheet2" , "D12" )
47+ GetCellValue (file , "Sheet2" , "E12" )
3948}
0 commit comments