hai can u make it out
-
try the code below...this is just a snippet....you have to properly declare the variables or path of the file and you have to check for proper file name and extension also where needed....
Dim conStr As String = "provider=Microsoft.Jet.OLEDB.4.0;data source=" + filepath + "; Extended Properties=Excel 8.0;" ''"filepath" is the path of the .xls file Dim sql As String = "select * from [Sheet1$]" ''"Sheet1" is the name of the excel sheet MyConnection = New System.Data.OleDb.OleDbConnection(conStr) MyConnection.Open() MyAdapter = New System.Data.OleDb.OleDbDataAdapter(sql, MyConnection) dim myDs As DataSet = New System.Data.DataSet MyAdapter.Fill(myDs)
let me know if you face any problem TirthadipLive life to the fullest
-
Here is a C# code //------------------------------------------- private DataSet PerformQueryIntoDataSet(string strFileName,string sheetName) { string strConn; strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + strFileName + ";" + "Extended Properties=" + Convert.ToChar(34).ToString() + "Excel 8.0;HDR=YES; IMEX=1;" + Convert.ToChar(34).ToString(); //You must use the $ after the object you reference in the spreadsheet OleDbDataAdapter myCommand = new OleDbDataAdapter("SELECT * FROM ["+ sheetName + "$]", strConn); DataSet myData = new DataSet(); myCommand.Fill(myData, sheetName); return myData; } //-------------------------------------------