<script language= "C #" runat= "Server" >
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;";
' You must use the ' $ after the ' object for your reference in the spreadsheet
Adodatasetcommand mycommand = new Adodatasetcommand ("SELECT * from [sheet1$]", strconn);
<script language= "VB" runat= "Server" >
Sub Page_Load (sender as Object, E as EventArgs)
Dim myDataSet as New DataSet ()
' can also use the Excel ODBC driver I believe-didn ' t try though
Dim strconn as String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\exceltest.xls;" & _
"Extended properties=" "Excel 8.0;" ""
' You must use the ' $ after the ' object for your reference in the spreadsheet
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>
<p><asp:label id=label1 runat= "Server" >spreadsheet contents:</asp:label></p>
<asp:datagrid id=datagrid1 runat= "Server"/>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.