- 积分
- 40165
- 好友
- 记录
- 主题
- 帖子
- 听众
- 收听
|
发表于 2013-8-20 16:47:18
|
显示全部楼层
[code=csharp]
/**/
/// <summary>
/// 返回Excel数据源
/// </summary>
/// <param name="filename">文件路径</param>
/// <param name="TSql">TSql</param>
/// <returns>DataSet</returns>
public static DataSet ExcelToDataSet(string filename, string TSql)
{
DataSet ds;
string strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=Excel 8.0;data source=" + filename;
OleDbConnection myConn = new OleDbConnection(strCon);
string strCom = TSql;
myConn.Open();
OleDbDataAdapter myCommand = new OleDbDataAdapter(strCom, myConn);
ds = new DataSet();
myCommand.Fill(ds);
myConn.Close();
return ds;
}
[/code]
http://www.sufeinet.com/forum.ph ... 029&highlight=excel |
|