public ActionResult ExcelImport(byte[] files) { //if (Request != null) //{ // HttpPostedFileBase file = Request.Files[0]; // if ((file != null) && (file.ContentLength > 0) && !string.IsNullOrEmpty(file.FileName)) // { // string fileName = file.FileName; // string fileContentType = file.ContentType; // byte[] fileBytes = new byte[file.ContentLength]; // var data = file.InputStream.Read(fileBytes, 0, Convert.ToInt32(file.ContentLength)); // } //} IGumruk iGumruk = new BSGumruk(); if (Request != null) { List <ColumnToExcel> listCltoExcel = new List <ColumnToExcel>(); HttpPostedFileBase file = Request.Files[0]; if ((file != null) && (file.ContentLength > 0) && !string.IsNullOrEmpty(file.FileName)) { string fileName = file.FileName; string fileContentType = file.ContentType; byte[] fileBytes = new byte[file.ContentLength]; var data = file.InputStream.Read(fileBytes, 0, Convert.ToInt32(file.ContentLength)); var usersList = new List <d_b_columns>(); using (var package = new ExcelPackage(file.InputStream)) { var currentSheet = package.Workbook.Worksheets; var workSheet = currentSheet.First(); var noOfCol = workSheet.Dimension.End.Column; var noOfRow = workSheet.Dimension.End.Row; string tableName; string schemaName; string columnName; bool allowNull; string type; string exp1; string exp2; bool primary; string lookup; string link; string formAlani; string systemType; for (int rowIterator = 2; rowIterator <= noOfRow; rowIterator++) { schemaName = (workSheet.Cells[rowIterator, 2].Value == null) ? "" : workSheet.Cells[rowIterator, 2].Value.ToString(); tableName = (workSheet.Cells[rowIterator, 3].Value == null) ? "" : workSheet.Cells[rowIterator, 3].Value.ToString(); columnName = (workSheet.Cells[rowIterator, 4].Value == null) ? "" : workSheet.Cells[rowIterator, 4].Value.ToString(); primary = (workSheet.Cells[rowIterator, 5].Value == null) ? false : bool.Parse(workSheet.Cells[rowIterator, 5].Value.ToString()); allowNull = (workSheet.Cells[rowIterator, 6].Value == null) ? false : bool.Parse(workSheet.Cells[rowIterator, 6].Value.ToString()); type = (workSheet.Cells[rowIterator, 7].Value == null) ? "" : workSheet.Cells[rowIterator, 7].Value.ToString(); exp1 = (workSheet.Cells[rowIterator, 8].Value == null) ? "" : workSheet.Cells[rowIterator, 8].Value.ToString(); exp2 = (workSheet.Cells[rowIterator, 9].Value == null) ? "" : workSheet.Cells[rowIterator, 9].Value.ToString(); lookup = (workSheet.Cells[rowIterator, 10].Value == null) ? "" : workSheet.Cells[rowIterator, 10].Value.ToString(); link = (workSheet.Cells[rowIterator, 11].Value == null) ? "" : workSheet.Cells[rowIterator, 11].Value.ToString(); formAlani = (workSheet.Cells[rowIterator, 12].Value == null) ? "" : workSheet.Cells[rowIterator, 12].Value.ToString(); systemType = (workSheet.Cells[rowIterator, 13].Value == null) ? "" : workSheet.Cells[rowIterator, 13].Value.ToString(); //veriler excel'den alındı. İlgili tablolara atılması gerekiyor. ColumnToExcel cl = new ColumnToExcel(); cl.AllowNull = allowNull.ToString(); cl.Explanation1 = exp1; cl.Explanation2 = exp2; cl.Field = columnName; cl.FormAlani = formAlani; cl.Link = link; cl.LookUp = lookup; cl.Module = ""; cl.Primary = primary.ToString(); cl.Schema = schemaName; cl.SystemType = systemType; cl.Table = tableName; cl.Type = type; cl.UserID = GetCurrentUser().id; listCltoExcel.Add(cl); } } iGumruk.ExcelImport(listCltoExcel); } } return(View("Index")); }