[水晶报表]基本语法

来源:互联网 发布:马代满月岛 知乎 编辑:程序博客网 时间:2024/04/30 09:51

简单介绍一下水晶报表的基本语法

组件的布局不做介绍

报表的筛选

报表段落与字段的隐藏与显示

1.IF条件表达式  THEN ...

 ELSE

    ......

例如:

IF {Rpt_JobPickListSp;1.nettable} = 1 THEN

   //TOTEXT({Rpt_JobPickListSp;1.det_QtyToPick}, {Rpt_JobPickListSp;1.qty_unit_format}, {Rpt_JobPickListSp;1.places_qty_unit})

    //ToText({Rpt_JobPickListSp;1.det_QtyToPick})

    Totext(iif({Rpt_JobPickListSp;1.det_JobMatlU_M}="PC" and {Rpt_JobPickListSp;1.det_QtyToPick}-int({Rpt_JobPickListSp;1.det_QtyToPick})<>0,int({Rpt_JobPickListSp;1.det_QtyToPick})+1,{Rpt_JobPickListSp;1.det_QtyToPick}))

ELSE

   ("sNon-Nettable")

2.iif(条件A,B,C)

如果满足A,变量的值为B,否则为C

例如

//Trim(ToText({Rpt_JobPickListSp;1.det_QtyAvailable}, {Rpt_JobPickListSp;1.qty_unit_format}, {Rpt_JobPickListSp;1.places_qty_unit}))//数量位数控制2小于零前面补充0

iif({Rpt_JobPickListSp;1.det_QtyAvailable}<1,"0"+totext({Rpt_JobPickListSp;1.det_QtyAvailable}),totext({Rpt_JobPickListSp;1.det_QtyAvailable}))

3.条件表达式(类似高级程序语言中的swtich case语句)

   select条件表达式

   case a: "a"

   case a: "b"

default:("sNo")

例如:

select {?@ReprintPickListItems}

case 1 : ("sYes")

default: ("sNo")

4.计数器

  WhilePrintingRecords;

  NumberVar Counter;

 Counter:=Counter +1;

5.if 条件表达式 then .. else if条件表达式 then ...

   else if 条件表达式  then ....

else 

 例如:

if {Rpt_GoodsReceivingNoteSp;1.stat} = "I" then ("sGrnStatus=I")

    else  if {Rpt_GoodsReceivingNoteSp;1.stat} = "A" then ("sGrnStatus=A")

    else if {Rpt_GoodsReceivingNoteSp;1.stat} = "S" then ("sGrnStatus=S")

    else ("sGrnStatus=H")

 

 6.ISNULL

例如

NumberVar GF1AmtPrice;

if(isNull(Sum ({Rpt_InventoryCostSp;1.amt_price}, {Rpt_InventoryCostSp;1.whse}))) then

    GF1AmtPrice:= 0.00

else

    GF1AmtPrice:=Sum ({Rpt_InventoryCostSp;1.amt_price}, {Rpt_InventoryCostSp;1.whse});

if GF1AmtPrice < 0 then

    "-" + Trim(ToText (Abs(GF1AmtPrice),{Rpt_InventoryCostSp;1.CostPriceFormat},{Rpt_InventoryCostSp;1.CostPricePlaces}))

else

    Trim(ToText (GF1AmtPrice,{Rpt_InventoryCostSp;1.CostPriceFormat},{Rpt_InventoryCostSp;1.CostPricePlaces}))

7. StrReverse

格式化字符串

列如

// tombus, 03.20.02

// to show the suffix as a string and to get the number looking like proper sequence

// if left suffix alone as a number it would appear as 0.00 or 2.00

// the user must see it as 0000 or 0002

// the StrReverse (totext({?@SuffixStarting}*1000,0)) takes the suffix 2.00 * 1000 = 2000 and then reverse the order so it

//  appears as 0002.

Shared stringVar Suffix := if {?@SuffixStarting}=0.00 then "0000" else StrReverse (totext({?@SuffixStarting}*1000,"0000"));

{?@JobStarting} + "-"+ Suffix

8.

同一记录显示一次

  

基本函数

 

space(n)n个空格的位置

ABS()取绝对值

totext()转换为文本数据框

isnull()判断是否为空

replace(字符串,A,'B')把字符串的A字符替换成B字符

Sum()汇总函数

int()是表示取整

Round(x,#places)保留几位小数

Length(str)返回字符串的长度

trm(str)去掉空格

TrimLeft(str)去掉左边空格

TrimRight(str)去掉右边空格

 

总之用到的时候去查询

原创粉丝点击