//Excel文件本地路径
string strConn = @"Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=C:\\Users\\Desktop\\ccccc.xlsx" + "; " + "Extended Properties='Excel 8.0;HDR=False;IMEX=1'";
OleDbConnection conn = new OleDbConnection(strConn);
conn.Open();
//查询得Sheet页
string strExcel = "select * from [Sheet1$]";
OleDbDataAdapter myCommand = new OleDbDataAdapter(strExcel, strConn);
DataSet ds = new DataSet();
myCommand.Fill(ds, "table1");
for (int i = 0; i < ds.Tables["table1"].Rows.Count; i++)
{
string Dealname = ds.Tables["table1"].Rows[i]["项目名称"].ToString();
string Type = ds.Tables["table1"].Rows[i]["文档类型"].ToString();
string DecomentName = ds.Tables["table1"].Rows[i]["文件名称"].ToString();
}
****如果在执行中报外部表格式不正确的话,需要在Excel文件打开的情况下去运行代码