AngelsandDemons
AngelsandDemons

Reputation: 2843

Converting .jrxml file to .pdf file

I ran few load test on my web application. Problem is the results of the load test application is in .jrxml format. The result contains charts graphs and certain parameters. I know its a jasperreport format. So if I convert the .jrxml file to .pdf file will I be able to see all charts,graphs and values...

I am assuming irrespective of the .jrxml content about chart or graph the pdf generated will contain appropiate values as template is prepared according to the charting API.

Can I produce jasper report without specifying any datasource connection..I dont need a datasource connection since my .jrxml file does not contain a datasource attribute... If yes, how can I acheive it.. Kindly suggest

Upvotes: 5

Views: 16229

Answers (4)

Sharad
Sharad

Reputation: 3548

If you are not using any data source then you have to select "Empty datasource" or "Sample datasource" from data sources if you are running sample reports, but as i think if you are crating a specific report for your project then u must have to select data source.

Upvotes: 0

Hardik Mishra
Hardik Mishra

Reputation: 14887

If you don't have any data source, you can try this

jasperReport = JasperCompileManager.compileReport(sourceFileName);
jasperPrint = JasperFillManager.fillReport(jasperReport,jasperParameter,new  JREmptyDataSource()); 
JasperExportManager.exportReportToPdfFile(jasperPrint, "D://Test.pdf");

Even if you do not have any data source and its a static data report giving JREmptyDataSource is required.

Check the answer for more explanation

Blank PDF even with the simplest Jasperreport jrxml

Upvotes: 9

SuperPomodoro
SuperPomodoro

Reputation: 426

If by "datasource connection" you mean a JDBC backed datasource, yes you can execute a report without requiring this.

There are other data source implementations that implement the net.sf.jasperreports.engine.JRDataSource (for example JRCsvDataSource) that are "lighter-weight" than hitting a database - useful for testing.

However for unit tests, I end up creating a mock implementation of JRDataSource that implements next() and getFieldValue() and reads from a Collection of Map objects (this could instead read from a file, etc.). This has been the simplest and fastest approach when it comes to testing for me.

Which part are you exactly load testing? Usually the interesting parts to stress test are:

  • Jasper report filling (executing the query, reading the results and filling a JasperPrint object)

  • Jasper export (producing the report output format - HTML, PDF, XLS, etc.)

Upvotes: 0

ayengin
ayengin

Reputation: 1596

.jrxml is output of jasper designer When you compile it you obtain its parsed form .jasper .After that ,you populate this object with data ,parameter,variables and obtain .print object .And Finally, you can export this print object any format sopported by jasper report such as PDF,CVS,HTML,Excel ...

Upvotes: 0

Related Questions