时间:2021-07-01 10:21:17 帮助过:143人阅读
由于参数报表大多数都和数据报表联合发布查询数据,所以这里只介绍联合使用方式(单独发布与数据报表一样)。参数报表嵌入页面时使用的标签为
name="form1"
paramFileName="demo_arg.rpx"
params=""
/>
数据报表嵌入页面使用的标签为
属性srcType的不同值指定了不同的报表发布方式,以满足不同场景的需要。下面分别来看一下。
当srcType=”file”时为file方式发布报表,通过reportFileName属性指定报表模板名称完成报表发布。此方式为最常用的报表发布方式,具体使用可以参考如下书写方式:
srcType=”file”
name="report1"
reportFileName="demo.rpx"
funcBarLocation="top"
needPageMark="yes"
params="d_year=2014;u_id=10001"
exceptionPage="/reportJsp/myError2.jsp"
/>
除了直接指定报表文件,还可以发布程序读入的报表定义(ReportDefine),使用这中方式需要指定srcType=“defineBean”,具体使用可以参考如下书写方式:
<% //读入报表定义
String reportPath =request.getRealPath("/reportFiles/api/wangge.rpx");
ReportDefine rd =(ReportDefine)ReportUtils.read(reportPath);
request.setAttribute("reportDefine",rd);
%>
name="report1"
srcType="defineBean"
beanName="reportDefine"
exceptionPage="/reportJsp/jsp/myError.jsp"
/>
除了直接指定报表模板和接收报表定义,有时还需要直接使用程序计算好的报表(IReport)进行发布,此时需要指定srcType=“reportBean”,使用时可以参考如下写法:
<% //程序计算报表
String reportPath =request.getRealPath("/reportFiles/api/wangge.rpx");
ReportDefine rd =(ReportDefine)ReportUtils.read(reportPath);
Context cxt = newContext();
Engine engine = newEngine(rd, cxt);
IReport iReport =engine.calc();
request.setAttribute("report",iReport);
%>
srcType="reportBean"
beanName="report"
exceptionPage="/reportJsp/jsp/myError.jsp"
/>
除了上述三种方式,还可以自定义context后传递给tag去发布,利用context,可以传递参数和宏,还可以指定数据源、数据库连接工厂等。使用时可以参考如下写法:
<%
Context context = newContext();
//传递参数、数据源等,此处省略
request.setAttribute(“myContext”, context );
%>
contextName=”myContext”
/>
1.功能条
配置funcBarLocation="top"和needPageMark="yes"可以在报表上方显示功能条及翻页按钮等。
2.导出打印按钮
配置needSaveAsWord="yes" needSaveAsExcel="yes" needSaveAsPdf="yes"needPrint="yes" 可以显示导出Word、Excel、Pdf及打印按钮。
3.固定表头
配置needScroll="yes" scrollWidth="100%"scrollHeight="100%"可以将报表表头固定。