Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to set Jexcel name in Spring mvc?
    primarykey
    data
    text
    <p>I'm following with <a href="http://www.mkyong.com/spring-mvc/spring-mvc-export-data-to-excel-file-via-abstractjexcelview/" rel="nofollow">mkyong</a> Jexcel with Spring tutorial and everything looks fine.it can create excel file and write sheet except one thing is I can't change my excel file name? It will display file name same as my link to controller.</p> <p><strong>Here is example</strong></p> <pre><code>&lt;li&gt;&lt;h3&gt;&lt;a href="report.html"&gt;Jexcel Showcase&lt;/a&gt;&lt;/h3&gt;&lt;/li&gt; </code></pre> <p>It will always create excel file name "report.html.xls". Anyone know how to change file name??</p> <p><strong>This is my controller</strong></p> <pre><code>@RequestMapping(method=RequestMethod.POST) protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { //dummy data revenueData.put("Jan-2010", "$100,000,000"); revenueData.put("Feb-2010", "$110,000,000"); revenueData.put("Mar-2010", "$130,000,000"); revenueData.put("Apr-2010", "$140,000,000"); revenueData.put("May-2010", "$200,000,000"); return new ModelAndView("jexcelSuccess","revenueData",revenueData); } </code></pre> <p><strong>and buildExcelDocument method</strong></p> <pre><code>protected void buildExcelDocument(Map model, WritableWorkbook workbook, HttpServletRequest request, HttpServletResponse response) throws Exception { Map&lt;String,String&gt; revenueData = (Map&lt;String,String&gt;) model.get("revenueData"); WritableSheet sheet = workbook.createSheet("Revenue Report", 0); WritableSheet sheet2 = workbook.createSheet("Test Report", 1); WritableSheet sheet3 = workbook.createSheet("Hello Report", 2); sheet.addCell(new Label(0, 0, "Month")); sheet.addCell(new Label(1, 0, "Revenue")); int rowNum = 1; for (Map.Entry&lt;String, String&gt; entry : revenueData.entrySet()) { //create the row data sheet.addCell(new Label(0, rowNum, entry.getKey())); sheet.addCell(new Label(1, rowNum, entry.getValue())); rowNum++; } } </code></pre> <p>Thank in advance, Mart</p>
    singulars
    1. This table or related slice is empty.
    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. 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