在 ASP.NET 2003 中操纵 Excel2007
ccc01 2007-02-27 02:29:06 我用如下方式可以打开Excel2003文件,可打开Excel2007时就不得吃了,请问用什么
方式可以打开Excel2007文件
打开Excel2003文件的代码如下:
string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + this.tempFilePath + ";" + "Extended Properties=Excel 8.0;";
OleDbConnection conn = new OleDbConnection(strConn);
string strExcel = "";
OleDbDataAdapter command = null;
DataSet ds = null;
strExcel = "select * from [sheet1$]";
command = new OleDbDataAdapter(strExcel, strConn);
ds = new DataSet();
command.Fill(ds, "table1");
this.dataGrid.DataSource=ds.Tables[0];
this.dataGrid.DataBind();