Usina BRAdvPL Guide
Sign in
← All topics
CLASSUnder review

FwPrinterXlsx

FwPrinterXlsx():New([lDelBase])

Generates XLSX through intermediate commands sent to printer.exe.

FwPrinterXlsxAdvPL
01 · OVERVIEW

Overview

Requires printer.exe 2.1.0 or newer on client and server, LIB 20201009 and release 12.1.23 or newer. Activate prepares the .rel file; AddSheet creates a worksheet and SetText writes a cell. toXlsx has documented NIL return: do not treat it as a success flag. The example prepares a block for a caller-supplied exclusive test path; it does not execute the block automatically. (Sources: refs. 1–1.)

02 · SYNTAX

Syntax

FwPrinterXlsx():New([lDelBase])

Methods

ActivatePrepares the base file.o:Activate(cFile, [oFile])
AddSheetAdds the required worksheet.o:AddSheet(cSheetName)
SetTextWrites cell text.o:SetText(nRow,nCol,cValue)
toXlsxRequests generation after commands.o:toXlsx() -> NIL
DeActivate / DestroyReleases activated elements and resources.o:DeActivate() / o:Destroy()
03 · PRACTICAL EXAMPLE

Commented example

#Include "Protheus.ch"

User Function Ed447()
    Local bGenerate := {|cRel| XlsxEd(cRel)}
    // Caller must supply a new authorized test path.
    ConOut(ValType(bGenerate))
Return Nil

Static Function XlsxEd(cRel)
    Local oXlsx := FwPrinterXlsx():New()
    Local lOk := .F.
    If !File(cRel)
        If oXlsx:Activate(cRel)
            lOk := oXlsx:AddSheet("ED01")
            If lOk
                lOk := oXlsx:SetText(1,1,"Review")
            EndIf
            If lOk
                oXlsx:toXlsx()
            EndIf
            oXlsx:DeActivate()
        EndIf
    EndIf
    oXlsx:Destroy()
    // lOk concerns commands, not final XLSX validation.
Return lOk
Expected result

Displays B and prepares generation; when invoking the block, validate the final file separately. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • Avoid concurrent filename reuse. File is a preliminary check, not an atomic reservation. GetStatusPrinter does not prove generation success.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

REFERENCES
  1. TOTVS. FwPrinterXlsx. TDN. Accessed on 2026-10-27.
Status
Under review
Page created on
Last reviewed on
Original language
Portuguese
Reviewed by
Usina.BR
0 approved comment(s)

Comments

There are no approved comments yet.

Sign in with Google or Microsoft to comment.

Powered by Usina Docs · Alpha