Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the best practices for rendering excel sheet reports in Java?

I have a need to generate an excel sheet report which looks like the following template -- Excel Report

I know this can be done using libraries like JExcelApi and Apache POI. However I would like to know if there are means of accomplishing this by writing a template similar to writing Apache Velocity templates for sending emails.

If there is a standard, good-practice approach for generating such reports what is it?

like image 860
ping Avatar asked Aug 03 '12 10:08

ping


People also ask

What are the best practices for developing Excel spreadsheets?

The first of our absolute Excel best practices is to choose an organization standard before developing your spreadsheet. Stick with it for as long as you’re using the spreadsheet. An organization standard sets the stage for all future users who end up working with the spreadsheet.

What are the best tools for developing reports in Java?

All the three tools include a WYSIWIG editor with report previewing capabilities. BIRT Report Designer and Jaspersoft Studio are tools built on Eclipse RCP. This is a good point for most of us Java developers, as we might be familiar with the Eclipse environment.

How to create Excel sheet via Java code?

You can create excel sheet via java code using apache poi library classes like HSSFSheet, HSSFRow.

What is the best way to render reports to HTML?

The best solution is to use Javascript clients to render reports directly into an HTML element. For BIRT, the Javascript client is Actuate JSAPI and for Jasper Reports, we should use JRIO.js


1 Answers

Why not create a styled template using Excel? Use placeholders (like ${name.of.field}) for the values that should be substituted, but otherwise style everything as required. Use a different placeholder to mark the end-of-template (this will allow you to write comments or other data beyond this space, to document your template).

Then, either via JExcelApi or Apache POI,

  • open the template file, and locate the end-of-template marker.
  • open the target file
  • for each record, copy fields from the template, substituting ${xyz}-values for their actual contents and stopping once you reach your end-of-template marker.
  • close target & template

Template modification will be extremely easy. The only problem is keeping the field-names in sync.

like image 109
tucuxi Avatar answered Sep 28 '22 09:09

tucuxi