I’m using displaytag’s Excel export with the ExcelHssfView to export a table as Excel. However, every field in the tables backing bean is being written out to the exported table, instead of just the defined columns. My displaytag configuration is:
export.types=excel
export.csv=false
export.pdf=false
export.excel=true
export.xml=false
export.excel.class=org.displaytag.export.excel.ExcelHssfView
export.excel.decorator=org.displaytag.sample.decorators.HssfTotalWrapper
export.ExcelView=org.displaytag.export.ExcelView
And in the jsp
<display:setProperty name="export.excel" value="true" />
<display:setProperty name="export.excel.filename" value="invoiceList.xls" />
<display:setProperty name="export.amount" value="list" />
<display:setProperty name="export.excel.include_header" value="true" />
<display:setProperty name="export.excel.label" value="Download Invoices" />
</display:table>
All the
<display:column>tags had theirmediaattribute set tohtml, which prevented them from being referenced by the Excel export (expecting theallorexcelmedia), so displaytag defaulted to passing in all the bean columns.changed to
And it worked.