Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88066

query for reading data from excel sheet in c#

$
0
0

Thanks Astander for replying to my query

I am here with more detailed query.

        string cs = "Provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source=" + @"D:\\sample.xls;" + "Excel 12.0;HDR=YES;";
        OleDbConnection Excelcon = new OleDbConnection(cs);
        OleDbDataAdapter ad = new OleDbDataAdapter();
        ad.SelectCommand = new OleDbCommand("SELECT *FROM [Sheet1$]", Excelcon);
        DataTable dt = new DataTable();
        ad.Fill(dt);
        return dt;

I am getting error at the select statement that :

The Microsoft Office Access database engine could not find the object 'Sheet1$'. Make sure the object exists and that you spell its name and the path name correctly.

Hope someone can help me find a solution.


Viewing all articles
Browse latest Browse all 88066

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>