Hello,
First of all I am new to spring, if I have searched for solution at web but can not figure out the solution.
I have a controller which reads requests, generates excel file and writes it via HttpServletRequest's outputStream.
Firefox and Chrome tries to save the xls file. But internet explorer 9 tries to view the content of the file. Some ideas would be great.
+This is a screen shot if I am not clear:PHP Code:@RequestMapping("/excel/*.xls")
public ModelAndView handleRequest(HttpServletRequest argRequest, HttpServletResponse argResponse) throws Exception
{
this.initFonts();
Map<String, String> requestParams = ReportUtilFactory.getInstance().getCsvReader().readParameterMapFromRequest(argRequest);
this.reportData = ReportUtilFactory.getInstance().getReportDataReader().getReportdata(requestParams);
OutputStream outputStream = argResponse.getOutputStream();
WorkbookSettings wbSettings = new WorkbookSettings();
wbSettings.setLocale(new Locale("tr", "TR"));
WritableWorkbook workbook = Workbook.createWorkbook(outputStream, wbSettings);
workbook.createSheet("Report", 0);
WritableSheet excelSheet = workbook.getSheet(0);
this.addCommonInfo(excelSheet, this.reportData);
this.setColumnWidths(excelSheet, this.reportData);
this.addHeaders(excelSheet, this.reportData);
this.addRows(excelSheet, this.reportData);
workbook.write();
workbook.close();
argResponse.setContentType("application/x-msexcel");
argResponse.setHeader("Content-Disposition", "attachment; filename=sheet.xls");
return null;
}
http://i53.tinypic.com/2akgzo8.png
Thanks.
--
Mehmet ÇADIRCI


Reply With Quote
