https://github.com/qax-os/excelize

    1. package main
    2. import (
    3. "fmt"
    4. "github.com/360EntSecGroup-Skylar/excelize"
    5. "math/rand"
    6. "os"
    7. )
    8. func main() {
    9. xlsx, err := excelize.OpenFile("./1_3.xlsx")
    10. if err != nil {
    11. fmt.Println(err)
    12. os.Exit(1)
    13. }
    14. rows := xlsx.GetRows("菏泽实验中学")
    15. i := 0
    16. var list1 = make([]string, 0)
    17. var list2 = make([]string, 0)
    18. var list3 = make([]string, 0)
    19. var list4 = make([]string, 0)
    20. var list5 = make([]string, 0)
    21. for _, row := range rows {
    22. if i == 0 {
    23. i++
    24. continue
    25. }
    26. for _, colCell := range row {
    27. fmt.Print(colCell, "\t")
    28. i++
    29. fmt.Println(i)
    30. flag := true
    31. for flag {
    32. i2 := rand.Int() % 5
    33. fmt.Println(i2)
    34. switch i2 {
    35. case int(0):
    36. if len(list1) != 10 {
    37. fmt.Println(11111111)
    38. list1 = append(list1, colCell)
    39. flag = false
    40. fmt.Println("退出循环")
    41. }
    42. case int(1):
    43. if len(list2) <= 10 {
    44. list2 = append(list2, colCell)
    45. flag = false
    46. }
    47. case int(2):
    48. if len(list3) <= 10 {
    49. list3 = append(list3, colCell)
    50. flag = false
    51. }
    52. case int(3):
    53. if len(list4) <= 10 {
    54. list4 = append(list4, colCell)
    55. flag = false
    56. }
    57. case int(4):
    58. if len(list5) <= 10 {
    59. list5 = append(list5, colCell)
    60. flag = false
    61. }
    62. }
    63. }
    64. break
    65. }
    66. fmt.Println()
    67. }
    68. fmt.Println(list1)
    69. fmt.Println(list2)
    70. fmt.Println(list3)
    71. fmt.Println(list4)
    72. fmt.Println(list5)
    73. for true {
    74. }
    75. }