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 曾科 阅读(668) 评论(0)  编辑  收藏 所属分类: C#

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


网站导航:
 
<2024年12月>
24252627282930
1234567
891011121314
15161718192021
22232425262728
2930311234

常用链接

留言簿(3)

随笔档案

文章分类

文章档案

相册

.net

搜索

  •  

最新评论

阅读排行榜

评论排行榜