您的位置:首页 > 其它

read and write excel file as a table

2004-05-20 11:40 671 查看
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.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: