日期:2014-05-17  浏览次数:20429 次

水晶报表字段格式化默认值遇到null居然无解!!
目标:格式化水晶报表上的字段
步骤:
1.选定字段a,右键Format Object
2.点击Dispaly String 【x-2】
3.输入公式:
if{Command.a}='' or isnull({Command.a}) then
'aaa '
else
{Command.a}

数据: 
a(字段名)                  
123(值)
null(值)

水晶报表上显示:
123


4.改公式:
if(1=1) then 's' else 'f'

水晶报表上显示:
s



结论
------------
为什么水晶报表中字段值为'null'时,设定公式不管用!

------解决方案--------------------
因为空值不会任何一个值比较,不想让它为空,必须先在数据库里转换为空字符串或0
------解决方案--------------------
try this:
iif(isnull({Command.a}),"",{Command.a})