复制代码 代码如下:
<INPUT type="file" runat="server">
<asp:Button runat="server" Text="Button"></asp:Button>
<asp:DataGrid runat="server"></asp:DataGrid>
复制代码 代码如下:
string strPath="c://test//" + DateTime.Now.ToString("yyyyMMddhhmmss") + ".xls";
File1.PostedFile.SaveAs(strPath);
string mystring="Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source = '"+ strPath +"';Extended Properties=Excel 8.0";
OleDbConnection cnnxls = new OleDbConnection (mystring);
OleDbDataAdapter myDa =new OleDbDataAdapter("select * from [Sheet1$]",cnnxls);
DataSet myDs =new DataSet();
myDa.Fill(myDs);
DataGrid1.DataSource=myDs.Tables[0];
DataGrid1.DataBind();
新闻热点
疑难解答
图片精选