JsperReport在JavaFx中不显示任何数据。

huangapple 未分类评论42阅读模式
英文:

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:

JsperReport在JavaFx中不显示任何数据。

and code rendering this design here:

    btnShowReport.setOnMouseClicked(e -&gt;
    {
        try
        {
            JasperDesign jasperDesign = JRXmlLoader.load(&quot;C:\\Users\\smartware\\Documents\\NetBeansProjects&quot; +
                                                         &quot;\\POSFX\\src\\View\\Reports\\BillDesign.jrxml&quot;);
            JRDesignQuery query = new JRDesignQuery();
            HashMap &lt;String, Object&gt; hashMap = new HashMap &lt;&gt; ();
            
            hashMap.put(&quot;BillType&quot;, stageTitle);
            hashMap.put(&quot;ProductValue&quot;, 50);
            
            query.setText(&quot;select ProductName, ProductUnit, Quantity, Price from &quot; +
                          &quot;BillDetails&quot;);
            
            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:

JsperReport在JavaFx中不显示任何数据。

and the lib I used here:

JsperReport在JavaFx中不显示任何数据。
JsperReport在JavaFx中不显示任何数据。

help please, thanks in advance(I spent a lot of time to solve this and search but I failed)

huangapple
  • 本文由 发表于 2020年4月5日 20:48:04
  • 转载请务必保留本文链接:https://java.coder-hub.com/61042836.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定