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


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:

   name = "XLS", value = "/<package>/Informe.jasper"</package>, 
   type = JasperReportsResult.class, 
   params = {
      "dataSource", "listaResultados", 
      "format", "XLS",      
      "contentDisposition", "attachment;filename=\"Informe.xls\"", 
      "exportParameters", "exportParametersJR" 
    public Map<String, String> getExportParametersJR(){
        JRXlsExporter jrXlsExporter = new JRXlsExporter();
        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( at org.apache.struts2.dispatcher.StrutsResultSupport.execute( at com.opensymphony.xwork2.DefaultActionInvocation.executeResult( at com.opensymphony.xwork2.DefaultActionInvocation.invoke( at org.apache.struts2.impl.StrutsActionProxy.execute( at org.apache.struts2.dispatcher.Dispatcher.serviceAction( at org.apache.struts2.dispatcher.FilterDispatcher.doFilter( at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter( at org.apache.catalina.core.ApplicationFilterChain.doFilter( at org.apache.catalina.core.StandardWrapperValve.invoke( at org.apache.catalina.core.StandardContextValve.invoke( at org.apache.catalina.core.StandardHostValve.invoke( at org.apache.catalina.valves.ErrorReportValve.invoke( at org.apache.catalina.core.StandardEngineValve.invoke( at org.apache.catalina.connector.CoyoteAdapter.service( at org.apache.coyote.http11.Http11Processor.process( at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection( at at at org.apache.tomcat.util.threads.ThreadPool$ at Source)

could anyone help me?

villanueva.ricardo's picture
Joined: Nov 22 2012 - 6:43am
Last seen: 10 years 4 months ago

1 Answer:


I saw that my project is using a old version that not support this feature.
The project uses struts2-jasperreports-plugin-, 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 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.
villanueva.ricardo's picture
Joined: Nov 22 2012 - 6:43am
Last seen: 10 years 4 months ago