手抄报 安全手抄报 手抄报内容 手抄报图片 英语手抄报 清明节手抄报 节约用水手抄报

excel报表工具FineReport之参数界面及工具栏

时间:2024-10-22 09:43:01

FineReport本身自带多种可编辑控件,可以实现复杂参数界面的制作。但是有时为了实现与系统界面中控件的一致性,希望不使用FR内置的参数界面和内置工具栏,而是自己定义参数界面以及工具栏,此时要如何设置呢?

工具/原料

excel报表工具FineReport

1.解决思路

1、在自定义参数界面中介绍了自定义参数界面的实现方式,在自定义工具栏章节中介绍了各种按钮的实现方式,那么只需要将这两个实现过程结合起来即可。

2.示例

1、以自定义参数界面中的最终模板/demo/parameter/number1.cpt模板为例,将其嵌入到页面中去,并且不显示模板参数界面和内置工具栏。

2、1效果效果如下图所示

excel报表工具FineReport之参数界面及工具栏

3、输入最小库存量,点击查询,就会提交参数值给number1.cpt模板,并且在该页面显示过滤结果。

4、2网页设计网页设计参见自定义参数界面并传参,只需要再添加一个工具栏即可,工具栏添加的详细介绍请查看自定义工具栏按钮。在网页中添加如下代码:

5、<body><!--自定义工具栏--><divi蟠校盯昂d="toolbar"><buttontype="button"onclick="document.getElementById('reportFrame').contentWindow.contentPane.gotoFirstPage()">首页</button><buttontype="button"onclick="document.getElementById('reportFrame').contentWindow.contentPane.gotoPreviousPage()">上一页</button><buttontype="button"onclick="document.getElementById('reportFrame').contentWindow.contentPane.gotoNextPage()">下一页</button><buttontype="button"onclick="document.getElementById('reportFrame').contentWindow.contentPane.gotoLastPage()">末页</button><buttontype="button"onclick="document.getElementById('reportFrame').contentWindow.contentPane.flashPrint()">客户端FLASH打印</button><buttontype="button"onclick="document.getElementById('reportFrame').contentWindow.contentPane.exportReportToExcel('page')">导出[Excel](分页)</button><buttontype="button"onclick="document.getElementById('reportFrame').contentWindow.contentPane.exportReportToWord()">导出[Word]</button></div>

6、完整代码如下:<html><head><title>FineReportDemo</title><metahttp-equiv="Content-Type"content="text/html;charset=GBK"/><scripttype="text/javascript">//cjkEncode方法的实现代码,放在网页head中或者用户自己的js文件中functioncjkEncode(text){if(text==null){return"";}varnewText="";for(vari=0;i<text.length;i++){varcode=text.charCodeAt(i);if(code>=128||code==91||code==93){//91is"[",93is"]".newText+="["+code.toString(16)+"]";}else{newText+=text.charAt(i);}}returnnewText;}functionautoSubmit(){varnum=document.getElementById('num').value;//获取文本控件的值varrow=document.getElementById('row').value;//获取下拉框控件的值//拼接出最终报表访问路径,并对完整的路径进行编码转换,防止乱码问题varreportURL=cjkEncode("/WebReport/ReportServer?reportlet=/demo/parameter/number1.cpt¶="+num+"&row="+row);document.paraForm.action=reportURL;//通过form的name获取表单,并将报表访问路径赋给表单的actiondocument.paraForm.submit();//触发表单提交事件}</script></head><body><fieldset><legend>查询表单:</legend><formname="paraForm"method="post"target="reportFrame">最小库存量:<inputtype="text"name="num"id="num"value="1"/>每页显示行数:<selectname="row"id="row"><optionvalue="10"select>10<optionvalue="20">20<optionvalue="30">30<inputtype="button"name="show"value="查询"onclick="autoSubmit()"/></form><!--自定义工具栏--><divid="toolbar"><buttontype="button"onclick="document.getElementById('reportFrame').contentWindow.contentPane.gotoFirstPage()">首页</button><buttontype="button"onclick="document.getElementById('reportFrame').contentWindow.contentPane.gotoPreviousPage()">上一页</button><buttontype="button"onclick="document.getElementById('reportFrame').contentWindow.contentPane.gotoNextPage()">下一页</button><buttontype="button"onclick="document.getElementById('reportFrame').contentWindow.contentPane.gotoLastPage()">末页</button><buttontype="button"onclick="document.getElementById('reportFrame').contentWindow.contentPane.flashPrint()">客户端FLASH打印</button><buttontype="button"onclick="document.getElementById('reportFrame').contentWindow.contentPane.exportReportToExcel('page')">导出[Excel](分页)</button><buttontype="button"onclick="document.getElementById('reportFrame').contentWindow.contentPane.exportReportToWord()">导出[Word]</button></div></fieldset><iframeid="reportFrame"name="reportFrame"width="100%"height="100%"></iframe></body></html>

7、已完成页面请参照%FR_HOME%\WebReport\page_demo\parameter_toolbar.html.

© 手抄报圈