<%@ Page Language="VB" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.Oledb" %>
<script language="VB" runat="server">
Sub Page_Load(sender As Object, e As EventArgs)
Dim myDataset As New DataSet()
Dim myOleDbConnection As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\2.xls;" & _
"Extended Properties=""Excel 8.0;""")
Dim myOleDbCommand As OleDbCommand = New OleDbCommand("SELECT * FROM [Sheet1$]",myOleDbConnection)
Dim myData As OledbDataAdapter= New OledbDataAdapter(myOleDbCommand)
myData.Fill(myDataset)
DataGrid1.DataSource = myDataset.Tables(0).DefaultView
DataGrid1.DataBind()
End Sub
</script>
<html>
<head></head>
<body>
<asp:Label id="L1" runat="server">读取C盘根目录下的test.xls文件,并以DataGrid的形式显示出来</asp:label>
<asp:DataGrid id=DataGrid1 runat="server"/>
</body>
</html>
posted on 2006-11-29 11:28
曾科 阅读(666)
评论(0) 编辑 收藏 所属分类:
C#