Salve a tutti, ho realizzato un sito internet per una squadra di basket di miei amici e loro vorrebbero che la classifica sempre aggiornata sul sito, quindi vorrrei mettere una tabella che si "autocompili" prendendo da sola i dati che le servono da un documento excel (xls) pubblicato settimanalmente sul sito della lega a cui appartengono.
Per realizzare ciò ho pensato all'ASP, ma purtroppo le mie conoscenze limitate mi impediscono di poter fare ciò da solo, così ho dato un occhiata al forum e ho visto che già altri si sono posti il mio stesso problema e sono arrivato ad una pagina con il seguente esempio:
Dopo aver analizzato per un po' il tutto sono giunto alla conclusione di non sapere che farne, in quanto non sono in grado di interpretarlo. Mi sapreste dire dove devo inserire l'indirizzo dove sta il documento excel, il nome, nome utente e password, e, soprattutto, le celle da cui prendere le informazioni? Detto ciò, una volta inserito il tutto, dovrebbe poi apparire "magicamente" la tabella o non ho capito niente?codice:<% ' Selected constants from adovbs.inc Const adOpenStatic = 3 Const adLockPessimistic = 2 Dim cnnExcel Dim rstExcel Dim I Dim iCols ' This is all standard ADO except for the connection string. ' You can also use a DSN instead, but so it'll run out of the ' box on your machine I'm using the string instead. Set cnnExcel = Server.CreateObject("ADODB.Connection") cnnExcel.Open "DBQ=" & Server.MapPath("xl_data.xls") & ";" & _ "DRIVER={Microsoft Excel Driver (*.xls)};" ' Same as any other data source. ' FYI: TestData is my named range in the Excel file Set rstExcel = Server.CreateObject("ADODB.Recordset") rstExcel.Open "SELECT * FROM TestData;", cnnExcel, _ adOpenStatic, adLockPessimistic ' Get a count of the fields and subtract one since we start ' counting from 0. iCols = rstExcel.Fields.Count %> <table border="1"> <thead> <% ' Show the names that are contained in the first row ' of the named range. Make sure you include them in ' your range when you create it. For I = 0 To iCols - 1 Response.Write "<th>" Response.Write rstExcel.Fields.Item(I).Name Response.Write "</th>" & vbCrLf Next 'I %> </thead> <% rstExcel.MoveFirst ' Loop through the data rows showing data in an HTML table. Do While Not rstExcel.EOF Response.Write "<tr>" & vbCrLf For I = 0 To iCols - 1 Response.Write "<td>" Response.Write rstExcel.Fields.Item(I).Value Response.Write "</td>" & vbCrLf Next 'I Response.Write "</tr>" & vbCrLf rstExcel.MoveNext Loop %> </table> <% rstExcel.Close Set rstExcel = Nothing cnnExcel.Close Set cnnExcel = Nothing %>

Rispondi quotando