これは私のコードです。324k 行以上のスプレッドシートに接続し、html ページのテーブルに値を返す必要があります。関数は正しく機能し、値を返します。ページをリロードせずに現在のテーブルを更新するだけで、「再検索」ボタンが機能せず、機能を再度開始することができません。HTML Web ページ タイプのインターフェイスである必要があります。しかし、Javascript と VBScript のどちらかを選択できます。セキュリティのため、一部の名前を外しています。
<!DOCTYPE html>
<html>
<head>
<title>CS Number Search Tool</title>
<table id="Header" border="1" bgcolor="E6E7F5">
<thead bgcolor="69BDF5">
<tr>
<th width="1130"><font color="F2F2F2" />the title i created</th>
</tr>
</thead>
</table>
<table id="Incidents" border="1" summary="CS Search Results">
<thead bgcolor="DAF0F5">
<tr >
<th></th>
</tr>
</thead>
</table>
<button onclick="vbscript:ReadExcel()">Search</button>
</head>
<body>
<script Language="VBScript" type="text/vbscript">
Option Explicit
Dim idTimer
function ReadExcel()
Dim myXlsFile
myXlsFile = "path\\reprogrammingticketsPOX.xlsb"
Dim mySheet
mySheet = "Sheet1"
Dim my1stCell
my1stCell = "A1"
Dim myLastCell
myLastCell = "F324375"
Dim blnHeader
blnHeader = True
Dim srcphr, Message
Dim Title
Message = "Please Enter A Number To Search"
Title = "CS Search Tool TycoIS"
srcphr = InputBox(Message, Title)
If srcphr = "" Then
Exit Function
End If
Dim arrData( ), i, j
Dim objExcel, objRS
Dim strHeader, strRange
Const adOpenForwardOnly = 0
Const adOpenKeyset = 1
Const adOpenDynamic = 2
Const adOpenStatic = 3
' Define header parameter string for Excel object
If blnHeader Then
strHeader = "HDR=YES;"
Else
strHeader = "HDR=NO;"
End If
' Open the object for the Excel file
Set objExcel = CreateObject( "ADODB.Connection" )
' With IMEX=1 numbers won't be ignored; tip by Thomas Willig.
' Connection string updated by Marcel Niënkemper to open Excel 2007 (.xslx) files.
objExcel.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" _
& myXlsFile & ";Extended Properties=""Excel 12.0;HDR=YES;IMEX=1;Format=xlsb;" _
& strHeader & """"
' Open a recordset object for the sheet and range
Set objRS = CreateObject( "ADODB.Recordset" )
strRange = mySheet & "$" & my1stCell & ":" & myLastCell
objRS.Open "SELECT * FROM [" & strRange & "] WHERE [CS_No]= '" & srcphr & "' OR [Cust_No]='" & srcphr & "' OR [Job_No]='" & srcphr & "' OR [New_CS_No]='" & srcphr & "' " , objExcel, adOpenStatic
' Read the data from the Excel sheet
i = 0
Do Until objRS.EOF
' Stop reading when an empty row is encountered in the Excel sheet
If IsNull( objRS.Fields(0).Value ) Or Trim( objRS.Fields(0).Value ) = "" Then Exit Do
' Add a new row to the output array
ReDim Preserve arrData( objRS.Fields.Count - 1, i )
' Copy the Excel sheet's row values to the array "row"
' IsNull test credits: Adriaan Westra
For j = 0 To objRS.Fields.Count - 1
If IsNull( objRS.Fields(j).Value ) Then
arrData( j, i ) = ""
Else
arrData( j, i ) = Trim( objRS.Fields(j).Value )
End If
Next
' Move to the next row
objRS.MoveNext
' Increment the array "row" number
i = i + 1
Loop
' Close the file and release the objects
objRS.Close
objExcel.Close
Set objRS = Nothing
Set objExcel = Nothing
' Return the results
ReadExcel = arrData
Call writeTable(arrData)
End function
sub writeTable(arrData)
Dim intCount, objSheet
For intCount = 0 To UBound( arrData, 2 )
document.write "<!DOCTYPE html>"
document.write "<html>"
document.write "<head>"
document.write "<title>CS Number Search Tool</title>"
document.write "<table id='Header' border='1' bgcolor='E6E7F5'>"
document.write "<thead bgcolor='69BDF5'>"
document.write "<tr>"
document.write "<th width='1130'><font color='F2F2F2' />Tyco Integrated Security - Panel Reprogramming Project CS Search</th>"
document.write "</tr>"
document.write "</thead>"
document.write "</table>"
document.write "<table id='Incidents' border='1'>"
document.write "<tbody bgcolor='DAF0F5'>"
document.write "<tr>"
document.write "<th width='200px'>Old CS Number <BR>"& arrData( 0, intCount ) &"</th>"
document.write "<th width='150px'>Site Number <BR>"& arrData( 1, intCount ) &"</th>"
document.write "<th width='150px'>Customer Number <BR>"& arrData( 2, intCount ) &"</th>"
document.write "<th width='150px'>Job Number <BR>"& arrData( 3, intCount ) &"</th>"
document.write "<th width='150px'>New CS Number <BR>"& arrData( 4, intCount ) &"</th>"
document.write "<th width='300px'>Source Sheet <BR>"& arrData( 5, intCount ) &"</th>"
document.write "</tr>"
document.write "</tbody>"
document.write "</table>"
document.write "</head>"
document.write "</html>"
Next
Call searchExcel()
End sub
Sub searchExcel()
document.write "<button onclick=ReadExcel()>Search Again</button>"
End Sub
</script>
</body>
</html>