Displaytag Export Excel not exporting all rows

ぐ巨炮叔叔 提交于 2021-01-27 15:01:32

问题


I want to export the table data into Excel using Displaytag.

Initially it's exporting all the data to Excel, however by default displaytag is using CSV format to export into Excel.

This solution fixed that problem Displaytag is exporting CSV into a .xls file

However, now new generated excel sheet is having only the selected page data rather than entire table/list. It's exporting 2nd page data is I am in 2nd page and so on.

But I want to export all pages data.

my complete displaytag.properties

export.types=csv excel xml rtf pdf  
export.excel=true
export.xml=true 
export.csv=true
export.rtf=false
export.pdf=false
export.excel.class=org.displaytag.export.excel.DefaultHssfExportView
export.pdf.class=org.displaytag.export.DefaultPdfExportView
export.rtf.class=org.displaytag.export.DefaultRtfExportView

in Jsp for the table

<displaytag:setProperty name="export.csv.filename" value="test.csv" />
<displaytag:setProperty name="export.excel.filename" value="test.xls" />
<displaytag:setProperty name="export.xml.filename" value="test.xml" />

Btw, other export formats (csv,xml) are generating complete data except for excel.


回答1:


The export amount controlled by below property configuration

export.amount=page  //only current page will be exported
export.amount=list //whole list will be exported

And Also try

export.excel.class=org.displaytag.export.excel.ExcelHssfView 

ExcelHssfView

instead of

export.excel.class=org.displaytag.export.excel.DefaultHssfExportView

or don't add this property (export.excel.class) in the .property file




回答2:


This seems to be bug and known issue in Displaytag http://jira.codehaus.org/browse/DISPL-361

I found a workaround, might be useful for others!

if(this.request.getParameter(TableTagParameters.PARAMETER_EXPORTING) != null)){
  return complete List;
}else {
  return based on user inputs
}


来源:https://stackoverflow.com/questions/15061416/displaytag-export-excel-not-exporting-all-rows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!