我按照这个代码示例,当我使用 iReport v2.0.4
进行子报告的报告时现在我想通过 Java 运行此报告。我的代码是:
String rs="E:\\Myproject\\NetBeansProjects\\Inventory_control_system_for_hotel\\
Mainreportname.jrxml";
JasperReport jasperMasterReport = JasperCompileManager.compileReport(rs);
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("para_custId", "66778999");
JasperPrint jasperPrint=JasperFillManager.fillReport(jasperMasterReport, parameters, JDBC41.con());
JasperViewer.viewReport(jasperPrint, false);
提供以下错误
net.sf.jasperreports.engine.JRException: Could not load object from location\Invoice_ireport_subreport2.jasper
at net.sf.jasperreports.engine.util.JRLoader.loadObjectFromLocation(JRLoader.java:266)
at net.sf.jasperreports.engine.fill.JRFillSubreport.evaluateSubreport(JRFillSubreport.java:308)
at net.sf.jasperreports.engine.fill.JRFillSubreport.evaluate(JRFillSubreport.java:257)
at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:275)
at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:426)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:1380)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:692)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:255)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:113)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:891)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:795)
at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:63)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:402)
at inventory_control_system_for_hotel.newquery.main(newquery.java:77)
现在我改变了我的Ireport版本5.5有些像这样的错误
`java.lang.NullPointerException
at net.sf.jasperreports.engine.JRPropertiesMap.readObject(JRPropertiesMap.java:185)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)`
保存我的报告路径= E:\ Myproject \ NetBeansProjects \ Inventory_control_system_for_hotel \ Mainreportname.jrxml 子repoth = E:\ Myproject \ NetBeansProjects \ Inventory_control_system_for_hotel \ Subreportname.jrxml 喜欢这个
答案 0 :(得分:0)
在ireport中链接报表和子报表时,必须设置属性“subreport expresion”,该属性是相对于子报表所在的类路径的路径。
子报告expresion =“reports / Invoice_ireport_subreport2.jasper.jasper”
你的项目中有以下内容:
的src /主/资源/报告/ Invoice_ireport_subreport2.jasper.jasper