简体   繁体   English

如何使用 Main 和 Subreport 两种不同的数据源创建 iReport

[英]How to create iReport with two different data source of Main and Subreport

I need to create a report combining data from SQL server and from PostgreSQL.我需要创建一个结合来自 SQL Server 和来自 PostgreSQL 的数据的报告。 I was already looking for tutorials online but got no help.我已经在网上寻找教程,但没有得到任何帮助。

I already have created before reports with multiple subreports but using only one data source.我已经创建了具有多个子报表但仅使用一个数据源的报表。 But never done multiple data source.但是从来没有做过多数据源。

You can create Map of parameters and put sql in map, then send parameters to report.您可以创建参数映射并将sql放入映射中,然后将参数发送到报告。 sql could be created from any data base可以从任何数据库创建 sql

Map parameters = new HashMap();
parameters.put("SQL_INPUT", sql);
JasperFillManager.fillReport(reportFile.getPath(), parameters, connection);

in report you create parameter with name SQL_INPUT and replace query with $P!{SQL_INPUT}在报告中,您创建名为 SQL_INPUT 的参数并用 $P!{SQL_INPUT} 替换查询

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM