Extension not added on excel generation (APACHE POI) -


i generating excel sheet using apache poi in spring mvc3 project. file generated without .xls extension. if rename same file .xls manually data generated fine. here snippet of code::

@requestmapping(value = "/download/")     public void downloadmerchantministatement(final httpservletresponse response,             @requestparam(value = "fromdate", required = true) string fromdate,             @requestparam(value = "todate", required = true) string todate,             @requestparam(value = "status", required = false) string status             ) throws ioexception {          string filename = statement_report_" + getdatestring(new date()) + ".xls";         list<transactiondto> transactiondtos = excelservice.gettransactionsforexcel(status, dateutil.convertstringtodate(fromdate), dateutil.convertstringtodate(todate));          bytearrayoutputstream excel = getexcelstatement(transactiondtos, fromdate, todate, status);         excel.writeto(response.getoutputstream());         response.setcontenttype("application/excel");         response.setheader("expires:", "0");         response.setheader("content-disposition", "attachment; filename=" + filename);         response.getoutputstream().flush();         response.getoutputstream().close();     } 

finally got solution, code response.setcontenttype("application/excel"); needed replaced response.setcontenttype("application/vnd.ms-excel");

that gives standard format output.


Comments

Popular posts from this blog

php - cannot display multiple markers in google maps v3 from traceroute result -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -