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

examples of how to use JRPptxExporter


glassner

Recommended Posts

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

This is my code to generate a PdF file, where reportStream is an object of type InputStream representing the .jasper file.

I could not find a way to use JasperPrint with JRPptxExporter ...


JasperPrint jasperPrint = JasperFillManager.fillReport(reportStream, parameterMap, resultSet);
  
  byte[] reportBytes = JasperExportManager.exportReportToPdf(jasperPrint);
   
   //Prepare response
    response.setContentType("application/pdf");
    response.setHeader("Content-disposition", "attachment; filename=Report.pdf" );
       response.setHeader("Expires", "0");
    response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
    response.setHeader("Pragma", "public");
    response.setContentLength(reportBytes.length);
 
  //Send Content to Browser
    response.getOutputStream().write(reportBytes);
    response.getOutputStream().flush();



  

Link to comment
Share on other sites

Got it.

This works for me. Hope somebody finds this useful 

 

 JRPptxExporter pptExporter = new JRPptxExporter();
   pptExporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); 
   pptExporter.setParameter(JRExporterParameter.OUTPUT_STREAM, pptReport );
   
   pptExporter.exportReport();

   byte[] reportBytes = pptReport.toByteArray();
   

    //Prepare response
     response.setContentType("application/vnd.ms-powerpoint");
     response.setHeader("Content-disposition", "attachment; filename=Report.ppt" );
     response.setHeader("Expires", "0");
     response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
     response.setHeader("Pragma", "public");
        response.setContentLength(reportBytes.length);

   //Send Content to Browser
     response.getOutputStream().write(reportBytes);
     response.getOutputStream().flush();
   

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...