public DataSet ExcelToDataSet(string ExcelFile, string SheetName) { DataSet ds = new DataSet(); string ConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + ExcelFile + ";Extended Properties=Excel 8.0;"; OleDbConnection Conn = new OleDbConnection(ConnString); try { Conn.Open(); } catch(Exception e) { } string Select = "SELECT * FROM [" + SheetName + "$]"; OleDbCommand Command = new OleDbCommand(Select, Conn); OleDbDataAdapter Adapter = new OleDbDataAdapter(); Adapter.SelectCommand = Command; Adapter.Fill(ds); Conn.Close(); return ds; }