"What You See Is What You Get" Exports

A Caption
CITY PROJECT HOURS TASK
Sample footer
Roma Army 23.0 sed clita duo diam
  
 
  Roma Total: 23.0  
 
Neapolis 450.0 kasd dolores accusam et
  
 
  Neapolis Total: 450.0  
 
Carthago Arts 227.0 ea labore ut voluptua
537.0 dolore sed sit et
  
 
  Carthago Total: 764.0  
 
Olympia 741.0 diam tempor sadipscing magna
  
 
  Olympia Total: 741.0  
 
Roma Gladiators 535.0 labore sadipscing sed diam
  
 
  Roma Total: 535.0  
 
Neapolis 804.0 sed sadipscing et ipsum
  
 
  Neapolis Total: 804.0  
 
Roma 807.0 consetetur sanctus nonumy sea
  
 
  Roma Total: 807.0  
 
Carthago Taxes 146.0 consetetur nonumy dolore sadipscing
  
 
  Carthago Total: 146.0  
 
Neapolis 879.0 amet dolore vero sadipscing
  
 
  Neapolis Total: 879.0  
 

 Grand Total:5149.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.