public static IEnumerable <ImportModel> EnumerateData(string xlsxpath) { // Открываем книгу using (var workbook = new XLWorkbook(xlsxpath)) { IXLWorksheet worksheet = workbook.Worksheets.Worksheet(1); { var totalRows = worksheet.RowsUsed().Count(); // Перебираем диапазон нужных строк for (int row = 2; row <= totalRows; ++row) { // По каждой строке формируем объект var metric = new ImportModel { Name = worksheet.Cell(row, 1).GetValue <string>(), date_start = Convert.ToDateTime(worksheet.Cell(row, 2).GetValue <string>()), duration = worksheet.Cell(row, 3).GetValue <int>(), delay = worksheet.Cell(row, 4).GetValue <int>(), responsible = worksheet.Cell(row, 6).GetValue <string>(), }; // И возвращаем его yield return(metric); } } } }
private void CreateData(HeaderedGanttRowGroup rowgroup, ImportModel item) { // Create and data var row1 = gant_grid.CreateGanttRow(rowgroup, item.Name); System.Windows.Media.Brush brush = Brushes.Green; gant_grid.AddGanttTask(row1, new GanttTask() { Start = item.date_start, End = item.date_end, Name = item.responsible }); }