posts - 5,  comments - 5,  trackbacks - 0
<%@ 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#

只有注册用户登录后才能发表评论。


网站导航:
 
<2024年11月>
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567

常用链接

留言簿(3)

随笔档案

文章分类

文章档案

相册

.net

搜索

  •  

最新评论

阅读排行榜

评论排行榜