problem with using displaytag + tiles to export excel

ⅰ亾dé卋堺 提交于 2021-02-04 19:09:14

问题


DisplayTag 1.2 Spring + MVC 2.5.6 Tiles 2.0.7

I have taken a look at some other items on this site around the same subject area but none seem to answer the question of how to export a table generated by display tag into excel. I am able to export/save xml and csv but not excel. Other jars that are needed?

Basic set up:

web.xml

  <!--  display tag -->
  <filter>
    <filter-name>ResponseOverrideFilter</filter-name>
    <filter-class>org.displaytag.filter.ResponseOverrideFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>ResponseOverrideFilter</filter-name>
    <url-pattern>*.jsp</url-pattern>
  </filter-mapping>

displaytag.properties

#export
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

export.excel.include_header=true
export.cvs.include_header=true

html

<display:table export="true" id="row" class="gridTable" name="shippingCommands" defaultsort="1" sort="list" requestURI="shipHome.html" defaultorder="ascending" pagesize="100">
  <display:column title="Customer Name" sortable="true" sortName="customerName">
    ${row.customerName }
    <c:if test="${null != row.customerContactName}">
      <br />
      <br />${row.customerContactName}
    </c:if>
  </display:column>
  <display:column property="storeNumber" title="Store #"  sortable="true" sortName="storeNumber" comparator="vsg.ecotrak.common.comparator.AlphanumComparator"/>
  <display:column property="storeAddress" title="Store Address"/>
  <display:column property="programName" title="Program" sortable="true" sortName="programName"/>
  <display:column property="boxType" title="Box Type" sortable="true" sortName="boxType"/>
  <display:column class="table-10" property="qtyToShip" title="# of Boxes" sortable="true" sortName="qtyToShip"/>
  <display:column property="orderType" title="Order Type" sortable="true" sortName="orderType"/>
  <display:column class="actions" media="html">
    <a class="action-fulfill" href="shipSummary.html?action=summary&orderId=${row.orderId}">Fulfill</a>
    <a class="action-delete" href="javascript:confirmDelete(${row.orderId})" title="Delete Order" >Delete Order</a>
  </display:column>
  <display:setProperty name="export.rtf.filename" value="boxestoship.rtf"/>
  <display:setProperty name="export.csv.filename" value="boxestoship.csv"/>
  <display:setProperty name="export.excel.filename" value="boxestoship.xls"/>
  <display:setProperty name="export.xml.filename" value="boxestoship.xml"/>
</display:table>

It turns out that excel works with poi-3.2-FINAL.jar and not poi-3.7. Not sure why but that is what I did to get it to work.


回答1:


Make sure you have poi-3.2-FINAL.jar in your WEB-INF/lib folder.

You can have more than one poi jars in your project but at least this one poi-3.2-FINAL.jar is compulsory and must to have.

If you want to export in other formats e.g. Excel - 2007 .xlsx format As shown here you need to have

poi-3.2-FINAL.jar

poi-3.9.jar

poi-ooxml-3.9.jar

poi-ooxml-schemas-3.9.jar

xmlbeans-2.6.0.jar

stax-api-1.0.1.jar

and other dependencies jars.



来源:https://stackoverflow.com/questions/4877445/problem-with-using-displaytag-tiles-to-export-excel

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