当前位置:编程学习 > JAVA >>

javaSE Jasperreport报表

Map parameters = new HashMap();
 parameters.put("ReportTitle", "客户信息");//报表标题
List list = Dao.getKhInfos();
JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(list);
File reportFile = new File(KeHuChaXun.class.getResource("../jasper/Demo1.jrxml").getPath());
JasperReport jasperReport = (JasperReport)JRLoader.loadObject(reportFile.getPath());
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, ds);
JasperPrintManager.printReport(jasperPrint, false);


报错信息:
net.sf.jasperreports.engine.JRException: Error loading object from file : D:\JXCManager\bin\jasper\Demo1.jrxml
at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:127)
at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:99)
at net.sf.jasperreports.engine.util.JRLoader.loadObjectFromFile(JRLoader.java:90)
at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:81)
at internalFrame.KeHuChaXun$1.actionPerformed(KeHuChaXun.java:110)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.io.StreamCorruptedException: invalid stream header: 3C3F786D
at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
at java.io.ObjectInputStream.<init>(Unknown Source)
at net.sf.jasperreports.engine.util.ContextClassLoaderObjectInputStream.<init>(ContextClassLoaderObjectInputStream.java:58)
at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:122)
... 40 more
Java SE 报表 --------------------编程问答-------------------- 您好,请问这个问题解决了吗? 能不能分享一下解决办法,我这边也出现这个问题了,搞了几天还没搞定; qq:316679149 --------------------编程问答-------------------- 文件引入错误  应该引入.jasper文件,, --------------------编程问答-------------------- 除 --------------------编程问答-------------------- 除
补充:Java ,  Java SE
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,