"What You See Is What You Get" Exports

A Caption
CITY PROJECT HOURS TASK
Sample footer
Olympia Army 86.0 sed eos no Lorem
  
 
  Olympia Total: 86.0  
 
Neapolis 351.0 sit tempor invidunt voluptua
  
 
  Neapolis Total: 351.0  
 
Carthago 448.0 et At aliquyam erat
  
 
  Carthago Total: 448.0  
 
Olympia 499.0 vero labore sanctus sed
  
 
  Olympia Total: 499.0  
 
Neapolis 522.0 et ut dolor dolores
  
 
  Neapolis Total: 522.0  
 
Carthago 691.0 takimata no sea At
  
 
  Carthago Total: 691.0  
 
Roma Arts 177.0 gubergren erat erat accusam
  
 
  Roma Total: 177.0  
 
Neapolis 707.0 voluptua tempor no dolores
  
 
  Neapolis Total: 707.0  
 
Carthago Gladiators 162.0 aliquyam gubergren labore Stet
  
 
  Carthago Total: 162.0  
 
Roma Taxes 961.0 vero tempor sea kasd
  
 
  Roma Total: 961.0  
 

 Grand Total:4604.0 

The purpose of this example is two-fold:

  1. to demonstrate exports that mimic the HTML data presentation. What you see rendered in the Excel, PDF, and RTF formats is what you see rendered as HTML
  2. to demonstrate how easy it is to implement this by applying the template method pattern to render the main table and decorate it

Why would one want to do this? When typical business users are presented with the displaytag export facility, they usually expect the exported Excel or PDF to look just like the HTML in their browser; they expect a WYSIWYG rendering. Yes, even when exporting to Excel, users tend to expect the same look, feel, and structure of the rendered HTML, instead of raw data.

(Note: the model state in this example changes with every view request, such that the data shown will change with every request, but the report's structure remains the same in all formats.)

What this table shows: You have a List who's objects are sorted and grouped by column A, column B and column C, so instead of repeating columns A, B over and over again, it does a grouping of those columns, and only shows data in those columns when it changes. Think of reports... We use the this display tag as a key part of our reporting framework.

Grouping is straight-forward, simply make sure that your list that you are providing is sorted appropriately, then indicate the grouping order via the group attribute of the column tags.