对于自动补空行或格线的情况,一般出现在以下两种情况:
1:清单类打印,最后一页数据不满时以空行或者格线填满
UPDATE 2005年4月27日
感谢奚彧的提醒,发现这篇文章,刚好是这种情况的说明
http://blog.csdn.net/landlordh/archive/2005/02/05/281590.aspx
幸亏自己没写,呵呵,不然可真是浪费了~~
2:单据类,一般单据格式固定,如每张打印5行数据,不满处则以格线补满5行。
UPDATE 2005年8月1日
感谢bonheur的提醒,原文最后一组时公式错误
我们以第2种情况为例进行说明,因为第2种会了第1种也自然就明白了
在这里我们使用模板公式来实现该功能,而不是用程序代码实现。
该方法并不是很灵活,欢迎大家进行讨论。
非常感谢CSDN的阿土及飞翔的心对本文的贡献
我在这里只担当一个文章整理及讲解的角色,现在开始
我们现在有张单据是这样的,这是我用Word做出来的
0 && image.height>0){if(image.width>=700){this.width=700;this.height=image.height*700/image.width;}}">
对于这种单据,我们一般采用定制纸型的方式,将执行设置为与单据规格一样的纸型
这里我这步就省略了。
构造如下数据
0 && image.height>0){if(image.width>=700){this.width=700;this.height=image.height*700/image.width;}}">
我们在做的时候,以"品牌"进行分组。
本模板中假定每组的数据不超过每张凭证的最大行数。
我们按正常步骤做一个按品牌进行分组的模板
Groupnumber mod 1=0
进入节专家,在详细资料节中插入4个空节,
0 && image.height>0){if(image.width>=700){this.width=700;this.height=image.height*700/image.width;}}">
勾上这四节的"抑制显示" ,分别以Crystal语法写入以下公式
详细资料b
0 && image.height>0){if(image.width>=700){this.width=700;this.height=image.height*700/image.width;}}" align=top>If on
0 && image.height>0){if(image.width>=700){this.width=700;this.height=image.height*700/image.width;}}" align=top> If COUNT({材料采购明细.材料名称},{材料采购明细.品牌})<5 Then
0 && image.height>0){if(image.width>=700){this.width=700;this.height=image.height*700/image.width;}}" align=top> False
0 && image.height>0){if(image.width>=700){this.width=700;this.height=image.height*700/image.width;}}" align=top> Else
0 && image.height>0){if(image.width>=700){this.width=700;this.height=image.height*700/image.width;}}" align=top> True
0 && image.height>0){if(image.width>=700){this.width=700;this.height=image.height*700/image.width;}}" align=top>Else
0 && image.height>0){if(image.width>=700){this.width=700;this.height=image.height*700/image.width;}}" align=top> COUNT({材料采购明细.材料名称},{材料采购明细.品牌})>=5 Or (Next({材料采购明细.品牌})={材料采购明细.品牌})
对该节公式做一下说明
如果当前记录是最后一条记录
判断该组的条数是否>=5 如果符合,则不一致显示(也就是显示);否则,一致显示
如果不是最后一条记录
如果该组条数>=5 或者 下一条记录与本条记录是同一组的,则抑制显示
通俗点说就是这样的
一共有5个节,第一节有数据则填充,没数据当然就不填充了
然后开始判断第2个节
对于第2个节,如果该组的总记录条数大于>=5条,则前面的第一个节就已经填充满了,此处就不必要显示了(True)
同样的,如果下一个记录与本条记录的值一样的话,那么说明后面还有数据,也就不用显示了(True)
但是对于最后一条数据,需要特别处理
最后一条数据的后面就没有数据了
所以如果条数>=5的话,那么前一个节肯定没填充满,所以就显示该节(False)
否则,如果条数不足5条的话,则前面已经处理完了(在前一轮循环中),就不显示该节了(True)
详细资料c
0 && image.height>0){if(image.width>=700){this.width=700;this.height=image.height*700/image.width;}}" align=top>If on
0 && image.height>0){if(image.width>=700){this.width=700;this.height=image.height*700/image.width;}}" align=top> If COUNT({材料采购明细.材料名称},{材料采购明细.品牌})<4 Then
0 && image.height>0){if(image.width>=700){this.width=700;this.height=image.height*700/image.width;}}" align=top> False
0 && image.height>0){if(image.width>=700){this.width=700;this.height=image.height*700/image.width;}}" align=top> Else
0 && image.height>0){if(image.width>=700){this.width=700;this.height=image.height*700/image.width;}}" align=top> True
0 && image.height>0){if(image.width>=700){this.width=700;this.height=image.height*700/image.width;}}" align=top>Else
0 && image.height>0){if(image.width>=700){this.width=700;this.height=image.height*700/image.width;}}" align=top> COUNT({材料采购明细.材料名称},{材料采购明细.品牌})>=4 Or (Next({材料采购明细.品牌})={材料采购明细.品牌})
详细资料d
0 && image.height>0){if(image.width>=700){this.width=700;this.height=image.height*700/image.width;}}" align=top>If on
0 && image.height>0){if(image.width>=700){this.width=700;this.height=image.height*700/image.width;}}" align=top> If COUNT({材料采购明细.材料名称},{材料采购明细.品牌})<3 Then
0 && image.height>0){if(image.width>=700){this.width=700;this.height=image.height*700/image.width;}}" align=top> False
0 && image.height>0){if(image.width>=700){this.width=700;this.height=image.height*700/image.width;}}" align=top> Else
0 && image.height>0){if(image.width>=700){this.width=700;this.height=image.height*700/image.width;}}" align=top> True
0 && image.height>0){if(image.width>=700){this.width=700;this.height=image.height*700/image.width;}}" align=top>Else
0 && image.height>0){if(image.width>=700){this.width=700;this.height=image.height*700/image.width;}}" align=top> COUNT({材料采购明细.材料名称},{材料采购明细.品牌})>=3 Or (Next({材料采购明细.品牌})={材料采购明细.品牌})
详细资料e
0 && image.height>0){if(image.width>=700){this.width=700;this.height=image.height*700/image.width;}}" align=top>If on
0 && image.height>0){if(image.width>=700){this.width=700;this.height=image.height*700/image.width;}}" align=top> If COUNT({材料采购明细.材料名称},{材料采购明细.品牌})<2 Then
0 && image.height>0){if(image.width>=700){this.width=700;this.height=image.height*700/image.width;}}" align=top> False
0 && image.height>0){if(image.width>=700){this.width=700;this.height=image.height*700/image.width;}}" align=top> Else
0 && image.height>0){if(image.width>=700){this.width=700;this.height=image.height*700/image.width;}}" align=top> True
0 && image.height>0){if(image.width>=700){this.width=700;this.height=image.height*700/image.width;}}" align=top>Else
0 && image.height>0){if(image.width>=700){this.width=700;this.height=image.height*700/image.width;}}" align=top> COUNT({材料采购明细.材料名称},{材料采购明细.品牌})>=2 Or (Next({材料采购明细.品牌})={材料采购明细.品牌})
这个时候模板中就增加了4行
在每个新增节的最上面画一条横线来实现表格形式,不然就从上到下的一个大框了
好,看看效果
0 && image.height>0){if(image.width>=700){this.width=700;this.height=image.height*700/image.width;}}">
0 && image.height>0){if(image.width>=700){this.width=700;this.height=image.height*700/image.width;}}">
下载模板文件
http://www.cnblogs.com/Files/babyt/Crystal1.rar
本文写得比较仓促,心里感觉不塌实
可能有不少不足之处,欢迎大家进行讨论
我有时间的话也会静下心来好好再看一下
-------Over------------------
希望这篇文章对你有所帮助。
阿泰 20050414
在论坛上经常会看到水晶报表分页的问题,这个很好解决。
但是自动插入空白行的问题却一直没有很好的答案,
经过研究找到一个变通的办法来实现了。
'分页
在详细资料上点格式化节,在后面页新建页打勾
公式中输入:
if on
FORMULA = FALSE
else
if RecordNumber mod 5 =0 then
FORMULA = TRUE
else
FORMULA = FALSE
end if
end if
'(BASIC 语法)
---------------------------------------------------------------------
最后页不足,用空行填充:
新增一个空白详细资料行,格式化此节,在抑制显示(无深化)打勾
公式中输入:
if not on
FORMULA = TRUE
else
if (RecordNumber mod 5 <= 1) then '第一个,1
FORMULA = TRUE
else
FORMULA = FALSE
end if
end if
'(BASIC 语法)
...接着第二个[ 新增一个空白详细资料行,格式化此节,在抑制显示(无深化)打勾 ]:
公式中输入:
if not on
FORMULA = TRUE
else
if (RecordNumber mod 5 <= 2) then '第二个,2
FORMULA = TRUE
else
FORMULA = FALSE
end if
end if
...接着第三个[ 新增一个空白详细资料行,格式化此节,在抑制显示(无深化)打勾 ]:
公式中输入:
if not on
FORMULA = TRUE
else
if (RecordNumber mod 5 <= 3) then '第三个,3
FORMULA = TRUE
else
FORMULA = FALSE
end if
end if
...(同理第四个,即最后5-1个)
(注:此方法适用于行数较少,上面是为5行为例,不过不觉得麻烦,对行数较多也可以用)
评论