/** 生成的excel文件扩展名 */
private static final String FileExt = "xls";
@Inject
DownloadGridExcelService downloadGridExcelService;
@Ok("raw:application/ms-excel")
@At("/downloadExcel")
public Object downloadExcel(@Param("..") Map map, HttpServletResponse response) throws Exception {
File f = null;
try {
String url = (String)map.get("sys_url");
String fileName = downloadGridExcelService.refineFileName(DataTypeUtil.toNotNullString(map.get("sys_fileName"))) + "." + FileExt;
String params = (String)map.get("sys_params");
List<DownloadGridBean> dataList = Json.fromJsonAsList(DownloadGridBean.class, (String)map.get("sys_columnData"));
f = downloadGridExcelService.createExcel(url, params, fileName, dataList);
response.setHeader("content-disposition", "attachment;filename=" + java.net.URLEncoder.encode(fileName, "UTF-8"));
response.setCharacterEncoding("utf-8");
response.getWriter().write("<SCRIPT> alert('good'); </SCRIPT>");
response.getWriter().close();
} catch (Exception e) {
log.error(e);
}
return f;
}
7 回复
添加回复
请先登陆