Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3396544
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:25:15+00:00 2026-05-18T04:25:15+00:00

I am trying to output an Excel file as the view in Spring Roo

  • 0

I am trying to output an Excel file as the view in Spring Roo 1.0.2
What is the quickest way to do this?
(Do I have to add new mapping etc?) At the moment I am using the default Roo AjaxUrlBasedViewResolver.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T04:25:15+00:00Added an answer on May 18, 2026 at 4:25 am

    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.

    First create a view class that extends AbstractExcelView and implements the buildExcelDocument method:

     import org.springframework.web.servlet.view.document.AbstractExcelView;
    
     public class XlsView  extends AbstractExcelView { 
    
       @Override
       protected void buildExcelDocument(
                Map<String, Object> 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\"");
        }
     }
    

    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:

       <bean id="excelViewResolver" class="org.springframework.web.servlet.view.XmlViewResolver">
                <property name="order" value="1"/>
                <property name="location" value="/WEB-INF/views/views-excel.xml"/>
            </bean>
    

    Finally create views-excel.xml with the following in it:

      <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">
         <bean name="XlsView" class="com.your.package.XlsView"/>
      </beans>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XML input file and I'm trying to output the result of
I was trying to output Excel's data to a text file to use them
I'm trying to output an XLS file in the XML format. This is what
I'm trying to skin HTML output which I don't have control over. One of
I'm trying to redirect the java compiler output to a file. I thought it's
I'm trying to create a batch file that will convert an Excel file to
I'm trying to use Excel VBA to write to a text file. I'm doing
I' trying to get the following string to output to a cell in Excel
I have an array of a large structure that I am trying to output
I have a Drupal view which should output a video player using flash. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.