我需要一个staticText浮动到另一个具有可变高度的元素下面.我正在拿书中的样本JasperReports for Java Programmers.它说可以做到这一点.与我的示例的不同之处在于我使用了硬编码字符串textFieldExpression,它们使用$ F {}字段.
<textField isStretchWithOverflow="true" hyperlinkType="None">
<reportElement x="0" y="0" width="100" height="24"/>
<box>
<pen lineWidth="0.5" lineStyle="Solid"/>
</box>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA["jjjjjjjjjjj oooooooooo uuuuuuuuuu aaaaaaaaaa xxxxxxxxx u ttttt"]]></textFieldExpression>
</textField>
<staticText>
<reportElement positionType="Float" x="0" y="25" width="500" height="30"/>
<box>
<pen lineWidth="0.5" lineStyle="Solid"/>
</box>
<textElement/>
<text><![CDATA[ This staticText element has a positionType of "Float" ppp ]]></text>
</staticText>
Run Code Online (Sandbox Code Playgroud)
它表示当你使用时positionType="Float",y属性被忽略,因为staticText它位于textField.这似乎有效,但是......他们可能是我的BS吗?所述textField具有Y = 0和高度= 24.所述staticText具有Y = 25.巧合?如果我更改了staticText'sy',很明显它不会被忽略:元素位于我告诉它的任何地方.没有漂浮!!! 从书中引用:
As …
我是新手JasperReports,不知道如何从servlet调用jasper文件.我的报告包含饼图.
我想在 ireport 中创建多个组,并且数据应该以分组方式显示。例如:首先应该完全打印 Group1 数据,然后,
第一组:
模块数据 在此之后我想完全打印 Group2 数据
组2:
类别数据
我正在使用结果集数据源。
有人可以帮助我吗?
我有一个标题带,其中包含一个包含计算变量的文本字段.该文本字段有evaluationTime设为报告,同为变量resetType.现在,我正在尝试使用条件样式设置此字段的背景颜色,但我不断收到一条错误消息,说明: $V{avg_perc}
Invalid expression: !Double.isNaN($V{avg_perc}) && $V{avg_perc} >= 0.8
Run Code Online (Sandbox Code Playgroud)
我在做同样的事情用相同的条件样式在列脚注和它的作品没有任何问题,即使我设置evaluationTime对这一领域的报告了.
删除后!Double.isNaN($V{avg_perc})我不再出现错误,但表达式仍然无效.我的字段保持红色,这是任何条件无效时的基本颜色,无论哪个值$V{avg_perc}有.但它仍然可以在Column Footer中使用.这是我的风格:
<style name="avg_color" mode="Opaque" backcolor="#FF0000" pdfFontName="Helvetica-Bold">
<conditionalStyle>
<conditionExpression><![CDATA[$V{avg_perc} >= 0.8]]></conditionExpression>
<style backcolor="#008000"/>
</conditionalStyle>
<conditionalStyle>
<conditionExpression><![CDATA[$V{avg_perc} >= 0.6 && $V{avg_perc} < 0.8]]></conditionExpression>
<style backcolor="#FFCC00"/>
</conditionalStyle>
</style>
Run Code Online (Sandbox Code Playgroud)
使用的字段和变量:
<field name="perc" class="java.lang.Double"/>
<variable name="avg_perc" class="java.lang.Double" calculation="Average">
<variableExpression><![CDATA[$F{perc}]]></variableExpression>
</variable>
Run Code Online (Sandbox Code Playgroud)
知道如何让这个东西工作吗?我在3.7.4版本中使用JasperReports和 …
我正在使用JasperReports创建发票.
我有一个详细信息部分,其中包含所有项目的列表,后面是包含总计,税收等的列页脚,然后是" 摘要"部分中的退货政策.
我想始终确保详细信息后跟列页脚,后跟摘要条带.我们怎样才能确保这一点?我发现有时摘要出现在列页脚之前.
有人可以对此有所了解吗?
当JasperViewer出现并关闭它时,主框架/父框架也关闭.怎么预防这个?
这是我的代码..
private void cmdprintidMouseClicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
try {
JasperDesign jasperDesign = JRXmlLoader.load("report12.jrxml");
String sql = "select * from db1 where Company LIKE '" + txtcompany.getText() + "%'";
JRDesignQuery newQuery = new JRDesignQuery();
newQuery.setText(sql);
jasperDesign.setQuery(newQuery);
JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, null, conn);
JasperViewer.viewReport(jasperPrint);
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
Run Code Online (Sandbox Code Playgroud) 即时尝试将jrxml文件导出为pdf,但我收到此错误:
WARN query.JRJdbcQueryExecuter - The supplied java.sql.Connection object is null.
Run Code Online (Sandbox Code Playgroud)
我只得到一个空白的pdf文件..
这是我导出为PDF的方法:
public void printReport(ActionEvent event) throws JRException, IOException {
String reportPath = FacesContext.getCurrentInstance().getExternalContext().getRealPath("/test.jrxml");
JasperReport report = JasperCompileManager.compileReport(reportPath);
JasperPrint jasperPrint = JasperFillManager.fillReport(report, new HashMap<String, String>());
HttpServletResponse httpServletResponse = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();
httpServletResponse.addHeader("Content-disposition", "attachment; filename=report.pdf");
ServletOutputStream servletOutputStream = httpServletResponse.getOutputStream();
JasperExportManager.exportReportToPdfStream(jasperPrint, servletOutputStream);
FacesContext.getCurrentInstance().responseComplete();
}
Run Code Online (Sandbox Code Playgroud)
我是jasperreports的新手,所以我有点迷失..我必须指定连接字符串到数据库或什么?我应该在哪里添加它.
顺便说一下,我正在使用JSF 2,intellij和maven.
谢谢.
在Jaspersoft Studio中,我创建了一个报告,我希望以粗体显示标题.如果我使用sans serif字体,那么它正常工作.如果我使用其他字体,则在Jaspersoft Studio的预览中会显示粗体,但在Jasper服务器中运行报告时不显示.请帮忙.
下面的代码得到一个byte[]结果,适用于PDF和XLSX.对于HTML,引发了异常.
JasperPrint jasperPrint = JasperFillManager.fillReport(report,
params, dataSource != null ? new JRMapArrayDataSource(
dataSource) : new JREmptyDataSource());
ByteArrayOutputStream out = new ByteArrayOutputStream();
@SuppressWarnings("rawtypes")
Exporter exporter;
switch (format) {
case PDF:
exporter = new JRPdfExporter();
break;
case XLSX:
exporter = new JRXlsxExporter();
break;
case HTML:
exporter = new HtmlExporter();
break;
default:
throw new ReportException("Unknown export format");
}
exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(out));
exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
exporter.exportReport();
return out.toByteArray();
Run Code Online (Sandbox Code Playgroud)
HTML的例外情况就是 exporter.exportReport();这样
java.lang.ClassCastException:
net.sf.jasperreports.export.SimpleOutputStreamExporterOutput cannot be cast to net.sf.jasperreports.export.HtmlExporterOutput
at net.sf.jasperreports.engine.export.HtmlExporter.exportReport(HtmlExporter.java:232)
Run Code Online (Sandbox Code Playgroud)
v6.0和v5.6的错误相同.这曾经在v5.0中工作(某些类在v5.6中已弃用).
如何以各种格式导出报告,包括HTML?
我将以下内容定义为存储库 (dispenseRepository) 中的本机查询:
@Query(
value = "SELECT p.*, c.*, s.*, d.* from patient p, consult c ,script s,dispense d "
+ " where p.patient_id=c.patient_id "
+ " and c.consult_id = d.consult_id "
+ " and c.fk_script_id =s.script_id"
+ " and c.consult_id=?1 ",
nativeQuery = true
)
List<Dispense> findInvoiceByConsultId(Long consultId);
Run Code Online (Sandbox Code Playgroud)
其余控制器有:
@RequestMapping(value = "/api/invoice/{consultId}",method = {RequestMethod.GET})
public List<Dispense> invoice(@PathVariable(value="consultId")Long consultId){
return dispenseRepository.findInvoiceByConsultId(consultId);
}
Run Code Online (Sandbox Code Playgroud)
当我点击 api 时,我只得到分配详细信息:
[
{
"dispenseId": 1,
"icd10": "J.10",
"tariffCode": "10010",
"dispenseItem": "Lenses",
"price": 400.0
},
{
"dispenseId": …Run Code Online (Sandbox Code Playgroud)