summaryrefslogtreecommitdiff
path: root/excelize_test.go
diff options
context:
space:
mode:
authorRi Xu <xuri.me@gmail.com>2016-08-30 21:54:28 +0800
committerRi Xu <xuri.me@gmail.com>2016-08-30 21:54:28 +0800
commit3c4ad28db75108dfd974b994df26ec7f33a69be7 (patch)
tree9f3f03683574b4e756b8467556ab2004f266b159 /excelize_test.go
parent0d60020f9678c80df75d180cc874a24d80b1db08 (diff)
- Get cell value support
- Optimisation code use fmt package - Update README - Remove useless function
Diffstat (limited to 'excelize_test.go')
-rw-r--r--excelize_test.go23
1 files changed, 16 insertions, 7 deletions
diff --git a/excelize_test.go b/excelize_test.go
index b392264..5dbcdb4 100644
--- a/excelize_test.go
+++ b/excelize_test.go
@@ -1,7 +1,6 @@
package excelize
import (
- "fmt"
"strconv"
"testing"
)
@@ -10,7 +9,7 @@ func TestExcelize(t *testing.T) {
// Test update a XLSX file
file, err := OpenFile("./test/Workbook1.xlsx")
if err != nil {
- fmt.Println(err)
+ t.Error(err)
}
file = SetCellInt(file, "SHEET2", "B2", 100)
file = SetCellStr(file, "SHEET2", "C11", "Knowns")
@@ -19,21 +18,31 @@ func TestExcelize(t *testing.T) {
file = SetCellStr(file, "SHEET3", "b230", "10")
file = SetActiveSheet(file, 2)
if err != nil {
- fmt.Println(err)
+ t.Error(err)
}
for i := 1; i <= 300; i++ {
- file = SetCellStr(file, "SHEET3", fmt.Sprintf("c%d", i), strconv.Itoa(i))
+ file = SetCellStr(file, "SHEET3", "c"+strconv.Itoa(i), strconv.Itoa(i))
}
err = Save(file, "./test/Workbook_2.xlsx")
// Test create a XLSX file
file2 := CreateFile()
- file2 = NewSheet(file2, 2, "SHEETxxx")
- file2 = NewSheet(file2, 3, "asd")
+ file2 = NewSheet(file2, 2, "TestSheet2")
+ file2 = NewSheet(file2, 3, "TestSheet3")
file2 = SetCellInt(file2, "Sheet2", "A23", 10)
file2 = SetCellStr(file2, "SHEET1", "B20", "10")
err = Save(file2, "./test/Workbook_3.xlsx")
if err != nil {
- fmt.Println(err)
+ t.Error(err)
}
+
+ // Test read cell value
+ file, err = OpenFile("./test/Workbook1.xlsx")
+ if err != nil {
+ t.Error(err)
+ }
+ GetCellValue(file, "Sheet2", "a5")
+ GetCellValue(file, "Sheet2", "D11")
+ GetCellValue(file, "Sheet2", "D12")
+ GetCellValue(file, "Sheet2", "E12")
}