
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!
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


0