如何在jasper中使用子报表?

时间:2015-11-18 20:28:40

标签: java jasper-reports

我在这里做错了什么?

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    subreport_dir = "...\\Report\\subReport.jasper";
    try {            
        compileView("...\\Report\\myReport.jrxml");            
    } catch (JRException ex) {
        JOptionPane.showMessageDialog(this, "No Row");
        System.out.println(ex.toString());
    }
}  

当我调用函数

private static void compileView(String path) throws JRException {
    Map<String, Object> param = new HashMap<String, Object>();
    param.put("month", myMonth);
    param.put("year", myYear);
    param.put("SUBREPORT_DIR", subreport_dir);
    param.putAll(param);
    JasperReport jRp = JasperCompileManager.compileReport(path);
    JasperPrint jPrint = JasperFillManager.fillReport(jRp, param, getConnection());
    JasperViewer.viewReport(jPrint, false);
    JasperViewer.setDefaultLookAndFeelDecorated(true);

}

我得到了这个例外:

  

线程中的异常&#34; AWT-EventQueue-0&#34; java.lang.NoClassDefFoundError:net / sf / jasperreports / compilers / GroovyEvaluator

我该怎么办?

1 个答案:

答案 0 :(得分:0)

<jasperReport>标记

上更改报告中的语言标记
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="subreport" language="groovy" pageWidth="555" pageHeight="842" columnWidth="555" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="6afeba62-b470-4dfb-a8fb-42e2226b906d">

<强>语言=&#34;常规&#34;

语言=&#34; java&#34;