Jump to content
We've recently updated our Privacy Statement, available here ×

How can I config one page per sheet with struts2 and jasperreport


villanueva.ricardo

Recommended Posts

 

I'm using the struts2 jasperreports plugin and it works well. The problem is that I want to pass exportParameters and I'm not sure how to do that through the plugin. I did it:

@Result(   name = "XLS", value = "//Informe.jasper",    type = JasperReportsResult.class,    params = {      "dataSource", "listaResultados",       "format", "XLS",            "contentDisposition", "attachment;filename="Informe.xls"",       "exportParameters", "exportParametersJR"    })@SuppressWarnings("unchecked")    public Map getExportParametersJR(){        JRXlsExporter jrXlsExporter = new JRXlsExporter();        JrXlsExporter.setParameter(               JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET,Boolean.TRUE);        return jrXlsExporter.getParameters();           }

I tried, and I got the datasource correctly, but when I add this line

"exportParameters", "exportParametersJR"

it show me this exception:

java.lang.NullPointerException at org.apache.struts2.views.jasperreports.JasperReportsResult.doExecute(JasperReportsResult.java:229) at org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:178) at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:348) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:253) at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:50) at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:504) at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:419) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684) at java.lang.Thread.run(Unknown Source)

could anyone help me?

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

 

I saw that my project is using a old version that not support this feature.
 
The project uses struts2-jasperreports-plugin-2.0.11.1.jar, so the solution was to use iReport 3 for define the property, in this way:
 
 1. add the net.sf.jasperreports.export.xls.* import (edit / Report Import Directives / new Import)
 2. add the net.sf.jasperreports.export.xls.one.page.per.sheet property and set ir to true in the report Custom Properties (edit / Custom Properties / new)
 3. save
 4. compile
 5. replace the .jasper file to the project
 
in this way I got that the project worked like I wanted.
 
references:
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...