/// <summary> /// 使用oledb连接Excel /// </summary> /// <param name="_fileUrl"></param> /// <param name="pageName"></param> /// <returns></returns> public DataSet ExcelConn(string _fileUrl, string pageName) { string filePath = _fileUrl; OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filePath + ";Extended Properties=\"Excel 8.0;IMEX=1\""); conn.Open(); OleDbCommand cmd = new OleDbCommand("SELECT * FROM [" + pageName + "$]", conn); OleDbDataAdapter da = new OleDbDataAdapter(cmd); DataSet ds = new DataSet(); da.Fill(ds);
conn.Close(); return ds; }
实例:导入Excel.rar
转载于:https://www.cnblogs.com/wuhenke/archive/2010/04/08/1707710.html
相关资源:C# Excel导出无需安装Excel