[翻译] FastReport 格式化和突出显示
一:格式化一个值
聚合函数的一个特征是,返回的数值没有格式化,如如下例子所示,它使用“SUM”:
数据字段通常返回一个格式化的值,这是一个没有任何变化的“文本”对象所显示的值. 格式化“SUM” 的结果, 让我们用FastReport中的格式化工具.
双击报表上的对象,切换到'Display Format...' 页进行设置:
这个编辑器在左边显示格式的类别, 相应的格式字符显示在右边. 我们选择 “Number” 分类和 "$1,234.50" 格式. 格式字符串是“Format”函数的一个参数, FastReport使用来实现数字格式的. 格式字符串和小数分隔符可以改变. 如果将小数分隔符留下空白,则使用当前区域设置值.
点击后ОК并预览报表,你会发现现在报表的总和是正确的格式:
Note the combobox at the top of the dialogue form. If we have more than one expression in an object, we may set different formatting for each expression.
二:内部格式化
内部格式化允许你在对象上设置不同的格式化字符串表达式. 这个被用于以前版本的FastReport. 现在是过时的(使用格式化对话为每个表达式设置不同的格式).
使用例子, re-size the footer and its object and change the object text to this:
Total: [SUM(<Group."ItemsTotal">,MasterData1)]
Number: [COUNT(MasterData1)]
The total and the number of orders will be displayed in the object.
In the report preview both of these values are shown in monetary format, which we had previously set. This is incorrect:
To display each value in its correct format they need to be formatted individually. To do this we use format tags, which are placed just before the closing square bracket of the expression. In our example, disable formatting for the object (select “Text (no formatting)” category in the format editor). Now we need to specify the format for just the first expression, as the second one will be displayed correctly by default (i.e. as an integer). Change the object text as follows:
Sum: [SUM(<Group."ItemsTotal">,MasterData1) #n%2,2m]
Number: [COUNT(MasterData1)]
Preview the report to make sure that the object is displayed correctly:
The general syntax of format tags is:
[expression #formattag]
Note that the space character between the expression and the “#” symbol is mandatory! The format tag itself might look like:
#nformat_string – numerical format
#dformat_string – date/time format
#bFalse,True – boolean format
Format_string in each case is the argument to the function used for formatting. So, for numerical formatting the Delphi Format function is used, and for date/time the FormatDateTime function. The syntax for these functions can be found in the Delphi help system. Below are several values used in FastReport:
for numerical formatting:
%g – number with the minimal places after the decimal point
%2.2f – number with a fixed number of places after the decimal point
%2.2n – as previous, but with thousands separator
%2.2m – monetary format, accepted by the Windows OS, dependent on the regional settings in the control panel
for date/time formatting:
dd.mm.yyyy – date as '23.12.2003'
dd mmm yyyy – date as '23 Nov 2003'
dd mmmm yyyy – date as '23 November 2003'
hh:mm – time as '23:12'
hh:mm:ss – time as '23:12:00'
dd mmmm yyyy, hh:mm – date and time as '23 November 2003, 23:12'
A comma or a dash can be used instead of the dot in the format_string for numerical formatting. This symbol is used as the separator between the integer and the fractional parts of the value. Any other character is not allowed.
For formatting with the “#b” type (boolean), the format_string is entered as two values separated by a comma. The first value corresponds to “False” and the second to “True”.
三:有条件的突出
在给定的条件下,可以改变“文本”对象的外观. 比如, 如果某个对象是负值,则可以用红色高亮显示. 这个特性叫"conditional highlighting". 要使用它,选择文本对象并单击工具栏中的 按钮.你将看到以下窗口:
可以设置一个或多个条件,每个条件可以包含以下的样式:
·frame; 边框
·fill; 填充
·font; 字体
·object's visibility. 是否可见
点击 "Add" 按钮. 你将看到一个表达式编辑器. 这里你可以写任意返回结果是布尔型的表达式. 多数情况下,使用"Value" 变量, 他表示当打印打印的值.
让我们看以下例子: 打印产品表中的某个字段:
[Products."UnitsInStock"]
我们想如果值 = 0 打印红色. 我们创建以下表达式:
Value = 0
在给定的条件下, 我们使用"Value" 变量, 它表示打印的值. 如果有多个表达式, 变量的值就是最后一个表达式的值.你可以使用数据列来取值:
<Products."UnitsInStock"> = 0
配置如下:
当对象值是0时,显示红色. 我们添加更多的条件, 如果少于10, 打印黄色. 如下:
Value < 10
在有多个条件情况下, FastReport 检查所有的条件, 从第一个开始. 如果某个条件满足, FastReport 应用他的样式设置, 并停止往下. 所以条件的顺序很重要. 以下顺序是正确的:
1. Value = 0
2. Value < 10
以下顺序工作不正常.
1. Value < 10
2. Value = 0
上面的 "Value = 0" 将不被执行, 因为先满足第一个条件, 调整顺序使用 和
按钮。
四:用颜色显示交替的数据行
使用条件突出,很容易创建有一个“带状”的报表,数据行交替着色的报表。为了节省时间,让我们用之前设计的“客户清单”的例子。
放置一个“文本”对象在数据带上,并延伸到几乎所有的带空间:
访对象根据数据行来改变颜色. 在对象上增加以下条件:
<Line> mod 2 = 1
选择一个灰色的颜色作为突出,不太饱和的颜色,但接近白色。现在可以将其他对象添加到第一个空的“文本”对象上的数据带中:
预览结果如下:
[翻译] FastReport 格式化和突出显示的更多相关文章
- vue_过滤器: 对要显示的数据进行特定格式化后再显示
过滤器 对要显示的数据进行特定格式化后再显示 并未改变原本的数据,可是产生新的对应的数据 <!DOCTYPE html> <html lang="en"> ...
- C#后台格式化JSON字符串显示
很多时候我们从服务器上获取的JSON字符串是没有格式化的,如下: {"BusinessId":null,"Code":200,"Data": ...
- [翻译] FastReport TfrxReport组件使用
一:加载和保存报表 报表默认保存在项目窗体文件中,大多数情况下,没有更多的操作要深圳市, 因此,你不需要采取特别措施来载入报告.如果你决定保存报表到文件或是数据库中 (这样更灵活, 比如修改报表不用重 ...
- [翻译] FastReport "Text" 对象中使用表达式
文本对象的最重要的功能之一是它不仅能够显示静态文本还能显示表达式.表达式混合在正常的文本内容中,让我们看一个简单的例子,他是如何工作的.在文件对象的内容中,输入以下字符: Hello, World! ...
- [翻译] FastReport 变量列表使用
使用报表变量时,引用"frxVariables"单元. 变量定义在"TfrxVariable" 类: TfrxVariable = class(TCollect ...
- [翻译] FastReport Class Hierarchy (FastReport 组件类层次结构)
"TfrxComponent" is the base class for all FastReport components. Objects of this type have ...
- ftl文件格式化jsp形式显示
通过myeclipse设置ftl的编辑器为jsp的编辑器,达到效果. Myeclipse->windows->preferences 1\ 2\ 3\ 完成后即可.
- C# 格式化 中文星期 显示
最近有些小忙,直接贴代码吧, /// <summary> /// 获取系统的星期 /// </summary> /// <param name="dt" ...
- jqGrid 日期格式化,只显示日期,去掉小时分
{name:'operateTime',index:'operateTime', formatter:"date", formatoptions: {newformat:'Y-m- ...
随机推荐
- docker 入門
http://dockone.io/article/277 我的碎碎念:Docker入门指南 [编者的话]之前曾经翻译过很多Docker入门介绍的文章,之所以再翻译这篇,是因为Anders的角度很独特 ...
- cloudrea manager 调整datanode数据存储目录
由于datanode所需磁盘空间较大,所以工作中可能会涉及到给datanode增加磁盘目录或者更改数据目录 CM停止该datanode节点 CM页面增加目录或者修改目录 如果是修改目录的话 需要将服务 ...
- 在c#下用 WCF编写restful
1.添加WCF服务库 2.在global里面注册路由 RouteTable.Routes.Add(new ServiceRoute("api", new WebServiceHos ...
- Redis启动与使用
在redis文件夹下,启动redis服务端的命令如下: .\redis-server 也可以指定要加载的配置文件,如下: .\redis-server ..\redis.conf 启动redis客户端 ...
- Drying
Drying http://poj.org/problem?id=3104 Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 2 ...
- oracle 使用正则表达式获取字符串中包含的数字
select REGEXP_REPLACE('字符串中包含的数字123,提取后就是123', '[^0-9]', '') from dual;
- adf常用方法总结
1.使用clientAttribute传值.获取值 或组件上面放客户端属性 <af:selectBooleanCheckbox text="" label="&qu ...
- linux 操作笔记
1.设置防火墙,允许用户使用http访问本机 [root@localhost geoserver]# systemctl enable httpdCreated symlink from /etc/s ...
- Ui设计流行趋势,对颜色的探讨
设计风向转换的趋势越来越短,在设计圈中,流行设计的跟新换代更是快.在设计时间越来越短的今天,在经理领导不断催促的时下,如何准确的把握当下的流行趋势,如何在设计之初就能定好设计的基调.这对于还是刚入设计 ...
- mupdf编译snprintf冲突问题
mupdf-1.6-source\thirdparty\jbig2dec\config_win32.h //# define snprintf _snprintf