web| Create | spreadsheet | data | In addition to the technology of "reading Excel data to form HTML tables," You might be interested in learning how to use the program to implement a list of spreadsheet and name-range Drop-down menus.
In addition to the contents of the cell, you can know more information with ADO--on top, we've discussed using it to get a list of field names.
Call the OpenSchema method to get a special set of records that currently open the database (also applicable to the electronic Data Book), where the spreadsheet and name range for the current electronic data book are retrieved from the routines discussed here. In the operation of the database, the information of all tables can be obtained by passing to the ADO a adschematablesas command parameter.
Set oschemars = Oconn.openschema (adSchemaTables)
The above call returns a recordset information, and for file Theworkbook.xls, the result is:
TABLE_NAME Table_type
employees$ SYSTEM TABLE
listofproducts$ SYSTEM TABLE
suppliers$ SYSTEM TABLE
A_duplicate_name TABLE
Alphabetical_list_of_products TABLE
Employees TABLE
Listofproducts$a_duplicate_name TABLE
Product_totals TABLE
The spreadsheet in the Electronic Data Workbook (worksheets) is treated as a system table and the name range is treated as a common table compared to the recordset. Usually, the nameless range can be used! ) is not reported by the recordset.
With this information in hand, creating a field drop-down menu is the work of separating the two table types and using the appropriate tags. For example, you can perform the following html/asp code snippet to create a drop-down menu of worksheet lists:
< select Name= "Xlsheet" >
<%
voptions = "< option ></option >"
Do as not oschemars.eof
If oschemars ("table_type") = "SYSTEM TABLE" Then
Voptions = voptions & "< option >" & _
Server.HTMLEncode (Oschemars ("table_name")) & _
"</option >
End If
Oschemars.movenext
Loop
Response.Write Voptions
% >
</select >
The actual readx1.asp code may be more complex, because the display of the previous option is processed, and the client's JavaScript script is used to check the legality of the input.