jxl导出excel,通常浏览器会提示excel导出完成情况及默认保存路径,或让用户自定义选择保存路径,要达到这种效果,有些要做下修改,如:response是jsp的内置对象,在jsp中使用时不用声明,但用在action中需要声明。
代码如下:
HttpServletResponse response = ServletActionContext.getResponse(); response.reset(); response.setContentType("<span class="wp_keywordlink"><a href="http://www.tieguanyin168.com/index.php/jxt-excel-2-1306.html" title="application/vnd.ms-excel" target="_blank">application/vnd.ms-excel</a></span>"); response.setHeader("Content-dposition:on","attachment;filename=log"); OutputStream os=response.getOutputStream(); jxl.write.WritableWorkbook wwb = Workbook.createWorkbook(os); ...此处省略