标签:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.OleDb;
namespace Framework.Common
{
public class CommonClass
{
public static DataSet ExecleDs(string filenameurl, string table)
{
DataSet ds = new DataSet();
string strConn = "Provider=Microsoft.Jet.Oledb.4.0;Data Source=" + filenameurl + ";Extended Properties=‘Excel 8.0;HDR=YES;IMEX=1;‘";
using (OleDbConnection conn = new OleDbConnection(strConn))
{
conn.Open();
string tableName = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null).Rows[0][2].ToString().Trim();
OleDbDataAdapter odda = new OleDbDataAdapter("select * from [" + tableName + "]", conn);
odda.Fill(ds, table);
}
return ds;
}
}
}
标签:
原文地址:http://www.cnblogs.com/xsj1989/p/5125315.html