bijil philip
bijil philip

Reputation: 41

Converting a xml file into jrxml file

Is there a way I can convert a xml file to jrxml file?

I am doing a project where I need to write data from the database in a MS Word file that is already designed with the required template. I have converted that document file into xml format.

I am using iReport to generate the resultant doc file. But it requires a jrxml file. It fails to read from xml file.

Upvotes: 4

Views: 8549

Answers (2)

Shalika Ashan
Shalika Ashan

Reputation: 1

Save your MS WORD file (Template) in report directory and using Apache POI, Do necessary edits to your template. Then save your file to any place you like.

Apache POI tutorials
Link 01:

To print save your edited file in temp directory and call Desktop.getDesktop().print(file) using desktop
Link 02:

Wish you good luck.

Upvotes: 0

Naveen Babu
Naveen Babu

Reputation: 1584

Bijil,

JRXML is a template that contains the format for the content that is shown on the report.

And from what i understand the xml is containing the input data.

How jasper reports work is, you create JASPER file by compiling the JRXML file (this can be done using iReport or through your java code). To this JASPER file you will attach a object from your java code that contain data for filling the JASPER.

Please see this link for details

Edited: iReport is a designer tool for creating jasper reports, I am not sure if there any tool that can convert xml to jrxml. jrxml will contain the syntax with respect to jasper report.

What we used to do, were try to create a similar report(by comparing the look and feel) as the one client has given using iReport and get the final jrxml. Compile jrxml in iReport check the look and feel with the sample word doc with the generated sample report

Then use the compiled jasper file in the application directly. The use of jasper has 2 advantages,

  1. you can use unicode characters in your report
  2. you reduce the overhead of compiling your code every time before generating report.

disadvantage

  1. you need to keep separate track of jrxml, to fix any defect on previous jasper file.

Upvotes: 2

Related Questions