导出excel

来源:互联网 发布:软件开发个人简历 编辑:程序博客网 时间:2024/05/16 05:59

控制层操作;

//导出excel@RequestMapping("/toExcel")public void downLoadExcel(HttpServletRequest request, HttpServletResponse response){String fileName = "生长适宜性指数";List<Map<String, Object>> listmap = new ArrayList<Map<String, Object>>();Map<String, Object> map = new HashMap<String, Object>();map.put("sheetName", "sheet1");listmap.add(map);Exponent exponent = null;for (int j = 0; j <list.size(); j++) {exponent = list.get(j);Map<String, Object> mapValue = new HashMap<String, Object>();mapValue.put("年份",exponent.getDT());mapValue.put("地区",exponent.getAREA());mapValue.put("作物名称",exponent.getFName());mapValue.put("站名",exponent.getSName());mapValue.put("站号",exponent.getSNO());mapValue.put("发育期",exponent.getPhase());mapValue.put("24小时生长适宜性",exponent.getI24());mapValue.put("48小时生长适宜性",exponent.getI48());mapValue.put("72小时生长适宜性",exponent.getI72());mapValue.put("96小时生长适宜性",exponent.getI96());listmap.add(mapValue);}String columnNames[] = {"年份","地区","作物名称","站名","站号","发育期","24小时生长适宜性","48小时生长适宜性","72小时生长适宜性","96小时生长适宜性"};// 列名String keys[] = {"年份","地区","作物名称","站名","站号","发育期","24小时生长适宜性","48小时生长适宜性","72小时生长适宜性","96小时生长适宜性"};// map中的keytry {ExportExcel.download(request, response, listmap, fileName, columnNames, keys);} catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();}}

js代码:

//导出Exccel    function pmgressbar(){//进度条    var win = $.messager.progress({    title : '请稍等',    msg : '正在导出中...',    });        setTimeout(function(){    $.messager.progress("close");    },600)    }    function onClick_download(){    //alert(11)    $.messager.confirm("确认","确认将搜索到的数据导出为Excel表格?",function(r){    if(r){    url="/SX_LGQX/exponent/toExcel.do";    location.href=url;    pmgressbar();    }    });    }


0 0