Ver Mensaje Individual
  #4 (permalink)  
Antiguo 07/06/2013, 11:21
PabloManuel
 
Fecha de Ingreso: diciembre-2010
Mensajes: 236
Antigüedad: 13 años, 5 meses
Puntos: 6
Respuesta: Problema al leer Excel desde Asp, omite campos alfanuméricos.

SOLUCIONADO
El problema estaba en la cadena de conexión. Pongo el código válido:

Código ASP:
Ver original
  1. <html>
  2.     <head>
  3.         <title>Recoge valores de celdas Excel</title>
  4.     </head>
  5.    
  6.     <body style="font-family: Arial; font-size: 9pt">
  7.    
  8.         <%
  9.        
  10.         dim ConnectDBQ,rs,dbc
  11.        
  12.         Set dbc = Server.CreateObject("ADODB.Connection")
  13.        
  14.         'Cadenas de conexión que mejor no usar:
  15.         'ConnectDBQ="DRIVER={Microsoft Excel Driver (*.xls)}; DBQ=" & server.mappath("ASP2.xls")    
  16.         'ConnectDBQ= "DRIVER={Microsoft Excel Driver (*.xls)}; IMEX=1; HDR=no; Excel 8.0; DBQ=" & Server.MapPath("ASP2.xls") & "; "    
  17.        
  18.         'Vale tanto para Xls como Xlsx
  19.         ConnectDBQ = _
  20.             "Provider=Microsoft.ACE.OLEDB.12.0;" & _
  21.             "Extended Properties='Excel 12.0 Xml;HDR=yes;IMEX=1';" & _
  22.             "Data Source=" & Server.MapPath("ASP.xls")
  23.        
  24.  
  25.         dbc.Open ConnectDBQ
  26.        
  27.         Set rs=Server.CreateObject("ADODB.RecordSet")
  28.         rs.open "select * from [Hoja1$]",dbc,3,3
  29.        
  30.  
  31.         %>
  32.         <table Border='1px'>
  33.         <tr>
  34.         <%
  35.  
  36.         For I = 0 To 3
  37.             response.write "<td>" & rs.Fields.Item(I).Name & "</td>"
  38.         Next
  39.        
  40.         %>
  41.         </tr>
  42.         <%
  43.        
  44.         do while not rs.eof
  45.             %>
  46.             <tr>
  47.             <%
  48.             For I = 0 To 3
  49.                 response.write "<td>" & rs.fields(I).value & "</td>"
  50.             Next
  51.             %>
  52.             </tr>
  53.             <%
  54.            
  55.             rs.movenext
  56.         loop
  57.        
  58.         rs.close
  59.         %>
  60.         </table>
  61.     </body>
  62. </html>