public static List <MadeService> getMadeServices(string filename) { FileInfo file = new FileInfo(filename); List <MadeService> madeServList = new List <MadeService>(); using (ExcelPackage package = new ExcelPackage(file)) { ExcelWorksheet worksheet = package.Workbook.Worksheets.FirstOrDefault(); int rowCount = worksheet.Dimension.Rows; int startRow = 6; string dtFormat = "dd-MM-yyyy"; for (int row = startRow; row <= rowCount; row++) { MadeService ms = new MadeService(); ms.Id = Int32.Parse(worksheet.Cells[row, 1].Value.ToString()); ms.Date = DateTime.ParseExact(worksheet.Cells[row, 2].Value.ToString(), dtFormat, CultureInfo.InvariantCulture); ms.PatientName = worksheet.Cells[row, 6].Value.ToString(); ms.PatientPesel = worksheet.Cells[row, 8].Value.ToString(); ms.ServiceCode = ms.getServiceCode(worksheet.Cells[row, 11].Value.ToString()); ms.Unit = ms.getUnit(worksheet.Cells[row, 10].Value.ToString()); madeServList.Add(ms); } } return(madeServList); }
List <MadeService> getMadeServices(string filename) { List <MadeService> madeServList = new List <MadeService> (); int rowsToCut = 4; int rowCount = excelWorksheet.Dimension.Rows - rowsToCut; int startRow = 6; for (int row = startRow; row <= rowCount; row++) { MadeService ms = new MadeService(); ms.Id = Int32.Parse(excelWorksheet.Cells[row, 1].Value.ToString()); ms.Date = parseDateTime(excelWorksheet.Cells[row, 2].Value.ToString()); ms.PatientName = excelWorksheet.Cells[row, 6].Value.ToString(); ms.PatientPesel = excelWorksheet.Cells[row, 8].Value.ToString(); ms.ServiceCode = ms.getServiceCode(excelWorksheet.Cells[row, 11].Value.ToString()); ms.Unit = ms.getUnit(excelWorksheet.Cells[row, 10].Value.ToString()); madeServList.Add(ms); } return(madeServList); }