https://github.com/qax-os/excelize
package main
import (
"fmt"
"github.com/360EntSecGroup-Skylar/excelize"
"math/rand"
"os"
)
func main() {
xlsx, err := excelize.OpenFile("./1_3.xlsx")
if err != nil {
fmt.Println(err)
os.Exit(1)
}
rows := xlsx.GetRows("菏泽实验中学")
i := 0
var list1 = make([]string, 0)
var list2 = make([]string, 0)
var list3 = make([]string, 0)
var list4 = make([]string, 0)
var list5 = make([]string, 0)
for _, row := range rows {
if i == 0 {
i++
continue
}
for _, colCell := range row {
fmt.Print(colCell, "\t")
i++
fmt.Println(i)
flag := true
for flag {
i2 := rand.Int() % 5
fmt.Println(i2)
switch i2 {
case int(0):
if len(list1) != 10 {
fmt.Println(11111111)
list1 = append(list1, colCell)
flag = false
fmt.Println("退出循环")
}
case int(1):
if len(list2) <= 10 {
list2 = append(list2, colCell)
flag = false
}
case int(2):
if len(list3) <= 10 {
list3 = append(list3, colCell)
flag = false
}
case int(3):
if len(list4) <= 10 {
list4 = append(list4, colCell)
flag = false
}
case int(4):
if len(list5) <= 10 {
list5 = append(list5, colCell)
flag = false
}
}
}
break
}
fmt.Println()
}
fmt.Println(list1)
fmt.Println(list2)
fmt.Println(list3)
fmt.Println(list4)
fmt.Println(list5)
for true {
}
}