• js之获取选中的checkbox


    //看红色部分代码即可
    function
    expExcel() { var ids=new Array(); $("input:checkbox:checked").each(function(){ ids.push($(this).attr("id")); }); if(ids.length==0){ alert("请至少选中一条记录"); return; } if (confirm("导出选中页面数据?")) { var url = __ctx + '/platform/ghnfgfc/qhnfgfc/exportExcel.htm?myId='+ ids; var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串 if (userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1) {//判断是否IE浏览器 window.location.href(url); } else { window.open(url, "导出报表"); } } }
    //后台获取checkbox并拼接,看红色部分代码

    @RequestMapping({ "exportExcel" }) public void exportExcel(HttpServletRequest request, HttpServletResponse response) throws Exception { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); String[] aryIds = RequestUtil.getStringAryByStr(request, "myId"); QueryFilter queryFilter = getQuerFilter(request); String myIds = ""; for (int i = 0; i < aryIds.length; i++) { String tmp = aryIds[i]; if (i != aryIds.length - 1) { myIds += "'" + tmp + "',"; } else { myIds += "'" + tmp + "'"; } } queryFilter.addParamsFilter("whereSql", "MY_ID_ in (" + myIds + ")"); queryFilter.addParamsFilter("orderBySql", "TBSJ ASC"); List<Ggdjqyfgfc> query = ggdjqyfgfcManager.query(queryFilter); String dirPath = FileUtil.getClassesPath() + File.separator + "template" + File.separator + "exportMode" + File.separator; String fileName = "ggdjfgfc.xls"; FileInputStream inStream = new FileInputStream(new File(dirPath + fileName)); HSSFWorkbook wb = new HSSFWorkbook(inStream); HSSFSheet sheet = wb.getSheetAt(0); HSSFCell cell = null; for (int i = 0; i < query.size(); i++) { Ggdjqyfgfc e = query.get(i); HSSFRow row = sheet.getRow(i + 2); row = ExcelUtil.getNotNullRow(sheet, i + 2); cell = ExcelUtil.getNotNullCell(wb, row, 0); cell.setCellValue(sdf.format(e.getTbsj())); cell = ExcelUtil.getNotNullCell(wb, row, 1); cell.setCellValue(e.getGdj() + ""); } fileName = "xxxx表_" + ".xls"; response.setContentType("application/octet-stream;charset=UTF-8"); response.setHeader("Content-Type", "application/vnd.ms-excel"); response.setHeader("Content-Disposition", "attachment;filename=" + new String(fileName.getBytes("GB2312"), "8859_1")); response.addHeader("Pargam", "no-cache"); response.addHeader("Cache-Control", "no-cache"); OutputStream out = response.getOutputStream(); wb.write(out); out.flush(); out.close(); }
  • 相关阅读:
    如何手工设置归档目录
    C#字符串格式化说明(String.Format) (zz.IS2120)
    win7 GodMode
    金山软件公司创始人求伯君简介 (is2120.zz)
    【百度地图】安卓系统的百度地图可以下载离线地图,这个很省流量和时间
    手机用笔记本wifi上网【无USB、无软件、无无线路由器】
    安卓版有道词典的离线词库《21世纪大英汉词典》等
    秀秀我的巨无霸手机P1000
    [转载]环游澳大利亚18天——前传与攻略
    [转载]环游澳大利亚18天——前传与攻略
  • 原文地址:https://www.cnblogs.com/rdchen/p/13949596.html
Copyright © 2020-2023  润新知