由于birt传参数的类型并没有数组,因此只能通过拼接字符串来进行查询
其dataSet的queryText如下
select pinking.id,pinking.wno,workpiece.wname,'' guige,'件' danwei,pinking.pinkCount,pinking.pinkCount,'' shouliaocangku,'' beizhu
from pinking,workpiece
where workpiece.wno=pinking.wno
其中的‘ ’ as guige 是为了打印表格时有空值,如下规格型号的这种效果,而‘件’则可以直接显示单位为“件”。
而where子条件则是通过脚本写入sql语句的,做的方法是,选中你的dataSet,点击下的Script
选择上方的beforeOpen,输入以下代码:
var id = params["id"].value;
this.queryText +=" and id in(" + id+")";
其中queryText即为sql语句,这样可以实现在打开前进行拼接sql语句,其中的params["id"].value是通过设置外传的参数
右击新建一个,选择display type 为text即可以创建,name即为接收他的变量,这样便可以进行动态sql语句的编写了,
其中也可以直接在链接的后面加参数,格式如下:
在jsp的URL里面添加所要传递的参数:
http://localhost:8080/birt-web/frameset?__report=test.rptdesign&sample=my+parameter
即&后写参数名称=参数值
在报表当中添加同名报表参数sample,然后可以添加data set参数关联到报表参数sample,这样data set参数就可以得到从jsp页面传递过来的参数从而作为查询条件。