一:格式化一个值

聚合函数的一个特征是,返回的数值没有格式化,如如下例子所示,它使用“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 格式化和突出显示的更多相关文章

  1. vue_过滤器: 对要显示的数据进行特定格式化后再显示

    过滤器 对要显示的数据进行特定格式化后再显示 并未改变原本的数据,可是产生新的对应的数据 <!DOCTYPE html> <html lang="en"> ...

  2. C#后台格式化JSON字符串显示

    很多时候我们从服务器上获取的JSON字符串是没有格式化的,如下: {"BusinessId":null,"Code":200,"Data": ...

  3. [翻译] FastReport TfrxReport组件使用

    一:加载和保存报表 报表默认保存在项目窗体文件中,大多数情况下,没有更多的操作要深圳市, 因此,你不需要采取特别措施来载入报告.如果你决定保存报表到文件或是数据库中 (这样更灵活, 比如修改报表不用重 ...

  4. [翻译] FastReport "Text" 对象中使用表达式

    文本对象的最重要的功能之一是它不仅能够显示静态文本还能显示表达式.表达式混合在正常的文本内容中,让我们看一个简单的例子,他是如何工作的.在文件对象的内容中,输入以下字符: Hello, World! ...

  5. [翻译] FastReport 变量列表使用

    使用报表变量时,引用"frxVariables"单元. 变量定义在"TfrxVariable" 类: TfrxVariable = class(TCollect ...

  6. [翻译] FastReport Class Hierarchy (FastReport 组件类层次结构)

    "TfrxComponent" is the base class for all FastReport components. Objects of this type have ...

  7. ftl文件格式化jsp形式显示

    通过myeclipse设置ftl的编辑器为jsp的编辑器,达到效果. Myeclipse->windows->preferences 1\ 2\ 3\ 完成后即可.

  8. C# 格式化 中文星期 显示

    最近有些小忙,直接贴代码吧, /// <summary> /// 获取系统的星期 /// </summary> /// <param name="dt" ...

  9. jqGrid 日期格式化,只显示日期,去掉小时分

    {name:'operateTime',index:'operateTime', formatter:"date", formatoptions: {newformat:'Y-m- ...

随机推荐

  1. 第六章 图(a)概述

  2. Codeforces Beta Round #12 (Div 2 Only)

    Codeforces Beta Round #12 (Div 2 Only) http://codeforces.com/contest/12 A 水题 #include<bits/stdc++ ...

  3. fiddler抓web请求

    原理 fiddler抓包原理 fiddler 调试器注册到操作系统因特网服务中,系统所有的网络请求都会走fiddler的代理,所以fiddler才能抓包. Debug traffic from any ...

  4. Partition List双色问题链表版

    [抄题]: Given a linked list and a value x, partition it such that all nodes less than x come before no ...

  5. Django开发问题及解决方法汇总

    1. manage.py@MxOnline > makemigrations users manage.py@MxOnline > migrate users 2. 操作django的ad ...

  6. 面向对象设计模式纵横谈:Builder 生成器模式(笔记记录)

    Builder模式的缘起 假设创建游戏中的一个房屋House设施,该房屋的构建由几个部分组成,且各个部分要富于变化. 如果使用最直观的设计方法,每一个房屋部分的变化,都将导致房屋构建的重新修正…… 动 ...

  7. 基于KVM的qemu中宿主机和虚拟机间的通信

    qga是一个运行在虚拟机内部的普通应用程序(可执行文件名称默认为qemu-ga,服务名称默认为qemu-guest-agent),其目的是实现一种宿主机和虚拟机进行交互的方式,这种方式不依赖于网络,而 ...

  8. Metro Revealed: Building Windows 8 apps with XAML and C# 阅读笔记

    第一章1.1.3中提到 Jesse Liberty 的<Pro Windows 8 Development with XAML and C#>,这是一本关于win8更全面的书,以后看.

  9. Mac下PHP+MySQL+Apache2环境搭建

    本机系统信息如下: -------------------------------------------------------------------------------------- OS: ...

  10. 【Unity】2.0 第2章 Unity编辑器和基本操作

    分类:Unity.C#.VS2015 创建日期:2016-03-26 本章要点: 1.掌握Unity 5.3.4编辑器视图和菜单项及其含义,这是入门的最基础部分,必须掌握. 2.了解最基本的操作,先学 ...