英文:
JsperReport don't show any data in JavaFx
问题
以下是翻译好的部分:
我使用JasperReport创建发票设计,并手动添加字段(使用相同的数据库字段名称)和参数,但是当我点击按钮显示发票(“使用JasperReport制作”),空的JasperView出现,不显示任何数据,即使我添加了无数据部分消息,并且我的数据库中有要显示的数据,这是我的报表设计:
(报表设计图片)
以及渲染此设计的代码:
btnShowReport.setOnMouseClicked(e -> {
try {
JasperDesign jasperDesign = JRXmlLoader.load("C:\\Users\\smartware\\Documents\\NetBeansProjects" +
"\\POSFX\\src\\View\\Reports\\BillDesign.jrxml");
JRDesignQuery query = new JRDesignQuery();
HashMap<String, Object> hashMap = new HashMap<>();
hashMap.put("BillType", stageTitle);
hashMap.put("ProductValue", 50);
query.setText("select ProductName, ProductUnit, Quantity, Price from " +
"BillDetails");
jasperDesign.setQuery(query);
JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, hashMap,
DatabaseConnection.connection);
JasperViewer.viewReport(jasperPrint);
} catch (JRException ex) {
System.out.println(ex);
}
});
运行结果:
(运行结果图片)
我使用的库:
(库图片)
帮助请看,提前感谢(我花了很多时间来解决这个问题并进行搜索,但我失败了)。
英文:
I create invoice design with JasperReport and I add fields manually (with same database fields name) and parameters, but when I click button to show the invoice ("which made using JasperReport") empty JasperView appear and don't show any data, even if I add No Data section massage and there data in my database to show, here my report design:
and code rendering this design here:
btnShowReport.setOnMouseClicked(e ->
{
try
{
JasperDesign jasperDesign = JRXmlLoader.load("C:\\Users\\smartware\\Documents\\NetBeansProjects" +
"\\POSFX\\src\\View\\Reports\\BillDesign.jrxml");
JRDesignQuery query = new JRDesignQuery();
HashMap <String, Object> hashMap = new HashMap <> ();
hashMap.put("BillType", stageTitle);
hashMap.put("ProductValue", 50);
query.setText("select ProductName, ProductUnit, Quantity, Price from " +
"BillDetails");
jasperDesign.setQuery(query);
JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, hashMap,
DatabaseConnection.
connection);
JasperViewer.viewReport(jasperPrint);
}
catch(JRException ex)
{
System.out.println(ex);
}
});
the running result here:
and the lib I used here:
help please, thanks in advance(I spent a lot of time to solve this and search but I failed)
专注分享java语言的经验与见解,让所有开发者获益!
评论