private void GetTimetable_Click(object sender, EventArgs e) { Teachers = new List <string>(); ExcelPackage TeachBook = new ExcelPackage(new FileInfo(TeachPath)); ExcelWorksheet TeachSheet = TeachBook.Workbook.Worksheets[1]; for (int i = 1; i < TeachSheet.Dimension.Rows; i++) { if (!Teachers.Contains(TeachSheet.Cells[i + 1, 1].Text)) { Teachers.Add(TeachSheet.Cells[i + 1, 1].Text); } } TeachBook.Dispose(); List <String> files = new List <string>(); foreach (Control gl in CPG_Selected.Controls) { if (!files.Contains(gl.Tag.ToString())) { files.Add(gl.Tag.ToString()); } } Groups = new DataStorage(); foreach (String str in files) { LogText($"Получение расписаний из {str}"); SrcBook = new ExcelPackage(new FileInfo(str)); SrcSheet = SrcBook.Workbook.Worksheets[1]; foreach (Control grlabel in CPG_Selected.Controls) { LogText($"Получение расписания для {grlabel.Text}"); var cells = SrcSheet.Cells[2, 1, 2, SrcSheet.Dimension.Columns].Where(a => a.Text == grlabel.Text).ToList(); if (cells.Count == 1) { Int32 cellcol = cells[0].Start.Column; Groups.AddGroup(grlabel.Text); Groups.AddWeek(grlabel.Text); Groups.AddWeek(grlabel.Text); for (int i = 0; i < 6; i++) { Groups.AddDay(grlabel.Text, 0); Groups.AddDay(grlabel.Text, 1); for (int j = 0; j < 12; j++) { Groups.AddLesson(grlabel.Text, j % 2, i, SrcSheet.Cells[12 * i + 4 + j, 0 + cellcol].Text, String.Concat(SrcSheet.Cells[12 * i + 4 + j, 1 + cellcol].Text.Split('\n')), ReplaceTeacher(SrcSheet.Cells[12 * i + 4 + j, 2 + cellcol].Text), SrcSheet.Cells[12 * i + 4 + j, 3 + cellcol].Text ); /*Groups[Groups.GroupCount-1][j%2,i].AddLesson( * SrcSheet.Cells[12 * i + 4 + j, 0 + cellcol].Text, * String.Concat(SrcSheet.Cells[12 * i + 4 + j, 1 + cellcol].Text.Split('\n')), * ReplaceTeacher(SrcSheet.Cells[12 * i + 4 + j, 2 + cellcol].Text), * SrcSheet.Cells[12 * i + 4 + j, 3 + cellcol].Text * );*/ } } } } SrcBook.Dispose(); Groups.RemoveBlankLessons(); Groups.RemoveBlankDays(); } WriteTimetable(); }