Flyinsky

志在四方,浪迹天涯

导航

read and write excel file as a table

string strFileName = "c:\***.xls";
string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strFileName + ";Extended Properties=Excel 8.0;";

System.Data.OleDb.OleDbConnection EConn=new System.Data.OleDb.OleDbConnection(strConn); 
EConn.Open();
System.Data.OleDb.OleDbCommand ECmd=new System.Data.OleDb.OleDbCommand();
ECmd.Connection = EConn;
ECmd.CommandText = "SELECT * FROM myRange";

"myRange" in SQL is the name of  the range you have selected in Excel file.

 

posted on 2004-05-20 11:40  flyinsky  阅读(716)  评论(0编辑  收藏  举报