Sameway, there is a command XBREPORT which can be used to generate simple reports with just one or few lines of code. The syntax is almost like XBROWSE syntax. This command creates xbrowse in a hidden window and runs its Report method.
This command is useful when we quickly need to print a no-frills report.
In its simplest form :
USE CUSTOMER NEW
XBREPORT oTmp TITLE "CUSTOMERS" ALIAS "CISTOMER" AUTOCOLS
CLOSE CUSTOMERWith this one line of code the report is ready in preview.
The generated report is as good or as bad as any report generated by Xbrowse's Report() method. But to write the code required to generate the above code using REPORT command requires more time and many lines of code.
We may try these two samples:
#include "FiveWin.Ch"
#include "xbrowse.ch"
REQUEST DBFCDX
function Main()
local oTmp, oRs
SET DELETED ON
FWNumFormat( "A", .t. )
RPrevUserBtns( nil, 2010 )
MsgInfo( "Quick Report from DBF" )
USE CUSTOMER NEW ALIAS CUST SHARED READONLY VIA "DBFCDX"
XBREPORT oTmp TITLE "CUSTOMERS" ;
DATASOURCE "CUST" COLUMNS "FIRST", "LAST", "CITY", "STATE", "AGE", "SALARY" ;
BRWSETUP { |oBrw| oBrw:Salary:nFooterType := AGGR_SUM } ;
REPSETUP { |oRep| oRep:lJoin := .t., nil }
CLOSE CUST
return (0)Result:

We can use all clauses of the XBrowe command syntax lile headers, picture clauses, alignments, etc and can easily handle memos and pictures too,.
We may try another example with a recordset:
#include "FiveWin.Ch"
#include "xbrowse.ch"
function Main()
local oTmp, oRs
XbrNumFormat( 'A', .t. )
RPrevUserBtns( nil, 2010 )
MsgInfo( "Quick Report from ADO" )
oRs := FW_OpenRecordSet( "xbrtest.mdb", "CUSTOMER" )
XBREPORT oTmp TITLE "CUSTOMERS" ;
DATASOURCE oRs COLUMNS "FIRST", "LAST", "CITY", "STATE", "AGE", "SALARY" ;
BRWSETUP { |oBrw| oBrw:Salary:nFooterType := AGGR_SUM }
oRs:Close()
oRs:ActiveConnection:Close()
return (0)This command is available in xbrowse.ch.
G. N. Rao.
Hyderabad, India
