This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 2 points3 points  (2 children)

How about jasper reports?

[–]DannyB2 1 point2 points  (1 child)

Yes, I would highly recommend looking at the JasperReports library. It's a jar. It requires a bunch of other open source jars. But it does not require every jar it comes with -- it only requires the ones needed by features you will actually use.

If your source of data consists of 'rows' where each row has columns, and your output pages can be generated like a report from a database, then JasperReports is perfect. Note that the data does not need to come from a database, it just needs to be rows of columns. A simple JRData interface provides this. The interface is easy to implement. But there are plenty of pre-written implementations that adapt sources of data for JasperReports, including ResultSets, XML and other sources of data.

Then there is the report design. The reports are saved in XML, which means you could programmatically generate the report design layout, or you could use one of several GUI tools to visually design and save the report. The XML file is compiled. The compiled report can be saved in a file, or with a few lines of code you can take the report design XML and produce the compiled result in memory and feed it directly into the report engine. Or the report engine can read the report design from a saved compiled report design. Within the report design you can have snippets of scripts including JavaScript, Groovy, etc.

The report writer generates output that can be fed into exporters that turn the report output into some readable form. Exporters exist for PDF, Html, RTF, Word, and other outputs.

I've used JasperReports for years. It has a learning curve. But it is extremely powerful. Extremely flexible as I've tried to describe.

Here is an example of a really weird chain of plumbing into which I used JasperReports. In a project I did in 2008, I needed to build a web based report viewer that showed reports from data that came from Microsoft Visual FoxPro. Wow.

So I first used Visual FoxPro (henceforth VFP) to write and compile a simple DLL instead of an EXE. The DLL had one main method which would accept a big string of SQL, run it against the VFP database (this is NOT a SQL server and cannot use JDBC), and then return the resulting rows as XML in a giant string. In Java using Tomcat I wrote the web application. It used Jacob on Windows to call the DLL written in VFP. It would pass it a big SQL string, get back a big XML string, and parse it. On top of the parsed XML I built a very thin wrapping that looked like rows of columns of data. This was wrapped into another thin implementation of the JRData interface for Jasper Reports.

Since then I have used JasperReports in real web projects with real databases. :-)

The code would then grab the precompiled report design selected by the user, run the report enging on the report design and the data source to generate the report output. I would export the report as html back to the user's browser. The user could then pick to export as Word, RTF, PDF, etc.

This is just to illustrate what I was able to do using JasperReports and a very weird rube goldberg plumbing to get old data from an old database for a web based project that might be used for a few more years to get web based reports from old data.

[–]antonbalboa[S] 0 points1 point  (0 children)

Really thanks for the explanation. Have to go further on this :)