TReport

Framework moderno de relatorios. Substituiu Cabec/SetPrint legados. Gera PDF, Excel, HTML a partir do mesmo codigo.

Assinatura: oReport := TReport():New(cNome, cTitulo, cPergunte, bAcao, cDesc)

Retorna: TReport object

TReport e o framework de relatorios atual do Protheus. Voce define secoes (tabelas), colunas, regras de agrupamento — e o framework cuida de paginacao, exportacao (PDF/XLS/CSV/HTML), filtros.

User Function RelCli()
    Local oReport := TReport():New("RELCLI", "Clientes", "MTRELCLI", ;
                                   {|oRep| RelPrint(oRep)}, "Lista de clientes")
    Local oSection := TRSection():New(oReport, "Clientes", {"SA1"})

    TRCell():New(oSection, "A1_COD",  "SA1", "Codigo")
    TRCell():New(oSection, "A1_NOME", "SA1", "Razao Social")
    TRCell():New(oSection, "A1_CGC",  "SA1", "CNPJ")

    oReport:PrintDialog()
Return

Static Function RelPrint(oReport)
    Local oSec := oReport:Section(1)
    SA1->(DBSetOrder(1))
    SA1->(DBSeek(xFilial("SA1")))
    oSec:Init()
    While !SA1->(Eof()) .And. SA1->A1_FILIAL == xFilial("SA1")
        oSec:PrintLine()
        SA1->(DBSkip())
    EndDo
Return

Vantagens vs Cabec/Roda

Veja também