public static List<string> GetListFromExcel(string term, int tableIndex) { string FilePath = HttpContext.Current.Server.MapPath("content\\PickList.xlsx"); ExcelFile ef = new ExcelFile(FilePath); DataSet ds = ef.GetDropDownList(); List<string> list = new List<string>(); foreach (DataRow row in ds.Tables[tableIndex].Rows) // 0 => Observation table { if (row[0].ToString().Contains(term)) { list.Add(row[0].ToString()); } } return list; }
//---------------------------------------------------- protected void PopulateDropdownFromExcel() { string FilePath = Server.MapPath("content\\PickList.xlsx"); ExcelFile ef = new ExcelFile(FilePath); DataSet ds = ef.GetDropDownList(); //-------------------------------------------------- DropDownListDataBind("ddObservation", ds.Tables[0]); DropDownListDataBind("ddDeficiency", ds.Tables[1]); }