有一些客戶希望在一個(gè)頁(yè)面打開數(shù)據(jù)鉆取的全部?jī)?nèi)容,這個(gè)功能可以利用iframe在自定義瀏覽界面解決,下面以一個(gè)簡(jiǎn)單的例子來說明:
1. 創(chuàng)建子模板son
1.1 打開Java報(bào)表工具設(shè)計(jì)器,新建工作簿,添加參數(shù)獲取數(shù)據(jù)集SELECT * FROM STSCORE where classno = '${class}',設(shè)置參數(shù)class默認(rèn)值Class1,合并A1至F12單元格,插入柱狀圖,綁定數(shù)據(jù)如下表:
1.2 下一步去掉iframe里的工具欄:打開報(bào)表|報(bào)表Web屬性|分頁(yè)預(yù)覽設(shè)置,清空所有按鈕,取消頁(yè)面樣式
1.3 保存模板到%FR_HOME%\WebReport\WEB-INF\reportlets\son.cpt
2. 創(chuàng)建主模板father
2.1 新建工作簿,獲取數(shù)據(jù)集SELECT * FROM STSCORE,配置數(shù)據(jù)如下表:
2.2 右擊A2單元格,設(shè)置超級(jí)鏈接,增加網(wǎng)絡(luò)報(bào)表1,選擇網(wǎng)絡(luò)報(bào)表%FR_HOME%\WebReport\WEB-INF\reportlets\son.cpt。取消顯示在原有報(bào)表頁(yè)面的勾選,在網(wǎng)絡(luò)報(bào)表頁(yè)面顯示樣式右邊的空白輸入inner2,插入報(bào)表參數(shù)class的值為A2,如圖
2.3 去掉iframe里的工具欄,具體操作同子模板son
2.4 稍作美觀,保存模板到%FR_HOME%\WebReport\WEB-INF\reportlets\father.cpt
3. 創(chuàng)建HTML文件iframe.html,源代碼如下:
<html>
<head>
<title>自定義瀏覽頁(yè)面</title>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<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 + "頁(yè)/共" + reportFrame.reportTotalPage + "頁(yè)";
$("#pnum").val(pv);
});
}
</script>
</head>
<body>
<div id="toolbar" >
<button type="button" onclick="reportFrame.gotoFirstPage()">首頁(yè)</button>
<button type="button" onclick="reportFrame.gotoPreviousPage()">上一頁(yè)</button>
<input id="pnum" type="text" readonly="true" style="width:80px">
<button type="button" onclick="reportFrame.gotoNextPage()">下一頁(yè)</button>
<button type="button" onclick="reportFrame.gotoLastPage()">末頁(yè)</button>
<button type="button" onclick="reportFrame.pageSetup()">頁(yè)面設(shè)置</button>
<button type="button" onclick="reportFrame.pdfPrint()">客戶端PDF打印</button>
<button type="button" onClick="reportFrame.flashPrint()">客戶端FLASH打印</button>
<button type="button" onclick="reportFrame.printReportServer()">服務(wù)器打印</button>
<button type="button" onClick="reportFrame.exportReportToExcel('page')">導(dǎo)出[Excel](分頁(yè))</button>
<button type="button" onClick="reportFrame.exportReportToWord()">導(dǎo)出[Word]</button>
<button type="button" onclick="reportFrame.exportReportToPDF()">導(dǎo)出[PDF]</button>
<button type="button" onclick="reportFrame.emailReport()">郵件</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>表示把主模板鏈接的子模板顯示在一個(gè)iframe中
4. 預(yù)覽
打開內(nèi)置服務(wù)器,在瀏覽界面輸入URL地址:
http://localhost:8075/WebReport/iframe.html,效果如圖:
這樣,鏈接的報(bào)表直接出現(xiàn)在了被鏈接的報(bào)表下面
文章轉(zhuǎn)自:http://blog.vsharing.com/fanfanzheng/A1385794.html
了解Java報(bào)表工具就從這里開始