Hey guys,
One more about reports. This time converting to pdf. With the countless attempts to generate a report using generators, now I'm trying to generate it in PDF but I keep getting the same problem, texts with web characters.
Everything is ready in the system, but I am not able to solve the printing with any report template.
In the case of the PDF I did it the way below but it's not working.
What can I do to resolve this once and for all?
<%@ Page Title="" Language="VB" MasterPageFile="~/home/MasterPage.master" AutoEventWireup="false" CodeFile="relDocPDF.aspx.vb" Inherits="ci_relatorios_relDocPDF" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:HyperLink ID="hlDownload" runat="server">DOWNLOAD</asp:HyperLink>
</asp:Content>
Partial Class ci_relatorios_relDocumento
Inherits System.Web.UI.Page
Private Documentos As New CENTEC.objDocumento
Private Fn As New Funcoes.classFuncao
Private Sub RecebewParametros()
If Not Request("relID") Is Nothing Then
ViewState("vlrID") = Request("relID")
Else
If Request("relID") Is Nothing Then
ViewState("vlrID") = 0
End If
End If
If Not Request("relTdoc") Is Nothing Then
ViewState("vlrdoc") = Request("relTdoc")
Else
If Request("relTdoc") Is Nothing Then
ViewState("vlrTdoc") = 0
End If
End If
End Sub
Private Sub PovoaRelatorio()
Dim pCaminho As String = ""
Dim pUnion As String = ""
Dim Ds As Data.DataSet
Dim Dr As Data.DataRow
Dim C As Integer = 0
Dim pSQL As String = "SET LANGUAGE BRAZILIAN " &
" SELECT A.ID, A.ASSUNTO, " &
" NUMERODOC = CONCAT(REPLICATE('0', 3 - LEN(CAST(A.NUMERO AS VARCHAR))) + CAST(A.NUMERO AS VARCHAR), '/', YEAR(A.DTCRIACAO)), " &
" USUORIGEM = B.NOME, SETOR_ORIGEM = H.DESCRICAO, USUDESTINO = C.NOME, SETOR_DESTINO = L.DESCRICAO, " &
" DATA_CRIACAO = CONVERT(VARCHAR(10), A.DTCRIACAO, 103), TIPO_DOCUMENTO = D.NOME, TEXTO = CONVERT(VARCHAR(MAX), A.TEXTO), " &
" " &
" DATA_CRIACAO_EXTENSO = REPLICATE('0', 2 - LEN(DAY(A.DTCRIACAO))) + CAST(day(A.DTCRIACAO) AS VARCHAR) + " &
" CASE MONTH(A.DTCRIACAO) " &
" WHEN 1 THEN ' de janeiro de ' " &
" WHEN 2 THEN ' de fevereiro de ' " &
" WHEN 3 THEN ' de março de ' " &
" WHEN 4 THEN ' de abril de ' " &
" WHEN 5 THEN ' de maio de ' " &
" WHEN 6 THEN ' de junho de ' " &
" WHEN 7 THEN ' de julho de ' " &
" WHEN 8 THEN ' de agosto de ' " &
" WHEN 9 THEN ' de setembro de ' " &
" WHEN 10 THEN ' de outubro de ' " &
" WHEN 11 THEN ' de novembro de ' " &
" WHEN 12 THEN ' de dezembro de ' " &
" ELSE '' END + CAST(YEAR(A.DTCRIACAO) AS VARCHAR) " &
" " &
" FROM ZMDDOCUMENTO A(NOLOCK) " &
" INNER JOIN PFUNC B(NOLOCK) ON (B.CHAPA = A.CODUSUARIOORIGEM) " &
" INNER JOIN PFCOMPL BB(NOLOCK) ON (BB.CHAPA = B.CHAPA And BB.CODCOLIGADA = B.CODCOLIGADA) " &
" INNER JOIN PFUNC C(NOLOCK) ON (C.CHAPA = A.CODUSUARIOADESTINO) " &
" INNER JOIN PFCOMPL CC(NOLOCK) ON (CC.CHAPA = C.CHAPA And CC.CODCOLIGADA = C.CODCOLIGADA) " &
" INNER JOIN ZMDTIPODOCUMENTO D (NOLOCK) ON (D .ID = A.TIPODOCUMENTO) " &
" INNER JOIN PSECAO E(NOLOCK) ON (E.CODIGO = B.CODSECAO And E.CODCOLIGADA = B.CODCOLIGADA) " &
" INNER JOIN PFUNCAO F(NOLOCK) ON (F.CODIGO = B.CODFUNCAO And F.CODCOLIGADA = B.CODCOLIGADA) " &
" INNER JOIN GDEPTO G(NOLOCK) ON (G.CODDEPARTAMENTO = E.CODDEPTO And G.CODFILIAL = E.CODFILIAL And G.CODCOLIGADA = E.CODCOLIGADA) " &
" INNER JOIN GCONSIST H ON (H.CODCLIENTE = BB.SETORCENTEC And H.CODTABELA = 'SETCENTEC') " &
" INNER JOIN PSECAO I(NOLOCK) ON (I.CODIGO = C.CODSECAO AND I.CODCOLIGADA = C.CODCOLIGADA) " &
" INNER JOIN PFUNCAO J(NOLOCK) ON (J.CODIGO = C.CODFUNCAO AND J.CODCOLIGADA = C.CODCOLIGADA) " &
" INNER JOIN GDEPTO K(NOLOCK) ON (K.CODDEPARTAMENTO = I.CODDEPTO AND K.CODFILIAL = I.CODFILIAL AND K.CODCOLIGADA = I.CODCOLIGADA) " &
" INNER JOIN GCONSIST L ON (L.CODCLIENTE = CC.SETORCENTEC AND L.CODTABELA = 'SETCENTEC') " &
" WHERE A.ID IN (" & ViewState("vlrID") & ") " &
" ORDER BY A.ID "
Ds = Documentos.ConsultaGenerica(pSQL)
Dim pSQL2 As String = ""
If Not Ds Is Nothing Then
For I As Integer = 0 To Ds.Tables(0).Rows.Count - 1
Dr = Ds.Tables(0).Rows(I)
pSQL2 += " SELECT ID = " & Dr("ID") & ", " &
"ASSUNTO = '" & Dr("ASSUNTO") & "', " &
"NUMERODOC = '" & Dr("NUMERODOC") & "', " &
"USUORIGEM = '" & Dr("USUORIGEM") & "', " &
"SETOR_ORIGEM = '" & Dr("SETOR_ORIGEM") & "', " &
"USUDESTINO = '" & Dr("USUDESTINO") & "', " &
"SETOR_DESTINO = '" & Dr("SETOR_DESTINO") & "', " &
"DATA_CRIACAO = '" & Dr("DATA_CRIACAO") & "', " &
"TIPO_DOCUMENTO = '" & Dr("TIPO_DOCUMENTO") & "', " &
"TEXTO = CONVERT(VARCHAR(MAX), '" & Server.HtmlDecode(Dr("TEXTO")) & "') " & pUnion
If I < C Then pUnion = " UNION "
C = C + 1
Next
End If
If ViewState("vlrdoc") = 1 Then
pCaminho = Session("sDominio") & "/ci/relatorios/relDocumento.frx"
Else
If ViewState("vlrdoc") = 2 Then
pCaminho = Session("sDominio") & "/ci/relatorios/relDocumento.frx"
Else
If ViewState("vlrdoc") = 3 Then
pCaminho = Session("sDominio") & "/ci/relatorios/relDocumento.frx"
End If
End If
End If
With sqlDS
.SelectCommand = " SET LANGUAGE BRAZILIAN " & pSQL2
.DataBind()
End With
Me.WebReport1.ReportFile = pCaminho
Me.WebReport1.DataBind()
End Sub
Private Sub ci_relatorios_relDocumento_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not IsPostBack Then
RecebewParametros()
PovoaRelatorio()
End If
End Sub
Protected Sub BtnVoltar_Click(sender As Object, e As EventArgs) Handles BtnVoltar.Click
Response.Redirect("../consDocumento.aspx")
End Sub
End Class
Grateful,
Ilano