拜托,我正在使用Netbeans开发java项目。我正在使用ireport创建一个报告,该报告使用JDBC连接从MYSQL数据库获取结果。我几乎完成了报告但是我想在应用程序中的表单中添加一个Jbutton并配置动作事件,以便onClick,它将提示输入所需的参数,接受它们然后将其导出到系统上的指定位置在pdf。我一直在使用ireport插件进行netbeans。 在将应用程序转换为可执行文件之后,它会正常工作还是我必须包含一些jar文件? 我会很感激的答案。谢谢。
答案 0 :(得分:0)
您需要将jasper和groovy库包含在您的项目中。
的Maven:
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>1.7.5</version>
</dependency>
您可以使用Jasper Library加载报告,填写报告并将其打印到您的出口(pdf ...)。
示例:
public class JasperReportsIntro
{
public static void main(String[] args)
{
JasperReport jasperReport;
JasperPrint jasperPrint;
try
{
jasperReport = JasperCompileManager.compileReport("reports/jasperreports_demo.jrxml");
jasperPrint = JasperFillManager.fillReport(
jasperReport, new HashMap(), new JREmptyDataSource());
JasperExportManager.exportReportToPdfFile(
jasperPrint, "reports/simple_report.pdf");
}
catch (JRException e)
{
e.printStackTrace();
}
}
}
开始将jasper集成到您的项目中的好网站是:Getting Started With JasperReports