如何在ASP页面中调用EXCEL数据
如何在ASP页面中像调用ACCESSS一样调用EXCEL数据,用ODBC已试过,不行. 问题点数:20、回复次数:3Top
1 楼playyuer(退休干部 卧鼠藏虫)回复于 2001-06-06 22:24:00 得分 0
'OLE DB + ODBC Driver 方式:
'adoConnection.Open "Data Provider=MSDASQL.1;driver=Microsoft Excel Driver (*.xls);DBQ=e:\temp\book2.xls"
'Microsoft.Jet.OLEDB.4.0 方式,(建议)
adoConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=e:\temp\book2.xls;Extended Properties='Excel 8.0;HDR=Yes'"
参阅:
HOWTO: Transfer Data from ADO Data Source to Excel with ADO
http://support.microsoft.com/support/kb/articles/Q295/6/46.asp
HOWTO: Transfer Data from an ADO Recordset to Excel with Automation
http://support.microsoft.com/support/kb/articles/Q246/3/35.ASP Top
2 楼playyuer(退休干部 卧鼠藏虫)回复于 2001-06-07 13:31:00 得分 20
<%
Dim adoConnection
Set adoConnection = Server.CreateObject("ADODB.Connection")
'OLE DB + ODBC Driver 方式:
'adoConnection.Open "Data Provider=MSDASQL.1;driver=Microsoft Excel Driver (*.xls);DBQ=e:\temp\book2.xls"
'Microsoft.Jet.OLEDB.4.0 方式,(建议)
adoConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=e:\temp\book2.xls;Extended Properties='Excel 8.0;HDR=Yes'"
Dim adoRecordset
Set adoRecordset = Server.CreateObject("ADODB.Recordset")
adoRecordset.Open "select * from [sheet1$]", adoConnection, adOpenKeyset, adLockOptimistic
'response.Write adoRecordset.GetString
response.Write "<TABLE border=1 width='100%'><TR><TD>" & adoRecordset.GetString(,10,"</td><td>", "</TD></TR><TR><TD>"," ") & "#</td><td colspan='" & adoRecordset.fields.count-1 & "'> </td></tr></TABLE>"
%>Top
3 楼playyuer(退休干部 卧鼠藏虫)回复于 2001-06-07 13:35:00 得分 0
<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<% dim adoConnection
dim adoRecordset
set adoConnection=Server.CreateObject("ADODB.Connection")
set adoRecordset=Server.CreateObject("ADODB.Recordset")
adoConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=e:\temp\book2.xls;Extended Properties='Excel 8.0;HDR=Yes'"
adoRecordset.Open "select * from [sheet1$]", adoConnection',1' adOpenKeyset, adLockOptimistic
response.write "<TABLE border=1 width='100%'><TR><TD>" & adoRecordset.GetString(,10,"</td><td>", "</TD></TR><TR><TD>"," ") & "#</td><td colspan='" & adoRecordset.fields.count-1 & "'> </td></tr></TABLE>"
adoRecordset.close
set adoRecordset=nothing
adoConnection.close
set adoConnection=nothing
%>
</BODY>
</HTML>Top




