According to the Displaytag 1.2 documentation, ExportView
is provided to output Excel files.
But actually, the source code shows that the entire Excel Model structure is just a plain data bean of strings. The result of using ExcelView
to output an XLS is the following plain-text output (not a valid XLS),
"Agreement Category" "Approving Official" "Second Level Approving Official"
"Regular" "John Smith" "Test"
Indeed, the ExcelView
Model package is just a String-based set of classes, like a POJO bean,
org.displaytag.model.Column
org.displaytag.model.HeaderCell
...
I understand that Displaytag also has a completely different renderer, org.displaytag.export.excel.DefaultHssfExportView
, which uses HSSF to write XLS files. That renderer does produce a valid Excel file. (It's in the JAR displaytag-export-poi-1.2.jar.)
So what's the purpose of ExcelView
, then? Is it a final renderer, or just an interface renderer of some kind? Does it assume more implementation? Why call it ExcelView
if it doesn't actually output Excel, just a String list? Are we supposed to use DefaultHssfExportView
for all Excel exports?
DisplayTag is a bad and poorly supported library, but here's what I've been able to find:
What it misleadingly calls org.displaytag.export.ExcelView
is just a quote-enclosed String Renderer (they call it "ascii format, tab separated" )
At least one user thought it was CSV, but it's not, because there are no commas (CSV requires commas -- here it's just spaces and quotes: "test" "test2" etc.).
To actually output a real Excel file you need:
a)
export.excel.class=org.displaytag.export.excel.DefaultHssfExportView
in displaytag.properties
b)
with: displaytag-export-poi-1.2.jar (this contains the DefaultHssfExportView
),
c) with: poi-3.2-FINAL.jar This is very important. You can't use a higher POI version with DefaultHssfExportView
.
This outputs a good Excel file, but there's one remaining problem: the current Page only (not the full List). Various ideas have been proposed to get the full List, such as using a different renderer called org.displaytag.export.excel.ExcelHssfView
. This other renderer is also available in display-export-poi-1.2.jar but I get a ClassDefNotFound on it for some reason, and it can't be used. Only the DefaultHssfExportView
renderer is found, instantiated, and works.
So for now I get a valid Excel file back, but with a Page-only set rather than the full set. There is no solution for the full set in the rendered XLS.