0

我想知道提交后是否可以将我的asp经典表单保存到列中的excel文件中?

谢谢你们。

4

2 回答 2

1

use the Microsoft.Jet.OLEDB Driver to access the excel sheet like so:

dim conn : set conn = server.createObject("ADODB.Connection")
dim rs : set rs = server.createObject("adodb.recordset")
dim sql

conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &_
          "myExcelFile.xls;" &_
          "Extended Properties=""Excel 8.0;HDR=YES;"""

then you yould use just sql to insert your data...

the possible connectionstrings for excel are listed here

于 2012-07-05T10:12:52.330 回答
0

下面的代码是插入到现有的 Excel 文件中。这就是您所需要的。

<%
    Option Explicit 

    ' OPEN DATABASE 
    dim objConn,strConnection,objRS,strQuery

'Set objConn = New ADODB.Connection 
    set objConn = Server.CreateObject("ADODB.Connection") 
    objConn.ConnectionString = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("TEST.xls") & "; Extended Properties=Excel 8.0;" 
    objConn.Open strConnection 

'Set objRS = New ADODB.Recordset
    set objRS = Server.CreateObject("ADODB.Recordset") 
    set objRS.ActiveConnection = objConn 

' This is to Select A1:A1 and open the recordset     
    strQuery = "SELECT * FROM A1:A1" 
    objRS.Open strQuery 

' This is to insert into A1:A1 a value that says: testttest     
    strQuery = "insert into [A1:A1] values('testttest')" 

' Close and destroy the Connection object. 
    objConn.Execute strQuery 
    objConn.Close
    Set objRS=Nothing
    Set objConn=Nothing
%>

更新特定列

您可以这样做:请参见此处:http ://bytes.com/topic/asp-classic/answers/620074-update-existing-excel-file-using-asp-urgent 以及此处:更新 Excel 工作表(在经典 ASP 中/Vbscript)

于 2012-07-05T18:02:44.033 回答