<< Click to display table of contents >> Template syntax | Data Field Types |
A type may be specified explicitly in:
<field type> ::= text | int | float | bool | datetime | date | time | minutes | seconds | mseconds | blob | ansimemo | unicodememo | document | rtf | rvf | docx | html | markdown | image | bitmap | gif | png | jpeg | tiff | icon | metafile | <alternative rvf name> | <custom field type>
<alternative rvf name> is a text of RVReportGenerator.Texts.RVF.
If specified, it is one of: text, int, float, bool, datetime, date, time, minutes, seconds, mseconds, blob, ansimemo, unicodememo, document, rtf, docx, html, markdown, rvf, image, bitmap, gif, png, jpeg, tiff, icon, metafile. As you can see, these types correspond to TRVReportFieldType.
Additionally, the value RVReportGenerator.Texts.RVF is treated as 'rvf'.
Additionally, programmers can register their own field types.
Field type |
Meaning |
text |
text string, may be multiline |
int |
integer value (Int64) |
float |
floating point value (Extended for Delphi 2009 or newer, Double otherwise) |
bool |
boolean value |
datetime |
date and time (TDateTime) |
date |
date (TDateTime) |
time |
time (TDateTime) |
minutes |
converts integer value (number of minutes) to time (TDateTime)* |
seconds |
converts integer value (number of seconds) to time (TDateTime)* |
mseconds |
converts integer value (number of milliseconds) to time (TDateTime)* |
blob |
BLOB field containing either a document or a graphic; the actual content type is detected by format**,***,**** |
ansimemo |
BLOB field containing ANSI text**, HTML, or RTF |
unicodememo |
BLOB field containing either Unicode (UTF-16) text or RTF (converted to UTF-16), or HTML (in UTF-16 encoding) |
document |
BLOB field containing text**,***, RTF****, DocX, HTML, or RVF |
rtf |
RTF**** |
docx |
Microsoft Word Document (DocX) |
html |
HTML |
markdown |
Markdown (in UTF-8 encoding) |
rvf, RVReportGenerator.Texts.RVF |
RVF |
image |
graphic; format is detected by content |
bitmap, gif, png, jpeg, tiff, icon, metafile |
graphic of the specific format |
* the result must be less than 24 hours
** if the field contains text, the report generator tries to detect if it contains Unicode (UTF-16) or ANSI
*** ANSI text encoding is defined in DefCodePage property of TRVStyle component linked to the editor containing the report template; by default, this is a default Windows code page
**** if the field contains RTF, the report generator tries to detect if RTF codes are stored as Unicode (UTF-16) or ANSI
There are several reasons to specify a type:
•converting value to another format (for example, float to int, datetime to date)
•more efficient processing (for example, blob to rvf allows skipping a format detection step)
•allowing to use format string from another field type (for example, int to float allows formatting integer values as floating point values)
•ignoring a field type returned by a query processor, and using the specified type;
•specifying a format that cannot be auto-detected (markdown)
•visualizing values in special ways (especially when using custom field types).
Barcodes with Zint for Delphi adds two new field types: barcode and qrcode.
Not all combination of the original type and the specified type are allowed. If a combination of types is incorrect, the specified type is ignored.
All types can be converted to 'text' (pictures are converted to empty text).
Additionally, the following conversions are possible.
Original field type |
Can be converted to... |
text |
int, bool, float, datetime, date, time, datetime |
int, float, bool |
int, float, bool, minutes, seconds, mseconds |
time, date, datetime |
time, date, datetime |
blob, ansimemo, unicodememo, document, rtf, docx, html, markdown, rvf, image, bitmap, gif, png, jpeg, tiff, icon, metafile |
blob, ansimemo, unicodememo, document, rtf, docx, rvf, html, markdown, image, bitmap, gif, png, jpeg, tiff, icon, metafile |
Notes:
•when converting non-blob types, the value is received from a query processor basing on its original type; then this value is converted to the specified type
•when converting any blob type to each other or to "text", no value conversion occurs; instead, a report generator tries to load content in the specified format.
•when converting to bool, the same rules are used as for the conversions in expressions.
•when converting bool to int or float, False is converted to 0, True to 1.
Programmers can implement additional data types. Objects that process custom data types can get initial value and return its different representation; additionally, they can [pre]process format strings.
For example, RVReportSampleFieldObjects unit implements the following additional field types:
•num2words – spells a number in English (int to text); for example, '{value num2words}' for value 21 returns 'twenty one';
•uppercase – returns text in upper case (text to text); for example '{name uppercase}' for 'John' returns 'JOHN';
•star – returns an image of a star having as many points as defined in the input value (int to bitmap); this field type processes format strings itself; example: '{value start "size=100 color=red linecolor=blue gradient=1 middlepercent=60"}'
•imageinfo – returns text describing the input image (image to text); it returns text like '[Image 250×150]'
See also: extending Report Workshop