wpsBlankLine_test.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package xlsx
  2. import (
  3. "testing"
  4. )
  5. // Test that we can successfully read an XLSX file generated by
  6. // Wps on windows. you can download it freely from http://www.wps.cn/
  7. func TestWpsBlankLine(t *testing.T) {
  8. xlsxFile, error := OpenFile("wpsBlankLineTest.xlsx")
  9. if error != nil {
  10. t.Error(error.Error())
  11. return
  12. }
  13. if xlsxFile == nil {
  14. t.Error("OpenFile returned nil FileInterface without generating an os.Error")
  15. return
  16. }
  17. sheet := xlsxFile.Sheets[0]
  18. row := sheet.Rows[0]
  19. cell := row.Cells[0]
  20. s := cell.String()
  21. expected := "编号"
  22. if s != expected {
  23. t.Errorf("[TestWpsBlankLine] expected cell A1 = '%s', but got :'%s'", expected, s)
  24. return
  25. }
  26. row = sheet.Rows[2]
  27. cell = row.Cells[0]
  28. s = cell.String()
  29. if s != expected {
  30. t.Errorf("[TestWpsBlankLine] expected cell A3 = '%s', but got :'%s'", expected, s)
  31. return
  32. }
  33. row = sheet.Rows[4]
  34. cell = row.Cells[1]
  35. s = cell.String()
  36. if s != "" {
  37. t.Errorf("[TestWpsBlankLine] expected cell B5 = '%s', but got :'%s'", "", s)
  38. return
  39. }
  40. s = sheet.Rows[4].Cells[2].String()
  41. if s != expected {
  42. t.Errorf("[TestWpsBlankLine] expected cell C5 = '%s', but got :'%s'", expected, s)
  43. return
  44. }
  45. }