javahtmlexcelstruts2displaytag

Hide display:column from display:table struts and export in Excel


I am working on a Struts application and creating a table with display tag library by using display:table and display:column tags.

I have added html in some columns so when I export the table html code also exported in Excel sheet. So I got a work around for this. I want to create hidden columns without using html code in them and export these columns instead of columns which contain html data.

But I stuck at hiding columns and exporting hidden column and prevent some columns to exported in Excel sheet.


Solution

  • You can hide columns by using css classes and then Export all columns, and add media="html" for columns which you want not to export. Give me some time I will revert you with exact code.

    Bellow is the exact code what you should do for complete your task :-

    1. Add headerClass="export-wthtml" class="export-wthtml" in your display:column tag for hide that column from view but keep in export.
    2. css : .export-wthtml{display: none;}
    3. add media="html"for columns which you want to show in view but not want to Export.
    4. And Use export="true" in display:table tag to add export functionality to table.
    5. and you can use <display:setProperty name="export.excel.filename" value="xxx.xls"/> under display:table to give a name to Exported Excel sheet.

    Hope your all queries are solved now!

    Thanks.