summaryrefslogtreecommitdiff
path: root/excelize_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'excelize_test.go')
-rw-r--r--excelize_test.go66
1 files changed, 30 insertions, 36 deletions
diff --git a/excelize_test.go b/excelize_test.go
index 3751775..d206e2d 100644
--- a/excelize_test.go
+++ b/excelize_test.go
@@ -7,57 +7,51 @@ import (
func TestExcelize(t *testing.T) {
// Test update a XLSX file
- file, err := OpenFile("./test/Workbook1.xlsx")
- if err != nil {
- t.Log(err)
+ file := OpenFile("./test/Workbook1.xlsx")
+ file.SetCellInt("SHEET2", "B2", 100)
+ file.SetCellStr("SHEET2", "C11", "Knowns")
+ file.NewSheet(3, "TestSheet")
+ file.SetCellInt("Sheet3", "A23", 10)
+ file.SetCellStr("SHEET3", "b230", "10")
+ file.SetCellStr("SHEET10", "b230", "10")
+ file.SetActiveSheet(2)
+ for i := 1; i <= 300; i++ {
+ file.SetCellStr("SHEET3", "c"+strconv.Itoa(i), strconv.Itoa(i))
}
- file = SetCellInt(file, "SHEET2", "B2", 100)
- file = SetCellStr(file, "SHEET2", "C11", "Knowns")
- file = NewSheet(file, 3, "TestSheet")
- file = SetCellInt(file, "Sheet3", "A23", 10)
- file = SetCellStr(file, "SHEET3", "b230", "10")
- file = SetActiveSheet(file, 2)
+ err := file.Save()
if err != nil {
t.Log(err)
}
- for i := 1; i <= 300; i++ {
- file = SetCellStr(file, "SHEET3", "c"+strconv.Itoa(i), strconv.Itoa(i))
- }
- err = Save(file, "./test/Workbook_2.xlsx")
+ // Test write file to given path
+ err = file.WriteTo("./test/Workbook_2.xlsx")
if err != nil {
t.Log(err)
}
-
- // Test save to not exist directory
- err = Save(file, "")
+ // Test write file to not exist directory
+ err = file.WriteTo("")
if err != nil {
t.Log(err)
}
// Test create a XLSX file
file2 := CreateFile()
- file2 = NewSheet(file2, 2, "TestSheet2")
- file2 = NewSheet(file2, 3, "TestSheet3")
- file2 = SetCellInt(file2, "Sheet2", "A23", 10)
- file2 = SetCellStr(file2, "SHEET1", "B20", "10")
- file2 = SetActiveSheet(file2, 0)
- err = Save(file2, "./test/Workbook_3.xlsx")
+ file2.NewSheet(2, "XLSXSheet2")
+ file2.NewSheet(3, "XLSXSheet3")
+ file2.SetCellInt("Sheet2", "A23", 56)
+ file2.SetCellStr("SHEET1", "B20", "42")
+ file2.SetActiveSheet(0)
+ err = file2.WriteTo("./test/Workbook_3.xlsx")
if err != nil {
t.Log(err)
}
- // Test read cell value
- file, err = OpenFile("./test/Workbook1.xlsx")
- if err != nil {
- t.Log(err)
- }
- // Test given illegal rows number
- GetCellValue(file, "Sheet2", "a-1")
- // Test given lowercase column number
- GetCellValue(file, "Sheet2", "a5")
- GetCellValue(file, "Sheet2", "C11")
- GetCellValue(file, "Sheet2", "D11")
- GetCellValue(file, "Sheet2", "D12")
- // Test given axis large than exists row
- GetCellValue(file, "Sheet2", "E13")
+ // Test read cell value with given illegal rows number
+ file.GetCellValue("Sheet2", "a-1")
+ // Test read cell value with given lowercase column number
+ file.GetCellValue("Sheet2", "a5")
+ file.GetCellValue("Sheet2", "C11")
+ file.GetCellValue("Sheet2", "D11")
+ file.GetCellValue("Sheet2", "D12")
+ // Test read cell value with given axis large than exists row
+ file.GetCellValue("Sheet2", "E13")
}