Java报表软件数据钻取在一个页面展开

       有一些客户希望在一个页面打开数据钻取的全部内容,这个功能可以利用iframe在自定义浏览界面解决,下面以一个简单的例子来说明:
1.
创建子模板son
1.1
打开Java报表软件设计器,新建工作簿,添加参数获取数据集SELECT * FROM STSCORE where classno = '${class}',设置参数class默认值Class1,合并A1F12单元格,插入柱状图,绑定数据如下表:


1.2
下一步去掉iframe里的工具栏:打开报表|报表Web属性|分页预览设置,清空所有按钮,取消页面样式
1.3
保存模板到%FR_HOME%\WebReport\WEB-INF\reportlets\son.cpt

2.
创建主模板father

2.1
新建工作簿,获取数据集SELECT * FROM STSCORE,配置数据如下表:






2.2
右击A2单元格,设置超级链接,增加网络报表1,选择网络报表%FR_HOME%\WebReport\WEB-INF\reportlets\son.cpt。取消显示在原有报表页面的勾选,在网络报表页面显示样式右边的空白输入inner2,插入报表参数class的值为A2,如图
  

2.3
去掉iframe里的工具栏,具体操作同子模板son
2.4
稍作美观,保存模板到%FR_HOME%\WebReport\WEB-INF\reportlets\father.cpt

3.
创建HTML文件iframe.html,源代码如下:
<html>
<head>
<title>自定义浏览页面</title>
<meta http-equiv="Content-Type" c>
<script type="text/javascript" src="/WebReport/ReportServer?op=resource&resource=/com/fr/web/jquery.js"></script>
<script type="text/javascript">
window.onload = function(){

reportFrame = document.getElementById("reportFrame").contentWindow.contentPane;


reportFrame.on("afterload", function(){




// currentPageIndex
是从1开始的


var cPageIndex = reportFrame.currentPageIndex;



var pv = "
" + cPageIndex + "/" + reportFrame.reportTotalPage +
"
";



$("#pnum").val(pv);


});

}
</script>
</head>

<body>
<div id="toolbar" >

<button type="button" >首页</button>
<button type="button" >上一页</button>

<input id="pnum" type="text" readonly="true" style="width:80px">

<button type="button" >下一页</button>

<button type="button" >末页</button>

<button type="button" >页面设置</button>

<button type="button" >客户端PDF打印</button>
<button type="button" >客户端FLASH打印</button>

<button type="button" >服务器打印</button>

<button type="button" >导出[Excel](分页)</button>
<button type="button" >导出[Word]</button>
<button type="button" >导出[PDF]</button>

<button type="button" >邮件</button>

</div>
<p align="center">

<iframe id="reportFrame" src="/WebReport/ReportServer?reportlet=father.cpt" frameborder="0"
width = "800" height = "128" ></iframe>


<iframe id="inner2" name="inner2" frameborder="0" width = "800" height = "300"></iframe>


</p>

</body>
</html>
注意:其中代码<iframe id="inner2" name="inner2" frameborder="0" width = "800" height = "300"></iframe>表示把主模板链接的子模板显示在一个iframe

4.
预览
打开内置服务器,在浏览界面输入URL地址:
http://localhost:8075/WebReport/iframe.html,效果如图:


这样,链接的报表直接出现在了被链接的报表下面
文章转自:http://blog.vsharing.com/fanfanzheng/A1385794.html