excelize_test.go 974 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package excelize
  2. import (
  3. "fmt"
  4. "strconv"
  5. "testing"
  6. )
  7. func TestExcelize(t *testing.T) {
  8. // Test update a XLSX file
  9. file, err := OpenFile("./test/Workbook1.xlsx")
  10. if err != nil {
  11. fmt.Println(err)
  12. }
  13. file = SetCellInt(file, "SHEET2", "B2", 100)
  14. file = SetCellStr(file, "SHEET2", "C11", "Knowns")
  15. file = NewSheet(file, 3, "TestSheet")
  16. file = SetCellInt(file, "Sheet3", "A23", 10)
  17. file = SetCellStr(file, "SHEET3", "b230", "10")
  18. file = SetActiveSheet(file, 2)
  19. if err != nil {
  20. fmt.Println(err)
  21. }
  22. for i := 1; i <= 300; i++ {
  23. file = SetCellStr(file, "SHEET3", fmt.Sprintf("c%d", i), strconv.Itoa(i))
  24. }
  25. err = Save(file, "./test/Workbook_2.xlsx")
  26. // Test create a XLSX file
  27. file2 := CreateFile()
  28. file2 = NewSheet(file2, 2, "SHEETxxx")
  29. file2 = NewSheet(file2, 3, "asd")
  30. file2 = SetCellInt(file2, "Sheet2", "A23", 10)
  31. file2 = SetCellStr(file2, "SHEET1", "B20", "10")
  32. err = Save(file2, "./test/Workbook_3.xlsx")
  33. if err != nil {
  34. fmt.Println(err)
  35. }
  36. }