Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I don't think there's a specific "Roo" way of doing this, but Spring MVC does have an AbstractExcelView class that uses Apache POI and doesn't cause any problems - I think it's the best you can hope for. </p> <p>First create a view class that extends AbstractExcelView and implements the buildExcelDocument method:</p> <pre><code> import org.springframework.web.servlet.view.document.AbstractExcelView; public class XlsView extends AbstractExcelView { @Override protected void buildExcelDocument( Map&lt;String, Object&gt; model, HSSFWorkbook workbook, HttpServletRequest request, HttpServletResponse response) throws Exception { //Apache POI code to set up the HSSFWorkbook goes here response.setHeader("Content-Disposition", "attachment; filename=\"file.xls\""); } } </code></pre> <p>Then add the following to your webmvc-config.xml. I don't think the position matters, but I have it below the section where my TilesConfigurer is listed:</p> <pre><code> &lt;bean id="excelViewResolver" class="org.springframework.web.servlet.view.XmlViewResolver"&gt; &lt;property name="order" value="1"/&gt; &lt;property name="location" value="/WEB-INF/views/views-excel.xml"/&gt; &lt;/bean&gt; </code></pre> <p>Finally create views-excel.xml with the following in it:</p> <pre><code> &lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"&gt; &lt;bean name="XlsView" class="com.your.package.XlsView"/&gt; &lt;/beans&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload