Foros del Web » Programando para Internet » ASP Clásico »

Problema para exportal a excel

Estas en el tema de Problema para exportal a excel en el foro de ASP Clásico en Foros del Web. Hola, no entiendo que pasa tengo una pagina similar a esta que si exporta sin problemas pero esta no me exporta nada, es mas cuando ...
  #1 (permalink)  
Antiguo 22/06/2010, 22:02
 
Fecha de Ingreso: noviembre-2007
Mensajes: 504
Antigüedad: 16 años, 5 meses
Puntos: 2
Problema para exportal a excel

Hola, no entiendo que pasa tengo una pagina similar a esta que si exporta sin problemas pero esta no me exporta nada, es mas cuando le paso los datos y el link manda a esta pagina para tirar la exportacion en excel me dice que la pagina no existe cuando si existe el archivo. Pero si le quito las primeras Lineas de:
<%
Response.AddHeader "Content-Disposition", "attachment;filename=WasReport.xls"
'Response.Buffer = true
Response.ContentType = "application/vnd.ms-excel"
'Response.Expires = 0
%>
Si me muestra la pagina, cual sera el problema?
Código ASP:
Ver original
  1. <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
  2.  
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  4. <html xmlns="http://www.w3.org/1999/xhtml">
  5. <%
  6. Response.AddHeader "Content-Disposition", "attachment;filename=WasReport.xls"
  7. 'Response.Buffer = true
  8. Response.ContentType = "application/vnd.ms-excel"
  9. 'Response.Expires = 0
  10. %>
  11. -->
  12. <html>
  13.  
  14. <head>
  15. <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
  16. <title>WAS2</title>
  17.  
  18.  
  19. </head>
  20.  
  21. <body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" marginheight="0" marginwidth="0" bgcolor="#FFFFFF">
  22. <style type="text/css">
  23. table.sample {
  24.     border-width: 1px;
  25.     border-spacing: 2px;
  26.     border-style: groove;
  27.     border-color: green;
  28.     border-collapse: collapse;
  29.     background-color: rgb(255, 255, 240);
  30. }
  31. table.sample th {
  32.     border-width: 1px;
  33.     padding: 3px;
  34.     border-style: inset;
  35.     border-color: red;
  36.     background-color: ;
  37.     -moz-border-radius: 0px 0px 0px 0px;
  38. }
  39. table.sample td {
  40.     border-width: 1px;
  41.     padding: 3px;
  42.     border-style: inset;
  43.     border-color: red;
  44.     background-color: ;
  45.     -moz-border-radius: 0px 0px 0px 0px;
  46.    
  47. }
  48.  
  49. </style>
  50.  
  51. <!--<table border="0" width="100%" cellspacing="0" cellpadding="0" background="img/topbkg.gif">
  52.   <tr>
  53.     <td width="50%"><img border="0" src="img/img2.png" width="142" height="66"></td>
  54.     <td width="50%">
  55.       <p align="right"><img border="0" src="img/topright.gif" width="327" height="66"></td>
  56.   </tr>
  57. </table>
  58. <table border="0" width="100%" cellspacing="0" cellpadding="0" background="img/blackline.gif">
  59.   <tr>
  60.     <td width="100%"><font color="#B8C0F0" face="Arial" size="2"><b>&nbsp;&nbsp;
  61.       <a href="http://messrv00/Mes/Asp/was2/Default.htm">Home&nbsp;&nbsp;</a> |&nbsp;&nbsp; Reports&nbsp;&nbsp; |&nbsp;&nbsp;
  62.           Other Link</b></font></td>
  63.   </tr>
  64. </table>-->
  65. <p style="margin-left: 20"><b><font color="#B8C0F0" face="Arial" size="2">&nbsp;</font></b><font face="Arial" size="2" color="#000000">
  66. <p align="center"><table border="1" CLASS="sample"></p>
  67. <tr>
  68. <td><b>Linea</b></td>
  69. <td><b>Peso</b></td>
  70. <td><b>Target</b></td>
  71. <td><b>Marca</b></td>
  72. <td><b>Vaso</b></td>
  73. <td><b>Tubo</b></td>
  74. <td><b>Fecha</b></td>
  75. </tr>
  76. <%
  77.  
  78. 'dim conexion,calendar1,calendar2,registros,linea,hora,test
  79. calendar1=request.QueryString("calendar1")
  80. calendar2=request.QueryString("calendar2")
  81. linea=request.QueryString("linea")
  82. tubo=request.QueryString("tubo")
  83. hora=request.QueryString("hora")
  84. hora=request.form("hora")
  85. test=("SELECT h.hora,h.marca,h.codoptima,h.target,P.CODOPTIMA,O.CODIGO,p.hora,p.peso,p.vaso,p.fecha, o.linea,o.tubo FROM pesos as p, optimas as o,htargets as h where o.codigo = p.codOptima and o.linea = '"&linea&"' and o.tubo LIKE '"&tubo&"'  AND p.fecha Between '"&calendar1&"' AND '"&calendar2&"' AND p.hora='"&hora&"'and h.codoptima = o.codigo and h.hora='"&hora&"'")
  86.         SET conexion=Server.CreateObject("ADODB.Connection")
  87.         conexion.Open "PROVIDER=SQLOLEDB; DATA SOURCE=VALP-MESSRV02;UID=sa;PWD=messrv;DATABASE=wasp "
  88.         SET registros=Server.CreateObject("ADODB.RecordSet")
  89.         'registros.open"SELECT peso,tubo from pesos where fecha  between '"&calendar1&"' AND '"&calendar2&"'",conexion
  90.  
  91.         'registros.open"SELECT h.hora AS hora1,h.marca,h.codoptima AS codoptimaT,h.target,P.CODOPTIMA,O.CODIGO,p.hora,p.peso,p.vaso,p.fecha,o.linea,o.tubo INTO #c FROM pesos AS p, optimas AS o,htargets AS h WHERE o.codigo = p.codOptima AND o.linea = '"&linea&"' AND o.tubo ='"&tubo&"' AND p.fecha BETWEEN '"&calendar1&"' AND '"&calendar2&"' AND p.hora='"&hora&"' AND h.codoptima = o.codigo AND h.hora='"&hora&"'",conexion
  92.  
  93.  
  94.  
  95.  
  96.     registros.open"SELECT h.hora,h.marca,h.codoptima,h.target,P.CODOPTIMA,O.CODIGO,p.hora,p.peso,p.vaso,p.fecha, o.linea,o.tubo FROM pesos as p, optimas as o,htargets as h where o.codigo = p.codOptima and o.linea = '"&linea&"' and o.tubo ='"&tubo&"'  AND h.fecha Between '"&calendar1&"' AND '"&calendar2&"'  AND p.fecha Between '"&calendar1&"' AND '"&calendar2&"' AND p.hora='"&hora&"'and h.codoptima = o.codigo and h.hora='"&hora&"'" ,conexion
  97.     'registros.open"SELECT p.hora,p.peso,p.vaso,p.fecha, o.linea,o.tubo FROM pesos as p, optimas as o where o.codigo = p.codOptima and o.linea = 'L15N' and o.tubo LIKE '%'  AND p.fecha Between '2010-06-14 09:00:00.000' AND '2010-06-14 09:30:00.000' AND p.hora='9:00 - 9:30'" ,conexion    
  98.     'SELECT h.codoptima,h.target,P.CODOPTIMA,O.CODIGO,p.hora,p.peso,p.vaso,p.fecha, o.linea,o.tubo,o.codigo FROM pesos as p, optimas as o,htargets as h where o.codigo = p.codOptima and o.linea = 'L07N' and o.tubo LIKE '%' AND p.fecha Between '2010-06-14 09:30' AND '2010-06-14 10:00' AND p.hora='9:30 - 10:00' and h.codoptima = o.codigo
  99.  
  100.     dim a
  101.     do while not registros.eof
  102. a=cint(registros.fields("target"))
  103.  
  104.         response.write("<tr>")
  105.         response.write("<td>"&registros.fields("linea")&"</td>")
  106.         response.write("<td>"&registros.fields("peso")&"</td>")
  107.         response.write("<td>"&registros.fields("target")&"</td>")
  108.         'response.write("<td>"&a&"</td>")
  109.         response.write("<td>"&registros.fields("marca")&"</td>")
  110.         response.write("<td>"&registros.fields("vaso")&"</td>")
  111.         response.write("<td>"&registros.fields("tubo")&"</td>")
  112.         response.write("<td>"&registros.fields("fecha")&"</td>")
  113.         registros.movenext
  114.  
  115.  
  116. loop
  117.  
  118. conexion.close
  119. response.write(test) '<--Test Debug
  120. 'RESPONSE.WRITE("<br>")
  121.     dim codoptima
  122.  
  123. if  linea="L01N" AND tubo="A" then
  124.             codoptima=30
  125. elseif _
  126.     linea="L01N" AND tubo="B" then
  127.             codoptima=31
  128. elseif  linea="L01N" AND tubo="C" then
  129.             codoptima=32
  130. elseif  linea="L01S" AND tubo="D" then
  131.             codoptima=33
  132. elseif  linea="L01S" AND tubo="E" then
  133.             codoptima=34
  134. elseif  linea="L01S" AND tubo="F" then
  135.             codoptima=35
  136.            
  137. elseif  linea="L02N" AND tubo="A"   then
  138.             codoptima=54
  139. elseif  linea="L02N" AND tubo="B" then
  140.             codoptima=55
  141. elseif  linea="L02N" AND tubo="C" then
  142.             codoptima=56
  143.                        
  144. elseif  linea="L02N" AND tubo="D" then
  145.             codoptima=57
  146. elseif  linea="L02N" AND tubo="E" then
  147.             codoptima=58
  148. elseif  linea="L02N" AND tubo="F" then
  149.             codoptima=59
  150.    
  151. elseif  linea="L03N" AND tubo="A"   then
  152.             codoptima=60
  153. elseif  linea="L03N" AND tubo="B"   then
  154.             codoptima=61
  155. elseif  linea="L03N" AND tubo="C"   then
  156.             codoptima=62       
  157.            
  158. elseif  linea="L03S" AND tubo="D"   then
  159.             codoptima=63
  160. elseif  linea="L03S" AND tubo="E"   then
  161.             codoptima=64
  162. elseif  linea="L03S" AND tubo="F"    then
  163.             codoptima=65
  164.            
  165. elseif  linea="L06N" AND tubo="A"   then
  166.             codoptima=36
  167. elseif  linea="L06N" AND tubo="B"       then
  168.             codoptima=37
  169. elseif  linea="L06N" AND tubo="C"       then
  170.             codoptima=38
  171.            
  172. elseif  linea="L06S" AND tubo="D"       then
  173.             codoptima=39
  174. elseif  linea="L06S" AND tubo="E"       then
  175.             codoptima=40
  176. elseif  linea="L06S" AND tubo="F"       then
  177.             codoptima=41           
  178.        
  179. elseif  linea="L07N" AND tubo="A"       then
  180.             codoptima=42
  181.  
  182.             codoptima=50   
  183.        
  184.        
  185.     end if     
  186.  
  187.  
  188.             'SELECT p.peso,p.tubo,p.fecha, o.linea FROM pesos as p, optimas as o where o.codigo = p.codOptima and o.linea = 'L02N'  AND p.fecha Between '2010-05-11 09:42:34.000' AND '2010-05-11 09:42:39.000'
  189.             SET conexion2=Server.CreateObject("ADODB.Connection")
  190.             conexion2.Open "PROVIDER=SQLOLEDB; DATA SOURCE=VALP-MESSRV02;UID=sa;PWD=messrv;DATABASE=wasp "
  191.             SET registros2=Server.CreateObject("ADODB.RecordSet")
  192.        
  193.         registros2.open"SELECT AVG(PESO)as peso from pesos where fecha Between '"&calendar1&"' AND '"&calendar2&"'AND hora='"&hora&"' AND codoptima='"&codoptima&"'",conexion2
  194.         'RESPONSE.WRITE("SELECT AVG(PESO)as peso from pesos where fecha Between '"&calendar1&"' AND '"&calendar2&"'AND hora='"&hora&"' AND codoptima='"&codoptima&"'")
  195.         do while not registros2.eof
  196.         c=cint(registros2.fields("peso"))
  197.         b=(a-c)/a
  198.         response.write("Promedio: "&registros2.fields("peso")&"")
  199.     '############## Aritmetica ####################
  200.     ' C = Promedio  WHERE B=(a-c)/a
  201.     ' A = Target
  202.         response.write("<br> Op: "&b&"<br>")
  203.            
  204.         saving=(c-a)
  205.        
  206.         registros2.movenext
  207.     loop
  208.        
  209.         conexion2.close
  210.        
  211. %>
  212.  
  213.  
  214. </tr>
  215. </table>
  216. </table>
  217. </font></p>
  218.  
  219. <p style="margin-left: 20"><font face="Arial" size="2" color="#000000">&nbsp;</font></p>
  220. <div align="center"> <a href="Show.asp"> <img src="../ProyImgs/excel.gif" alt="Exportar" width="22" height="20" border="0" /> </a> </div>
  221. <p style="margin-left: 20"><font face="Arial" size="2" color="#000000">&nbsp;</font></p>
  222. <p style="margin-left: 20"><font face="Arial" size="2" color="#000000">&nbsp; </font></p>
  223. <p style="margin-left: 20"><font face="Arial" size="2" color="#000000">&nbsp;</font></p>
  224. <p style="margin-left: 20"><font face="Arial" size="2" color="#000000">&nbsp;</font></p>
  225. <p style="margin-left: 20"><font face="Arial" size="2" color="#000000">&nbsp;</font></p>
  226. <p style="margin-left: 20"><font face="Arial" size="2" color="#000000">&nbsp;</font></p>
  227. <p style="margin-left: 20"><font face="Arial" size="2" color="#000000">&nbsp;</font></p>
  228. <p style="margin-left: 20" align="center"><font face="Arial" color="#000000" size="1">©
  229. COPYRIGHT 2010 ALL RIGHTS RESERVED PG.COM</font></p>
  230. <table border="0" width="100%" cellspacing="0" cellpadding="0" background="img/botline.gif">
  231.   <tr>
  232.     <td width="100%"><img border="0" src="img/botline.gif" width="41" height="12"></td>
  233.   </tr>
  234. </table>
  235.  
  236.  
  237. </body>
  238.  
  239. </html>
  #2 (permalink)  
Antiguo 25/06/2010, 07:51
 
Fecha de Ingreso: noviembre-2007
Mensajes: 504
Antigüedad: 16 años, 5 meses
Puntos: 2
Respuesta: Problema para exportal a excel

ya encontre el problema, saludos
  #3 (permalink)  
Antiguo 25/06/2010, 11:09
 
Fecha de Ingreso: agosto-2006
Mensajes: 60
Antigüedad: 17 años, 8 meses
Puntos: 1
Respuesta: Problema para exportal a excel

Sería bueno que publiques tu solución para que el que la necesite la pueda ver.

Etiquetas: excel
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 02:26.