Visualizzazione dei risultati da 1 a 7 su 7
  1. #1

    Aiuto Script ASP che Legge da EXCEL

    Ho trovato in rete questo script che usa come database excel e lo trovo molto interessante. Ora volevo sapere un paio di cose.

    1.Come posso modificare le righe e le colonne da leggere, infatti non legge piu di 2 colonne e 8 righe.

    2.Come posso formattare il testo all'interno delle tabelle.. ho provato in diversi modi ma nulla.

    3.Quando cerco di richiamare lo script con un include non funziona.
    Es.SCRIPT FUNZIONANTE
    Es.SCRIPT NON FUNZIONANTE RICHIAMATO TRAMITE INCLUDE


    Intanto vi passo il codice... è questo:

    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("database.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="0">
    	<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
    %>

    Grazie...

  2. #2
    Moderatore di JavaScript L'avatar di br1
    Registrato dal
    Jul 1999
    Messaggi
    19,998
    Sbagliato mira? ti sposto...
    Il guaio per i poveri computers e' che sono gli uomini a comandarli.

    Attenzione ai titoli delle discussioni: (ri)leggete il regolamento
    Consultate la discussione in rilievo: script / discussioni utili
    Usate la funzione di Ricerca del Forum

  3. #3
    scusa..

    cmq qualcuno che sa aiutarmi?

  4. #4

  5. #5
    nessuno che può aiutarmi?

  6. #6
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    L'errore te lo dice:

    Microsoft VBScript compilation error '800a0411'

    Name redefined

    /classifica.asp, line 14

    Dim I
    ----^


    La variabile devi definirla una sola volta (tramite la Dim) all'interno di uno script.

    Roby

  7. #7
    cmq ho risolto..

    ho fatto uno script che legge da excel e rimanda sullo schermo tramite asp.

    Per vederlo andate qui www.virtusalburni.com e clikkate su risultati o classifiche.. si aprono in una PopUp..

    Inoltre nello script dalla sezione admin ho messo un upload file che permette di sovrascrivere i DB di excel tramite form con sfoglia.

    Mi so proprio divertito!

    ciao e grazie!

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.