Jasper Reports 5 to 6 Obsolete methods

Asked

Viewed 314 times

4

I created some relays through the TIBCO Jaspersoft® Studio - Visual Designer for JasperReports and I am using the lib below in my project.

<dependency>
    <groupId>net.sf.jasperreports</groupId>
    <artifactId>jasperreports</artifactId>
    <version>6.0.0</version>
</dependency>

In previous versions was using JRXlsExporter but some methods are obsolete and did not find the new form in the official documentation (either I did not know how to look or it was not really updated).

Example:

   JRXlsExporter exporter  = new JRXlsExporter(); 
   response.setHeader("Content-Disposition", "attachment;    filename=PONTOS_DE_VENDA.xls");
   response.setContentType("Content-type: application/vnd.ms-excel"); //DEPRECATED
   exporter.setParameter(JExcelApiExporterParameter.JASPER_PRINT, jasperPrint); //DEPRECATED
   exporter.setParameter(JExcelApiExporterParameter.OUTPUT_STREAM,  response.getOutputStream()); //DEPRECATED

Has anyone used this new version? Or where can I find an example of using.

  • friend, depreciated? would not be obsolete?

  • @Pablovargas although you are probably right about the fact that the translation of "deprecated" is not in the best possible way, the term "depreciated" ended up being adopted by the Brazilian culture (I can not say of Portugal). As you can see for example at this link: http://www.devmedia.com.br/tags-e-attribute-depressed-na-html/28042, where the terms "obsolete" and "deprecated" are used interchangeably. Therefore, I would say that there is no consensus as to the correct term. I have seen even the word "retired" being used for such.

2 answers

5


  • That’s exactly what I was looking for I’ll post here the code of how it turned out. Vlw for help.

1

In the end I came to this code, with the answer from Anthony Accioly just above:

        JRXlsExporter exporter  = new JRXlsExporter(); 
        SimpleXlsReportConfiguration configuration = new SimpleXlsReportConfiguration();
        configuration.setOnePagePerSheet(false);
        ......
        exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
        exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(response.getOutputStream()));
        exporter.setConfiguration(configuration);
        exporter.exportReport();

In this case I had to change the exporter.setParameter for SimpleXlsReportConfiguration that I can assemble the same configuration that I used in Xporter. Visually became even more elegant.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.