Reputation: 21
I am using Display tag in my jsp file for the use to export the list or table contents. I am alright with exporting all the table details except my caption that i have mentioned.. pls do the needful that how to export my caption in excel or pdf format.
I have pasted my code below..
<display:table name="requestScope.reportmanagementForm.domainList" requestURI="" export="true" id="id" pagesize="4" cellpadding="25">
<display:caption media="html">
<strong>A Caption</strong>
</display:caption>
<display:caption media="excel pdf">A Caption</display:caption>
<display:setProperty name="export.pdf" value="true" />
<display:column title="Vertical Name" property="vertical.name"/>
<display:column title="Domain Name" property="name"/>
<display:column title="Domain Description" property="desc"/>
<display:column title="Remarks" property="remarks"/>
<display:column title="Super User IPN" property="domainSuperAdmin"/>
<display:column title="Start Date" property="formatedStartDate"/>
<display:column title="End Date" property="formatedEndDate"/>
<display:setProperty name="export.excel.filename" value="List.xls"/>
<display:setProperty name="export.csv.filename" value="List.csv"/>
<display:setProperty name="export.pdf.filename" value="List.pdf"/>
</display:table>
Upvotes: 1
Views: 5999
Reputation: 7042
You will be able to export you caption too but to do that you need to give some labor for that.
For any kind of customization (which you don't get normally) you will need to create you own ExportView
by implementing the ExportView
interface.
This answer will give some explanation Read this answer. Although the requirement are not the same but the procedure is same.
If You have read the link then will will know some method doExport
Inside your class you will get a table model via public void setParameters(TableModel tableModel, boolean exportFullList, boolean includeHeader,boolean decorateValues)
method.
Actully this tableModel
contains all the information that is shown in the html.
now you can get you caption and write it to using this:
sheet.createRow(rowNum++).createCell(0).setCellValue(tableModel.getCaption());
Have a look at this source code for batter explanation. it is also a ExportView
ExcelHssfView
and read documentation of display tag Display Tag Configuration export.export name.class
Upvotes: 0
Reputation: 21
From getting out of this error, u have to add the following jars:
commons-beanutils
commons-fileupload-1.0
jakarta-jstl-1.1.2
jakarta-oro
jcl104-over-slf4j-1.4.2
log4j-1.2.13
poi-3.2-FINAL
slf4j-log4j12-1.4.2
struts
displaytag-1.2
displaytag-export-poi1.2
displaytag-portlet-1.2
Also u must create a property file in ur action class package named as displaytag.properties and u have to paste the code which has been pasted below.
displaytag.properties:
displaytag.properties:
export.types=csv excel xml pdf rtf
export.excel=true
export.csv=true
export.xml=true
export.pdf=true
export.rtf=true
export.excel.class=org.displaytag.export.excel.DefaultHssfExportView
export.pdf.class=org.displaytag.export.DefaultPdfExportView
export.rtf.class=org.displaytag.export.DefaultRtfExportView
Upvotes: 1