FwPrinterXlsx
FwPrinterXlsx():New([lDelBase])Generates XLSX through intermediate commands sent to printer.exe.
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.)
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()
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 lOkDisplays 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.
- 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.

Comments
There are no approved comments yet.
Sign in with Google or Microsoft to comment.