Selaa lähdekoodia

thx to tealeg 6

Dasflugen 5 vuotta sitten
vanhempi
commit
94fad7f40c
1 muutettua tiedostoa jossa 20 lisäystä ja 20 poistoa
  1. 20 20
      schedule/xlsx.go

+ 20 - 20
schedule/xlsx.go

@@ -28,11 +28,11 @@ func ImportXLSX(filename string) []*PlanXLSX {
         plan.GroupNumber   = strings.Split(splited[len(splited)-1], "-")[0]
 
         sheet.ForEachRow(func(row *Row) error {
-            splited := strings.Split(row.Cells[1].String(), ".")
-            if i >= 20 && len(row.Cells) >= 20 && len(row.Cells)>=20 && !(row.Cells[2].String() == "" || row.Cells[2].String() == "ИТОГО") && !(strings.HasPrefix(row.Cells[1].String(), "Консультации") || strings.HasPrefix(row.Cells[1].String(), "Государственная")) && len(splited) == 2{
+            splited := strings.Split(row.GetCell(1).Value.String(), ".")
+            if i >= 20 && len(row.Cells) >= 20 && len(row.Cells)>=20 && !(row.GetCell(2).Value.String() == "" || row.GetCell(2).Value.String() == "ИТОГО") && !(strings.HasPrefix(row.GetCell(1).Value.String(), "Консультации") || strings.HasPrefix(row.GetCell(1).Value.String(), "Государственная")) && len(splited) == 2{
                 typerow := TypeRow(IsSubTR)
             switch {
-            case strings.Contains(row.Cells[2].String(), "цикл"):
+            case strings.Contains(row.GetCell(2).Value.String(), "цикл"):
                 typerow = IsCycleTR
             case splited[1] == "00":
                 typerow = IsStartTR
@@ -40,23 +40,23 @@ func ImportXLSX(filename string) []*PlanXLSX {
                 typerow = IsPmTR
             }
 
-            max, _       := row.GetCell(4).Int()
-            selfstudy, _ := row.GetCell(5).Int()
-            allstudy, _  := row.GetCell(6).Int()
-            lectures, _  := row.GetCell(7).Int()
-            labs, _      := row.GetCell(8).Int()
-            projects, _  := row.GetCell(9).Int()
-            c1s1, _      := row.GetCell(12).Int()
-            c1s2, _      := row.GetCell(13).Int()
-            c2s1, _      := row.GetCell(14).Int()
-            c2s2, _      := row.GetCell(15).Int()
-            c3s1, _      := row.GetCell(16).Int()
-            c3s2, _      := row.GetCell(17).Int()
-            c4s1, _      := row.GetCell(18).Int()
-            c4s2, _      := row.GetCell(19).Int()
+            max, _       := row.GetCell(4).Value.Int()
+            selfstudy, _ := row.GetCell(5).Value.Int()
+            allstudy, _  := row.GetCell(6).Value.Int()
+            lectures, _  := row.GetCell(7).Value.Int()
+            labs, _      := row.GetCell(8).Value.Int()
+            projects, _  := row.GetCell(9).Value.Int()
+            c1s1, _      := row.GetCell(12).Value.Int()
+            c1s2, _      := row.GetCell(13).Value.Int()
+            c2s1, _      := row.GetCell(14).Value.Int()
+            c2s2, _      := row.GetCell(15).Value.Int()
+            c3s1, _      := row.GetCell(16).Value.Int()
+            c3s2, _      := row.GetCell(17).Value.Int()
+            c4s1, _      := row.GetCell(18).Value.Int()
+            c4s2, _      := row.GetCell(19).Value.Int()
 
             certform := ""
-            splited = strings.Split(row.Cells[3].String(), ",")
+            splited = strings.Split(row.GetCell(3).Value.String(), ",")
             for _, v := range splited {
                 if v != "-" {
                     certform = v
@@ -65,8 +65,8 @@ func ImportXLSX(filename string) []*PlanXLSX {
             }
 
             plan.Lines = append(plan.Lines, LineXLSX{
-                ID:        row.Cells[1].String(),
-                Name:      row.Cells[2].String(),
+                ID:        row.GetCell(1).Value.String(),
+                Name:      row.GetCell(2).Value.String(),
                 CertForm:  certform,
                 StudyLoad: StudyLoadXLSX{
                     Max:       max,