天天看点

pentaho report-designer 报表中添加相应的超链接及传参pentaho report-designer 报表中添加相应的超链接及传参

pentaho report-designer 报表中添加相应的超链接及传参

以前都是自己学习技术,自己做笔记都是自己看,最近有点想写博客,这是我第一篇博客。后续会将自己学习大数据的笔记及工作中遇到的问题也通过博客发出来。

使用pentaho做报表设计,而且需要在报表中使用超链接并可以传参。这几天在网上一直找相关的资料,但是发现基本没有,于是自己摸索。最后终于找到了实现方式。希望对刚学pentaho的同学有帮助(本文不对pentaho的搭建做说明)

注:如果有疏漏或错误的地方,请大家多多指教,谢谢

需要解决的问题:生成数据列表页和数据行的明细页——报表中添加相应的超链接

数据表:

表名:sale
字段:
saleId
cusId
unpiprice

第一步:新建一个报表

1.1 新建报表,  

pentaho report-designer 报表中添加相应的超链接及传参pentaho report-designer 报表中添加相应的超链接及传参

1.2 设置查询sql为:select * from sale where saleId = ${saleID} and cusId= ${cusID}

pentaho report-designer 报表中添加相应的超链接及传参pentaho report-designer 报表中添加相应的超链接及传参

1.3 设计报表

pentaho report-designer 报表中添加相应的超链接及传参pentaho report-designer 报表中添加相应的超链接及传参

1.4 添加参数:saleID,cusID

pentaho report-designer 报表中添加相应的超链接及传参pentaho report-designer 报表中添加相应的超链接及传参
pentaho report-designer 报表中添加相应的超链接及传参pentaho report-designer 报表中添加相应的超链接及传参
pentaho report-designer 报表中添加相应的超链接及传参pentaho report-designer 报表中添加相应的超链接及传参

1.5 发布

pentaho report-designer 报表中添加相应的超链接及传参pentaho report-designer 报表中添加相应的超链接及传参

获取当前页面的url:http://localhost:8080/pentaho/api/repos/%3A%E8%BF%9E%E6%8E%A54.prpt/viewer

第二步:新建另一个报表

2.1 新建报表

2.2 设置查询sql为:select saleId,cusId from sale where saleId(步骤同上)

2.3 设计报表

pentaho report-designer 报表中添加相应的超链接及传参pentaho report-designer 报表中添加相应的超链接及传参

2.4 设计超链接

右击 Details 中的 saleId,选择 HyperLink

pentaho report-designer 报表中添加相应的超链接及传参pentaho report-designer 报表中添加相应的超链接及传参

选择 Location --> Manual Linking

pentaho report-designer 报表中添加相应的超链接及传参pentaho report-designer 报表中添加相应的超链接及传参

在Formula 填写以下内容:

=DRILLDOWN("generic-url"; "http://localhost:8080/pentaho/api/repos/%3A%E8%BF%9E%E6%8E%A54.prpt/viewer"; {"saleID"; [saleId] | "cusID"; [cusId]})

注意格式为:=DRILLDOWN("generic-url";"需要链接的url(第一个报表的url)";{"参数名称()";[传参字段名] |"参数名称()";[传参字段名]})

2.5 发布改报表(操作同上)

第三步:web查看

点击 saleId 栏的数值。便可以连接到第一个报表中。

pentaho report-designer 报表中添加相应的超链接及传参pentaho report-designer 报表中添加相应的超链接及传参
pentaho report-designer 报表中添加相应的超链接及传参pentaho report-designer 报表中添加相应的超链接及传参

操作结束。

saleId