我在一个需要PDF和CSV输出的项目中使用Jasper报告,而大多数数据都是表格中的详细信息部分。我知道您可以在文档级别删除pageHeader和columnHeader,但是是否可以删除表中的列标题或仅打印一次?如果不是CSV输出,
User Type,Time,Username,Event,IP Address,Student Name,Student Number
Admin,6/6/11 8:09 PM,admin,Uploaded a report file.,0:0:0:0:0:0:0:1,,
....[about 20 more lines of CSV then]....
User Type,Time,Username,Event,IP Address,Student Name,Student Number
这看起来非常不专业,而且功能不是很强。就像我说的,我知道页面级标题可以删除:
jasperPrint.getPropertiesMap().setProperty("net.sf.jasperreports.export.exclude.origin.band.1", "pageHeader");
jasperPrint.getPropertiesMap().setProperty("net.sf.jasperreports.export.exclude.origin.band.2", "pageFooter");
jasperPrint.getPropertiesMap().setProperty("net.sf.jasperreports.export.csv.exclude.origin.band.1", "columnHeader");
jasperPrint.getPropertiesMap().setProperty("net.sf.jasperreports.export.csv.exclude.origin.band.2", "pageFooter");
jasperPrint.getPropertiesMap().setProperty("net.sf.jasperreports.export.csv.exclude.origin.keep.first.band.1", "columnHeader");
但我正在寻找一种解决方案,只在桌面上删除它们,仅用于CSV输出,而不是PDF。这可能吗?
非常感谢任何帮助!
谢谢, 卡盘
答案 0 :(得分:1)
控制不同格式的报告导出的一些有用属性。
net.sf.jasperreports.export.xls.exclude.origin.band.1 =标题 net.sf.jasperreports.export.xls.exclude.origin.band.2 =摘要 net.sf.jasperreports.export.xls.exclude.origin.band.3 = pageHeader net.sf.jasperreports.export.xls.exclude.origin.band.4 = pageFooter net.sf.jasperreports.export.xls.exclude.origin.keep.first.band.1 =的columnHeader net.sf.jasperreports.export.xls.collapse.row.span = FALSE net.sf.jasperreports.export.xls.remove.empty.space.between.columns =真
net.sf.jasperreports.export.csv.exclude.origin.band.csvSummary =摘要 net.sf.jasperreports.export.csv.exclude.origin.band.1 =标题 net.sf.jasperreports.export.csv.exclude.origin.band.2 = pageFooter net.sf.jasperreports.export.csv.exclude.origin.keep.first.band.1 =的columnHeader
net.sf.jasperreports.export.xls.exclude.origin.band.1 =标题 net.sf.jasperreports.export.xls.exclude.origin.band.2 =摘要 net.sf.jasperreports.export.xls.exclude.origin.band.3 = pageHeader net.sf.jasperreports.export.xls.exclude.origin.band.4 = pageFooter net.sf.jasperreports.export.xls.exclude.origin.keep.first.band.1 =的columnHeader net.sf.jasperreports.export.xls.collapse.row.span = FALSE net.sf.jasperreports.export.xls.remove.empty.space.between.columns =真
net.sf.jasperreports.export.html.using.images.to.align =假 net.sf.jasperreports.export.html.remove.emtpy.space.between.rows =真
net.sf.jasperreports.export.ignore.page.margins =真
答案 1 :(得分:1)
当表溢出并且无法隐藏时,表组件中的列标题将重复出现。为了达到你想要的目的,你可以:
将columnHeader的内容移动到tableHeader中,以便只有表头打印一次 或者通过添加以下属性集来执行特定导出时过滤掉元素:
<property name="net.sf.jasperreports.export.pdf.exclude.origin.keep.first.band.1" value="columnHeader"/>
<property name="net.sf.jasperreports.export.pdf.exclude.origin.keep.first.report.1" value="*"/>
答案 2 :(得分:-1)
也许您应该为每个输出使用不同的报告定义。如果没有,那么您可以只识别何时打印到csv并仅设置那些属性。