C # CODE
---------------------------------------------
<% @ Page language = "c #"%>
<% @ Import namespace = "system.data"%>
<% @ Import namespace = "system.data.ado"%>
Protected Void Page_Load (Object SRC, Eventargs E)
{
String strconn;
StrConn = "provider = microsoft.jet.Oledb.4.0;"
"Data Source = C: //ExCeltest.xls;"
"Extended Properties = Excel 8.0;";
AdoDataSetCommand mycommand = new adodatasetcommand ("SELECT * FROM [Sheet1 $], STRCONN);
Dataset mydataset = new dataset ();
MyCommand.FillDataSet (MyDataSet, "Excelinfo");
DataGrid1.datasource = myDataSet.tables ["excelinfo"]. Defaultview;
DataGrid1.databind ();
}
script>
VB.NET CODE
----------------------------------------------
<% @ Page language = "vb"%>
<% @ Import namespace = "system.data"%>
<% @ Import namespace = "system.data.ado"%>
SUB Page_Load (Sender As Object, E as Eventargs)
DIM MyDataSet As New Dataset ()
DIM STRCONN AS STRING = "provider = microsoft.jet.Oledb.4.0;" _
& "Data Source = C: /EXCELTEST.XLS;" _
& "Extended Properties =" "Excel 8.0;" "" "
Dim myadodatasetcommand as new adodatasetcommand ("Select * from [Sheet1 $], STRCONN)
Myadodatasetcommand.tablemappings.add ("Table", "Exceltest") myadodatasetcommand.FillDataSet (MyDataSet)
DataGrid1.datasource = myDataSet.tables (0) .defaultview
DataGrid1.databind ()
End Sub
script>