ASP - creacion de xls con asp

 
Vista:
Imágen de perfil de Roberto Iran Ramirez Navarro

creacion de xls con asp

Publicado por Roberto Iran Ramirez Navarro (17 intervenciones) el 15/10/2008 18:22:02
Hola buenos dias

Tengo un desarrollo en el cual necesito crear un xls, bueno todo me funciona pero el unico problema que tengo es que los acentos no los pasa al xls y me pone simbolos raros, la parte de mi script es este:

Response.buffer = true
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "Content-Disposition", "filename=sdf.xls;"
Response.Charset = "UTF-8"

Espero alguien pueda ayudarme, tambien les dejo es script completo donde genero la tabla que exporto a xls.

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#INCLUDE FILE="Free_CS.asp"-->
<html>
<head></head>
<body>
<%
Response.buffer = true
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "Content-Disposition", "filename=sdf.xls;"
Response.Charset = "UTF-8"
strQRY = ""
strUID = "_SMSYSADMIN_"
strPWD = Application("METADATA").Passwd
strGPO = Session("strGpo")
strUSR = Session("MerlinConnection")
strMod = Request.QueryString("xModulo")
'strDSN = Application("METADATA").DSN
strDSN = "magic"
if (Request.QueryString("xFcoor") = strUSR) Then
strUSR = "[LOGIN ID ASSIGNED TO] = '"&Request.QueryString("xFcoor")&"'"
else
strUSR = "[Seq.Assigned To] = "&Request.QueryString("xFcoor")
End IF
If (strMod = "Incident") Then
strSequence = "Incident #"
else
strSequence = "Work Order #"
End If
strStatus = Request.QueryString("xState")
'Application("METADATA").Modules.GetModuleBySequence(27)
Set Dbconn = Server.CreateObject("ADODB.Connection")
'Dbconn.ConnectionTimeOut = 10
'Dbconn.Open "Driver={SQL Server};Server=DEV-SQL01;Database="&strDSN&";uid="&strUID&";pwd="&strPWD&";"
Dbconn.Open "Driver={SQL Server};Server=VSDE9;Database="&strDSN&";uid="&strUID&";pwd="&strPWD&";"
strQRY = "SELECT"
strQRY = strQRY&" ["&strSequence&"],"
strQRY = strQRY&" "&"[State:],"
strQRY = strQRY&" "&"[Open Date & Time],"
strQRY = strQRY&" "&"([First Name Opened By]+' '+[Last Name Opened By]) 'Generado por',"
strQRY = strQRY&" "&"[Client ID],"
strQRY = strQRY&" "&"lower([First Name]+' '+[Last Name]) Cliente,"
strQRY = strQRY&" "&"[Cl. Ext.],"
strQRY = strQRY&" "&"[Incident Description],"
strQRY = strQRY&" "&"[Incident Resolution],"
strQRY = strQRY&" "&"[Due Date & Time:],"
strQRY = strQRY&" "&"[Close Date & Time]"
strQRY = strQRY&" "&"FROM "&strGPO&".["&strMod&"]"
strQRY = strQRY&" "&"WHERE "&strUSR
strQRY = strQRY&" "&"AND [INACTIVE:]=0"
If (strStatus <> "All") Then strQRY = strQRY&" "&"AND [State:]='"&strStatus&"'"
strQRY = strQRY&" "&"ORDER BY ["&strSequence&"]"
Set RS_Dbconn = Server.CreateObject("ADODB.Recordset")
RS_Dbconn.Open strQRY, Dbconn, 1,2
oRowXLS = RS_Dbconn.GetRows()
%>
<table border="1" width="100%" height="100%" cellpadding="0" cellspacing="0" id="tabla" class="table">
<%
For i=0 to RS_Dbconn.Fields.Count - 1
%>
<th height="20px">
<label><%=txtTrad(txtValue(RS_Dbconn(i).Name))%></label>
</th>
<%
Next
RS_Dbconn.Close
Dbconn.Close
Set RS_Dbconn = nothing
Set Dbconn = nothing
For reg = 0 To UBound(oRowXLS,2)
%>
<tr>
<%
For col = 0 To UBound(oRowXLS,1)
%>
<td><label class="label"><%=oRowXLS(col,reg)%></label></td>
<%
Next
%>
</tr>
<%
Next
%>
</table>
</body>
</html>

Saludos!
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:creacion de xls con asp

