Ciao.
Spero possiate aiutarmi e spero anche di riuscire a spiegarvi il problema.
Devo leggere tramite ASP un foglio excel con un formato NON standard ( cioè i dati non sono incolonnati e sviluppati per riga in maniera uniforme nel senso che in una riga ad esempio si può trovare il come di una colonna... ) ed inserire i dati letti in un db mysql.
Il codice che utilizzo con ASP per leggere questo file lo trovate postato alla fine di questo msg.
Questo è il risultato finale della lettura del file excel:
MM20-40001 ---> adoRs0
---> adoRs1
---> adoRs2
MIT ---> adoRs0
---> adoRs1
---> adoRs2
Codice ---> adoRs0
Primo ---> adoRs1
Secondo ---> adoRs2
Come potete vedere il valore di adoRs0 è ogni volta diverso ed assume i valori delle celle che il codice incontra man mano che scorre il foglio excel.
Come faccio a fargli capire che il valore di adoRs0 deve essere sempre questa stringa: MM20-40001 ?
codice:<% Set adoCn = Server.CreateObject("ADODB.Connection") With adoCn .Provider="Microsoft.Jet.OLEDB.4.0" .ConnectionString="Data Source="&Server.MapPath("ram.xls")&";Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1""" .Open End With strQuery = "SELECT * from [Foglio1$] " Set adoRs = Server.CreateObject("ADODB.Recordset") With adoRs Set .ActiveConnection = adoCn .Open strQuery End With adoRs.MoveFirst Do While Not adoRs.Eof response.write adoRs(0) &" ---> adoRs0 " response.write adoRs(1) &" ---> adoRs1 " response.write adoRs(2) &" ---> adoRs2 " strSQL = "INSERT INTO " strSQL = strSQL & " tbl" strSQL = strSQL & " ( " strSQL = strSQL & " campoUno " strSQL = strSQL & " ) " strSQL = strSQL & " VALUES " strSQL = strSQL & " ( " strSQL = strSQL & " '" & adoRs(0) & "' " strSQL = strSQL & " )" cn.execute(strSQL) adoRs.MoveNext Loop adoRs.close Set adoRs = Nothing adoCn.Close Set adoCn = Nothing cn.Close Set cn = Nothing %>

Rispondi quotando