使用 Jaspersoft IReport Designer 5.5.0 开发的报表
显示在html正常显示图片。
但是导出Excel和Pdf时就报错!
导出pdf时报:
[2013-12-26.16:13:58]ERROR - [common.util.report.WabappJasperPrint:line 112]导出报表异常 net.sf.jasperreports.engine.JRException: Byte data not found at : ../dishpic/722f464f-3883-42aa-901f-21706da9c582.png at net.sf.jasperreports.repo.RepositoryUtil.getBytesFromLocation(RepositoryUtil.java:324) at net.sf.jasperreports.engine.JRImageRenderer.getImageData(JRImageRenderer.java:493) at net.sf.jasperreports.engine.RenderableUtil.getOnErrorRendererForImageData(RenderableUtil.java:287) at net.sf.jasperreports.engine.export.JRPdfExporter.exportImage(JRPdfExporter.java:1239) at net.sf.jasperreports.engine.export.JRPdfExporter.exportElements(JRPdfExporter.java:854) at net.sf.jasperreports.engine.export.JRPdfExporter.exportFrame(JRPdfExporter.java:2664) at net.sf.jasperreports.engine.export.JRPdfExporter.exportElements(JRPdfExporter.java:862) at net.sf.jasperreports.engine.export.JRPdfExporter.exportFrame(JRPdfExporter.java:2664) at net.sf.jasperreports.engine.export.JRPdfExporter.exportElements(JRPdfExporter.java:862) at net.sf.jasperreports.engine.export.JRPdfExporter.exportPage(JRPdfExporter.java:818) at net.sf.jasperreports.engine.export.JRPdfExporter.exportReportToStream(JRPdfExporter.java:695) at net.sf.jasperreports.engine.export.JRPdfExporter.exportReport(JRPdfExporter.java:396) at common.util.report.ReportPdfExporter.export(ReportPdfExporter.java:21) at common.util.report.WabappJasperPrint._exportFile(WabappJasperPrint.java:126) at common.util.report.WabappJasperPrint.exportFile(WabappJasperPrint.java:109) at common.util.report.WabappJasperPrint.renderOutputModel(WabappJasperPrint.java:104) at com.hestia.mosa.report.service.ReportJasperServiceImpl.mosaMenuInfo(ReportJasperServiceImpl.java:2328) at com.hestia.mosa.report.service.ReportJasperServiceImpl.navigation(ReportJasperServiceImpl.java:155) at com.hestia.mosa.report.controller.ReportJasperController.report(ReportJasperController.java:25) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.springframework.web.servlet.mvc.multiaction.MultiActionController.invokeNamedMethod(MultiActionController.java:471) at org.springframework.web.servlet.mvc.multiaction.MultiActionController.handleRequestInternal(MultiActionController.java:408) at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153) at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:771) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:647) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:552) at javax.servlet.http.HttpServlet.service(HttpServlet.java:621) at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at common.filter.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:149) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) at org.apache.catalina.core.StandardContextValve.__invoke(StandardContextValve.java:123) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:722)导出Excel时报:
[2013-12-26.16:24:25]ERROR - [common.util.report.WabappJasperPrint:line 112]导出报表异常 net.sf.jasperreports.engine.JRException: The cell cannot be added at net.sf.jasperreports.engine.export.JRXlsExporter.exportImage(JRXlsExporter.java:1564) at net.sf.jasperreports.engine.export.JRXlsAbstractExporter.exportPage(JRXlsAbstractExporter.java:1191) at net.sf.jasperreports.engine.export.JRXlsAbstractExporter.exportReportToStream(JRXlsAbstractExporter.java:983) at net.sf.jasperreports.engine.export.JRXlsAbstractExporter.exportReport(JRXlsAbstractExporter.java:629) at common.util.report.ReportXlsExporter.export(ReportXlsExporter.java:31) at common.util.report.WabappJasperPrint._exportFile(WabappJasperPrint.java:126) at common.util.report.WabappJasperPrint.exportFile(WabappJasperPrint.java:109) at common.util.report.WabappJasperPrint.renderOutputModel(WabappJasperPrint.java:104) at com.hestia.mosa.report.service.ReportJasperServiceImpl.mosaMenuInfo(ReportJasperServiceImpl.java:2328) at com.hestia.mosa.report.service.ReportJasperServiceImpl.navigation(ReportJasperServiceImpl.java:155) at com.hestia.mosa.report.controller.ReportJasperController.report(ReportJasperController.java:25) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.springframework.web.servlet.mvc.multiaction.MultiActionController.invokeNamedMethod(MultiActionController.java:471) at org.springframework.web.servlet.mvc.multiaction.MultiActionController.handleRequestInternal(MultiActionController.java:408) at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153) at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:771) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:647) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:552) at javax.servlet.http.HttpServlet.service(HttpServlet.java:621) at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at common.filter.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:149) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) at org.apache.catalina.core.StandardContextValve.__invoke(StandardContextValve.java:123) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:722) Caused by: net.sf.jasperreports.engine.JRException: Byte data not found at : ../dishpic/722f464f-3883-42aa-901f-21706da9c582.png at net.sf.jasperreports.repo.RepositoryUtil.getBytesFromLocation(RepositoryUtil.java:324) at net.sf.jasperreports.engine.JRImageRenderer.getImageData(JRImageRenderer.java:493) at net.sf.jasperreports.engine.RenderableUtil.getOnErrorRendererForImageData(RenderableUtil.java:287) at net.sf.jasperreports.engine.export.JRXlsExporter.exportImage(JRXlsExporter.java:1336) ... 48 more
这种导出时会报:
[2013-12-27.10:38:45]ERROR - [common.util.report.WabappJasperPrint:line 112]导出报表异常 net.sf.jasperreports.engine.JRException: The cell cannot be added at net.sf.jasperreports.engine.export.JRXlsExporter.exportImage(JRXlsExporter.java:1564) at net.sf.jasperreports.engine.export.JRXlsAbstractExporter.exportPage(JRXlsAbstractExporter.java:1191) at net.sf.jasperreports.engine.export.JRXlsAbstractExporter.exportReportToStream(JRXlsAbstractExporter.java:983) at net.sf.jasperreports.engine.export.JRXlsAbstractExporter.exportReport(JRXlsAbstractExporter.java:629) at common.util.report.ReportXlsExporter.export(ReportXlsExporter.java:31) at common.util.report.WabappJasperPrint._exportFile(WabappJasperPrint.java:126) at common.util.report.WabappJasperPrint.exportFile(WabappJasperPrint.java:109) at common.util.report.WabappJasperPrint.renderOutputModel(WabappJasperPrint.java:104) at com.hestia.mosa.report.service.ReportJasperServiceImpl.mosaMenuInfo(ReportJasperServiceImpl.java:2171) at com.hestia.mosa.report.service.ReportJasperServiceImpl.navigation(ReportJasperServiceImpl.java:155) at com.hestia.mosa.report.controller.ReportJasperController.report(ReportJasperController.java:25) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.springframework.web.servlet.mvc.multiaction.MultiActionController.invokeNamedMethod(MultiActionController.java:471) at org.springframework.web.servlet.mvc.multiaction.MultiActionController.handleRequestInternal(MultiActionController.java:408) at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153) at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:771) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:647) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:552) at javax.servlet.http.HttpServlet.service(HttpServlet.java:621) at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at common.filter.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:149) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:722) Caused by: net.sf.jasperreports.engine.JRException: Image read failed. at net.sf.jasperreports.engine.util.JRJdk14ImageReader.readImage(JRJdk14ImageReader.java:73) at net.sf.jasperreports.engine.util.JRImageLoader.loadAwtImageFromBytes(JRImageLoader.java:167) at net.sf.jasperreports.engine.JRImageRenderer.getImage(JRImageRenderer.java:407) at net.sf.jasperreports.engine.JRImageRenderer.getDimension(JRImageRenderer.java:482) at net.sf.jasperreports.engine.RenderableUtil.getOnErrorRendererForDimension(RenderableUtil.java:264) at net.sf.jasperreports.engine.export.JRXlsExporter.exportImage(JRXlsExporter.java:1339) ... 47 more
上面导出PDF和EXCEL的问题是图片路径出错!!!
数据库中存存的图片路径是"../dishpic/722f464f-3883-42aa-901f-21706da9c582.png",浏览器上能够显示,但在导出PDF和EXCEL时路径就不对了。
IReport设计出来使用图片控件;使用的是相对路径。
我在判断程序如果是导出excel或是pdf时我就从新做了个模板,将上面的属性“Is Lazy”属性给取消掉,使用的路径就是绝对路径,这样就能够正常导出Excel了。
但是我又遇到问题啦!!!!
导出下面格式的内容就不报错。
但是导出下面的格式内容就有问题!!
我现在想即便这里有空白,我也能导出内容,只是有空白的导不出内容就是了,希望有懂的给予指导。感谢了
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。