Publicado por weirdmix (210 intervenciones) el 20/10/2008 20:10:57
intenta poniendo esto:

SetLocale("es-mx") 'es vbscript

en este caso yo estoy en Mexico, tienes q averiguar cual seria el correcto para tu pais.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de Roberto Iran Ramirez Navarro

RE:creacion de xls con asp

Publicado por Roberto Iran Ramirez Navarro (17 intervenciones) el 20/10/2008 23:00:14
Hola weirdmix

Gracias por tu ayuda, la solucion que encontre fue poner al principio <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%> y mi codigo queda asi:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%Response.buffer = false%>
<!--#INCLUDE FILE="Free_CS.asp"-->
<html>
<head></head>
<body>
<%
strQRY = ""
strUID = "_SMSYSADMIN_"
strPWD = Application("METADATA").Passwd
strGPO = Session("strGpo")
strUSR = Session("MerlinConnection")
strMod = Request.QueryString("xModulo")
strDSN = Application("METADATA").DSN
'strDSN = "magic"
strStatus = Request.QueryString("xState")
Select case strStatus
case "O"
namStatus = "Abiertos"
case "C"
namStatus = "Cerrados"
case "All"
namStatus = "AbiertosyCerrados"
End Select
namFile = strUSR&"_"&strMod&Request.QueryString("xFcoor")&namStatus&"_"&day(now)&month(now)&year(now)
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "Content-Disposition", "attachment;filename="&namFile&".xls;"
Response.Charset = "UTF-8"
if (Request.QueryString("xFcoor") = strUSR) Then
strUSR = "[LOGIN ID ASSIGNED TO] = '"&Request.QueryString("xFcoor")&"'"
else
strUSR = "[Seq.Assigned To] = "&Request.QueryString("xFcoor")
End IF
If (strMod = "Incident") Then
strSequence = "Incident #"
else
strSequence = "Work Order #"
End If
Set Dbconn = Server.CreateObject("ADODB.Connection")
Dbconn.Mode = AdModeReadWrite
Dbconn.Mode = adModeShareDenyWrite
Dbconn.Open = "DSN="&strDSN&";UID="&strUID&";PWD="&strPWD
strQRY = "SELECT"
strQRY = strQRY&" ["&strSequence&"],"
strQRY = strQRY&" "&"[State:],"
strQRY = strQRY&" "&"[Open Date & Time],"
strQRY = strQRY&" "&"([First Name Opened By]+' '+[Last Name Opened By]) 'Generado por',"
strQRY = strQRY&" "&"[Client ID],"
strQRY = strQRY&" "&"lower([First Name]+' '+[Last Name]) Cliente,"
strQRY = strQRY&" "&"[Cl. Ext.],"
strQRY = strQRY&" "&"[Incident Description],"
strQRY = strQRY&" "&"[Incident Resolution],"
strQRY = strQRY&" "&"[Due Date & Time:],"
strQRY = strQRY&" "&"[Close Date & Time]"
strQRY = strQRY&" "&"FROM "&strGPO&".["&strMod&"]"
strQRY = strQRY&" "&"WHERE "&strUSR
strQRY = strQRY&" "&"AND [INACTIVE:]=0"
If (strStatus <> "All") Then strQRY = strQRY&" "&"AND [State:]='"&strStatus&"'"
strQRY = strQRY&" "&"ORDER BY ["&strSequence&"]"
Set RS_Dbconn = Server.CreateObject("ADODB.Recordset")
RS_Dbconn.Open strQRY, Dbconn, 1,2
oRowXLS = RS_Dbconn.GetRows()
%>
<table border="1" width="100%" height="100%" cellpadding="0" cellspacing="0" id="tabla" class="table">
<%
For i=0 to RS_Dbconn.Fields.Count - 1
%>
<th height="20px">
<label><%=txtTrad(txtValue(RS_Dbconn(i).Name))%></label>
</th>
<%
Next
RS_Dbconn.Close
Dbconn.Close
Set RS_Dbconn = nothing
Set Dbconn = nothing
For reg = 0 To UBound(oRowXLS,2)
%>
<tr>
<%
For col = 0 To UBound(oRowXLS,1)
%>
<td><label class="label"><%=oRowXLS(col,reg)%></label></td>
<%
Next
%>
</tr>
<%
Next
%>
</table>
</body>
</html>

Saludos!
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar