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

JasperReport Output to MS Word(.docx) - Formatting issue


maulik_nanavaty

Recommended Posts

I have a simple Jasper Report created using Jaspersoft Studio 6.3.1 and I have couple of rectangle element with backcolor in it and also couple of line elements.

Now from my Java code, I am trying to generate report in different formats using JasperPrint and trying to generate PDF and MS Word (.docx) version of this report by passing datasource from there. This code runs successfully and generates PDF and docx versions, but those rectangle and line elements with backcolor are only visible in PDF version and not in MS Word version. 

Is that a normal behavior or it is possible to get all that formatting in Word version as well? If yes, then can you please share code snippet to do that? I'm using following code to generate PDF and Word versions.

 

     JasperPrint jasperPrint = JasperFillManager.fillReport(reportName, params, vnDataSource.create(jasperReport));
       
     // exporting process
    // 1- export to PDF
    JasperExportManager.exportReportToPdfFile(jasperPrint, fileName + ".pdf");
    
    // 2- export to Word
    JRDocxExporter exporter = new JRDocxExporter();
    exporter.setExporterInput(new SimpleExporterInput(jasperPrint));      
    File exportReportFile = new File(fileName + ".docx");
    exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(exportReportFile));
    exporter.exportReport();
 
Any help is much appreciated!!
Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

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