public string edit(ExcelDataRow row) { var dbRow = ctx.ExcelDataTables.Find(row.idRow); dbRow.Data = JsonConvert.SerializeObject(row); ctx.SaveChanges(); return("edited."); }
public List <ExcelDataRow> getRowsFromExcel(string path) { IWorkbook wb; var fs = new FileStream(path, FileMode.Open); try { wb = new XSSFWorkbook(fs); } catch (Exception) { fs.Close(); fs = new FileStream(path, FileMode.Open); wb = new HSSFWorkbook(fs); } var rows = new List <ExcelDataRow>(); for (int sheetN = 0; sheetN < 2; sheetN++) { var sheet = wb.GetSheetAt(sheetN); var nextRow = sheet.GetRow(1); if (nextRow == null) { return(null); } var dataRow = new ExcelDataRow(); for (int i = 0; i < 20; i++) { dataRow.cells[i] = getValueFromCell(nextRow.GetCell(i)); } rows.Add(dataRow); } return(rows); }