Excel .net读取

public void LoadData(string StyleSheet)
{
string strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source =" + Server.MapPath
("\\Content\\Excel\\数据填报模版_地产V2.01.xls") + ";Extended Properties=Excel 8.0";
string strExcel = "";
OleDbDataAdapter myCommand = null;
DataSet myDataSet = new DataSet();
string[] tables = { "[填写说明$]", "[经营信息$]", "[职位信息$]", "[入离职信息$]", "[内部异动信息$]", "[薪酬福利信息$]", "[招聘信息(成本)$]", "[招聘信息(执行)$]", "[培训信息$]" };
for (int i = 0; i < tables.Length; i++)
{
strExcel = "select * from "+tables[i];
myCommand = new OleDbDataAdapter(strExcel, strCon);
myCommand.Fill(myDataSet,tables[i]);
}
for (int i = 0; i < myDataSet.Tables.Count; i++)
{
DataTable table = myDataSet.Tables[i];
}
}

posted @ 2015-06-11 16:21  caijinhao  阅读(134)  评论(0编辑  收藏  举报