有人可以告诉我如何使用printWhenExpressionJasperReports吗?
有没有办法为报表中的字段设置默认值?我在报告中有很多字符串字段,并希望它们在为空时显示"0,00".
报告习惯用语似乎是一个报告由一个项目列表组成,还有一些额外的数据(参数).有没有办法在报告中包含几个不相关的列表,或者这是否会违背成语,以至于应该使用不同的工具来生成输出?
例如,假设您有一个居住在建筑物中的人员列表,其中包含姓名,电话号码等.该列表将是主要的数据源.此外,在同一报告中,您希望显示有关该建筑物的各种其他信息,例如地址,楼层数等.此信息中的项目数可能因建筑物而异,因此您不能简单地将其放入静态参数中,而是需要地图或列表.这当然是一个受人尊敬的例子,但应该用来说明问题.
简而言之:您可以在报告中使用多个不相关的列表吗?
我最近遇到了一个问题,我的JasperReports报告的子报告中出现了以下错误:
子报告溢出在不支持溢出的波段上.
怎么了?
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="tree-template" pageWidth="595" pageHeight="842" columnWidth="481" leftMargin="57" rightMargin="57" topMargin="72" bottomMargin="72">
<style name="Title" forecolor="#000000" fontName="Times New Roman" fontSize="50" isBold="false" pdfFontName="Times-Bold"/>
<style name="SubTitle" forecolor="#666666" fontName="Times New Roman" fontSize="18" isBold="false" pdfFontName="Times-Roman"/>
<style name="Column header" forecolor="#666666" fontName="Times New Roman" fontSize="14" isBold="true" pdfFontName="Times-Roman"/>
<style name="Detail" mode="Transparent" fontName="Times New Roman" pdfFontName="Times-Roman"/>
<style name="Row" mode="Transparent" fontName="Times New Roman" pdfFontName="Times-Roman">
<conditionalStyle>
<conditionExpression><![CDATA[$V{REPORT_COUNT}%2 == 0]]></conditionExpression>
<style mode="Opaque" backcolor="#F0EFEF"/>
</conditionalStyle>
</style>
<parameter name="JasperCustomSubReportLocation" class="net.sf.jasperreports.engine.JasperReport"/>
<parameter name="JasperCustomSubReportDatasource" class="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource"/>
<field name="name" class="java.lang.String"/>
<field name="notes" class="java.lang.String"/>
<field …Run Code Online (Sandbox Code Playgroud) 在我的项目中,我正在使用Maven 3.0.4并使用JasperReports 5.1.0.要 使用jasperreports-maven-plugins编译JRXML文件.我有版本1.0-beta-2 的jasperreports-maven-plugin.因为它是测试版(1.0-beta-2)我可以知道,什么是稳定版的jasperreports-maven-plugin可以使用?
在我的pom.xml文件中使用的插件下面
<properties>
<jasperreports.version>5.1.0</jasperreports.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jasperreports-maven-plugin</artifactId>
<version>1.0-beta-2</version>
<configuration>
<sourceDirectory>src/main/resources/reports</sourceDirectory>
<outputDirectory>${project.build.directory}/classes/reports</outputDirectory>
</configuration>
<executions>
<execution>
<!-- Need to bind to the compile phase cuz the reports uses classes under target/classes. The default is the generate-resources phase. -->
<phase>compile</phase>
<goals>
<goal>compile-reports</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>${jasperreports.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.0.1</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud) 我刚刚开始使用Jasper Reports从使用Hibernate检索的数据生成报告.一切正常,除了JR似乎不尊重文本字段中的换行符(\n).有没有办法强制换行字符换行?
我有一个网络应用程序,客户端已要求查看一些报告.方法是使用iReport并在屏幕上显示报告.
我已经问了这样的事情.但今天我发现报告文件(jrxml)的路径是绝对的.所以我必须更改程序,以便它接受相对路径.我一直在尝试这样做,但似乎jrxml或编译(.jasper)文件都不接受既不编译也不填充报告的相对路径.
这是我迄今为止所得到的:
//path is generated as request.getContextPath() + "/jrxmlFiles/"
public void generateReport(HttpServletResponse res, ConexionAdmin con, String path) throws Exception{
ServletOutputStream out = null;
ByteArrayOutputStream bos = new ByteArrayOutputStream();
JasperDesign jasperDesign = JRXmlLoader.load(path);
JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
byte[] bytes = JasperRunManager.runReportToPdf(jasperReport, pars, con.initConexion());
res.setContentType("application/pdf");
res.setContentLength(bytes.length);
out = res.getOutputStream();
out.write(bytes, 0, bytes.length);
res.setHeader("Cache-Control", "cache");
res.setHeader("Content-Disposition", "attachment; filename=report.pdf");
res.setHeader("Pragma", "cache");
res.setContentLength(bos.size());
out.write(bos.toByteArray());
out.flush();
bos.close();
out.close();
res.flushBuffer();
}
Run Code Online (Sandbox Code Playgroud)
这似乎适用于绝对路径,但抛出我:
Exception Message
net.sf.jasperreports.engine.JRException: java.io.FileNotFoundException
Run Code Online (Sandbox Code Playgroud)
当改为相对路径时.我在网上搜索没有成功如何改变我的适合度.
我有jasper API的javaDoc,但如果我能帮助它,我宁愿不读它.
我有一个JasperReports jrxml文件,它在textField元素中有一个超链接.
我不想在HTML视图以外的任何地方显示此超链接,因为该链接在excel,PDF,word等中不起作用,并且显示没有意义.
我已经阅读了具有属性的常见问题,但它只是让我困惑,因为它根本没有谈论隐藏textField,只是页眉和页脚的"乐队".
这是我想要隐藏的文本字段,而不是HTML:
<textField hyperlinkType="ReportExecution">
<reportElement style="Report_Param_Value_Link" mode="Opaque" x="400" y="0" width="161" height="20"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[Boolean.TRUE.equals($P{LAST_WEEK}) ? "View WTD" : "View last week"]]></textFieldExpression>
<hyperlinkParameter name="noMenu">
<hyperlinkParameterExpression><![CDATA["true"]]></hyperlinkParameterExpression>
</hyperlinkParameter>
<hyperlinkParameter name="reportUnit">
<hyperlinkParameterExpression><![CDATA["repo:/Reports/Operations/Business_Support/Subreports/Business_Support_Performance_Dashboard"]]></hyperlinkParameterExpression>
</hyperlinkParameter>
<hyperlinkParameter name="LAST_WEEK">
<hyperlinkParameterExpression><![CDATA[Boolean.valueOf(!Boolean.TRUE.equals($P{LAST_WEEK})).toString()]]></hyperlinkParameterExpression>
</hyperlinkParameter>
</textField>
Run Code Online (Sandbox Code Playgroud) 首先,记录按表组件显示在表中,但不在报表中显示.
结果如下:
YEARS MONTHS SUMMONTH SUMQUARTER
----- ------ -------- ----------
2009 Jan 130984 432041
Feb 146503
Mar 154554
Apr 147917 435150
May 131822
Jun 155411
Jul 144000 424806
Aug 130369
Sep 150437
Oct 112137 400114
Nov 152057
Dec 135920
=====================================
Jan-Dec 1692111
=====================================
2010 Jan 139927 417564
Feb 154940
Mar 122697
Apr 163257 413305
May 124999
Jun 125049
Jul 145127 427612
Aug 138804
Sep 143681
Oct 143398 406381
Nov 125351
Dec 137632
=====================================
Jan-Dec 1664862
=====================================
Run Code Online (Sandbox Code Playgroud)
总部列显示了每个季度的总和.
重复字段值时不会打印它们.
问题是如何对sumquarter的列进行分组,以便每行中第一个打印的重复值加入下一个重复值,成为单个单元格,直到它满足非重复值?
你可以在图像中看到它.下面是表格显示的图像,我喜欢的解决方案是将这3个月的总和分组到一个单元格中. …