RTFReport2
RTFReport2 is non visual component which provides functionality for
generating reports according prepared RTF template file with special TAGs.
RTFReport2 use this template and fill data into it instead of TAGs.
Main advantages of this solutions are:
- RTF template file is stand alone file independent on application
- RTF template file can be modified easily by any RTF editor (i.g. MS Word)
- you can modify or add new types of report without changing applications
- Result of report is again RTF file which can be printed out immediately or saved for using in future
Example of report template Employee_list2.rtf (on each page is one example of report)
and the result of report Result.rtf
List of special tags which can be used inside of RTF template file:
(X) in tags specify one dataset, datasets are passed as parameter and are marked by character from A to Z
|
FIELD tags:
|
|
FIELDS tags is used for inserting of field value from selected dataset (X) and current record
\X.FieldName\
insert value of specified field in their default format, example: \A.LastName\
\X.FieldName:Format\
insert value of specified field in specified format, Format has the same format string as in Delphi
example: \A.Salary:# ##0.00\ \A.OrderDate:mm/dd/yy\
\X.#FieldIndex\ \X.#FieldIndex:Format\
insert value of field specified by their index, example: \A.#2\
Note:
if Format=LABEL then "Display Label" of the field will be inserted (not field value)
For graphics field can be used special format string composed from one or more parts separated by semicolon:
W=number - define max width of picture in pixels
H=number - define max height of picture in pixels
Wcm=number - define max width of picture in centimeters
Hcm=number - define max height of picture in centimeters
Rotate=number - define angle of rotation
Enlarge - define that smaller pictures than defined W or H will be enlarged
InsertInRTF - picture will be inserted directly to RTF report
in binary format (windows metafile is used),
if this tag is missing, in rtf report will be only link to external file with picture
Quality - define quality of inserted picture (10..100, 100=full quality; Auto=automatic resize)
SaveAsJPG - define that all pictures will be saved in report in JPG format
SaveAsBMP - define that all pictures will be saved in report in BMP format
NameField=fieldname - define field whose value will be used as filename of picture
example: \A.Photo:Wcm=5;Hcm=5;Rotate=90;InsertInRTF;Quality=Auto\
|
|
VARIABLES TAG:
|
|
\VariableName\
insert value of variable from list of variables which is defined in property Variables,
OnUserCalc events is called if variable is not found in variable list
Example: \UserName\
|
|
CALCULATION tags:
|
|
CALCULATION tags are used for inserting numeric value of any expression
\=expression:Format\
expression can contain:
- signs: + - * /
- any number of brackets: ( )
- number constant
- Field value: X.Field (value of the field must have number format)
- user defined variables (value of the variable must have number format)
- result of aggregation function: FuncName[X.Field] or FuncName[CalcName], where
FuncName can be one of Sum, Max, Min, Count, Avg or GrandSum, GrandMax, GrandMin, GrandCount, GrandAvg;
each X.Field or CalcName must be defined in CALC part of SCAN tags before using in aggregation functions
Example: \=B.Salary*1.2\ \=B.Salary*1.3:# ##0.00\ \=(Sum[A.Salary]+Sum[A.Bonus])/2:# ##0\
\ResetCalc\
reset all aggregation fields to 0
|
|
SCAN tags
|
|
Scan tags are used for repeating some part of report for more dataset records.
\Scan(X);While(condition);SkipIf(condition); NewCol;NewPage;NoIfEmpty;NoFirst; Calc(X.Field1,X.Field2,CalcAvg=(X.Field1+X.Field2)/2,...)\
- defines first point and conditions of scan function
- scan loop is finished when While condition come false
- scan loop skip record if SkipIf condition is true
- NewCol insert new column after each record
- NewPage insert new page after each record
- scan loop do not move to first record if NoFirst is used
- Calc defines list of Fields or Named expression for aggregation function, for each listed field or expression
will be calculated following values: Sum, Min, Max, Avg, Count and GrandSum, GrandMin and so on
\ScanEntry(X)\
defines start point of repetition, this tag is optional
\ScanFooter(X)\
defines stop point of repetition, this tag is optional
\EndScan(X)\
defines last point of scan function
Typical use:
Example 1 - simple loop:
\Scan(B)\
body of table - is repeated for each record
\EndScan(B)\
Example 2 - full loop:
\Scan(B)\
any header
\ScanEntry(B)\
body of table - is repeated for each record
\ScanFooter(B)\
any footer
\EndScan(B)\
Example 3 - full loop with conditions:
\Scan(B);SkipIf(B.Retired);Calc(Salary,Bonus)\
any header
\ScanEntry(B)\
body of table - is repeated for each record
\ScanFooter(B)\
any footer
\EndScan(B)\
Note:
If any of scan tag is alone in the line, whole line will be deleted
|
|
RECORD MOVE tags
|
|
This tags can be used for moving dataset to another record. Usually is not necessary to use it.
\Next(X)\
\Prev(X)\
\First(X)\
\Last(X)\
|
|
IF and IIF tags
|
IF or IIF tags is used for inserting any text or dataset field dependently on any condition
IF tag is global, it means IF tag is processed before all scan function
IIF tag is inline tag, it means IIF tag is processed inside current scan, i.e. for each record
(it is important if you use dataset value inside condition)
\If(condition)\...block if true...\ElseIf\...block if false...\EndIf\
\IIf(condition)\...block if true...\ElseIIf\...block if false...\EndIIf\
Note:
"ElseIf" tag and "block if false" is optional
|
|
SPECIAL tags
|
|
\ListAllFields\
insert list of all dataset fields name, it is usefull only during creating new report
\SepList("sep",X.Field1,X.Field2,...)\
insert list of values separated by "sep", it is usefull in creating separeted list of any fields, because this function skips empty fields
\Picture(VariableName:Format)\
insert external graphic file to report, VariableName define Variable, which must contain full path to graphic file
(see VariableTags description), Format has the same possibility as for graphic fields
\DefVar(VariableName,Value)\
define variable which can be used everywhere in report, value can be any constant ("text") or expression
\Info(Name=Value)\
tag Info is used for backward communication from report to application
all Info tags are processed before any other action, so this tags can be enywhere in RTF template
tag body (Name=Value) will be added to property ExtendedInfo and event OnInfo will be called, so application
can make any action according ExtendedInfo content
Example:
this tag can be used for specifying of active printer and application can process it
\Info(Printer=HP Laser Jet 5L)\
\BarCode(expression):Format\
- insert BarCode picture
- expression defines displayed code and can be fieldtag, variable or constant (eg. "123")
- format can be made up from more parts devided by ;
- Type=string - define type of barcode from following
CodeEANAuto (auto detection according text length), CodeEAN8, CodeEAN13,
Code_2_5_interleaved, Code_2_5_industrial, Code_2_5_matrix,
Code39, Code39Extended,
Code128A, Code128B, Code128C,
Code93, Code93Extended, CodeMSI, CodePostNet, CodeCodabar,
CodeUPC_A, CodeUPC_E0, CodeUPC_E1, CodeUPC_Supp2, CodeUPC_Supp5,
CodeEAN128A, CodeEAN128B, CodeEAN128C
- ShowCode - defines showing of numeric code
- FontName - define font for numeric code + all tags for Pictures included Rotate, Wmax, Hmax and Quality
(Quality should be 100 for barcode)
|
|
CONDITIONS:
|
CONDITIONS can be used in SCAN tags (While or SkipIf) or in IF and IIF tags
condition can contain:
- signs: == <> >= <= = > <
- boolean field: X.Retired
- text field: X.Field
- text constant: "text"
- datetime constant: #YYYYHHMM# or #YYYYHHMMhhmmss#
- any expression (see above)
- any number of brackets: ( )
- logical operations: and or not
- test if dataset is empty: X.0
example of some conditions:
- A.Name="Tomas"
- A.Salary>30000
- A.Salary>30000 and B.State<>"NY"
- (not A.Retired) and (B.State="NY" or B.State="WA")
|
|