Saving generated reports

Revision date: 10/4/2003

XFRX is able to save the generated report to a file and preview it or transform it to any of the target formats (PDF, Word, HTML, Excel) any time later.

To save the report, send "XFF" as the target parameter and the name of the file as the output name parameter of the SetParams() method:

LOCAL loSession, lcReportFile
lcReportFile = "output.xff"
loSession=EVALUATE([xfrx("XFRX#INIT")])
IF loSession.SetParams(lcReportFile,,,,,,"XFF") = 0
    loSession.ProcessReport("report")
    loSession.finalize()
ENDIF
By default, .XFF extension (XFrx File) is added to the output file. The XFF file is internally stored as a normal DBF file, and because Memo fields are used for some of its columns, another file with the same name and .FPT extension is created.

To preview or process the stored report, you need to initialize a XFRXDraw object, link it to the stored file and send it as a parameter of TransformReport.

Example: Transforming a stored XFF file to a PDF document.

LOCAL loSession, loReport
loSession=EVALUATE([report("XFRX#INIT")])
lcName = "output.xff"
loReport = EVALUATE([report("XFRX#DRAW")])
IF loReport.openDocument(lcName)
    lnRetVal = loSession.SetParams("output.pdf",,,,,,"PDF")
    loSession.TransformReport(loReport)
ENDIF
In case you wanted to preview the report, the code would be very similar:
LOCAL loSession, loReport
loSession=EVALUATE([report("XFRX#INIT")])
lcName = "output.xff"
loReport = EVALUATE([report("XFRX#DRAW")])
IF loReport.openDocument(lcName)
    thisform.cntXFRX.reset() && let's assume the XFRX container reference is thisform.cntXFRX
    lnRetVal = loSession.SetParams(,,,,,,"CNT")
    loSession.setOtherParams(thisform.cntXFRX)
    loSession.TransformReport(loReport)
ENDIF
You can also generate a page subset of the document. To achieve this, call SetPageRange() method with the page range definition as the parameter, for example:
loSession.setPageRange("2,4,5-8")
For a full featured example, please check the demo application in the latest evaluation version (download).