'Does Displaytag's ExcelView even work? Getting Non-Excel output of plain strings
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?
Solution 1:[1]
I was able to get the full binary Excel export with:
displaytag 1.2 and displaytag-export-poi 1.2
e.g. in build.gradle:
implementation 'displaytag:displaytag:1.2'
implementation 'displaytag:displaytag-export-poi:1.2'
and adding the following to displaytag.properties:
export.excel.class=org.displaytag.export.excel.ExcelHssfView
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Tom Baldwin |
