// 根据project导入信息,批量授权 @RequestMapping(value = "/model", method = RequestMethod.GET) // @ResponseBody public void importmodel( HttpServletResponse response, HttpServletRequest request) throws Exception { response.setContentType("application/msexcel;"); File f = null; String path = request.getSession().getServletContext().getRealPath("/"); response.setHeader("Content-Disposition", new String(("attachment;filename=" + "xxxxxxxxx.xls").getBytes("GB2312"), "UTF-8")); f = new File(path + "xxxxxx.xls"); FileInputStream in = new FileInputStream(f); byte b[] = new byte[1024]; int i = 0; ServletOutputStream out = response.getOutputStream(); while ((i = in.read(b)) != -1) { out.write(b, 0, i); } out.flush(); out.close(); in.close(); }
通过下载模板来导出excel
最新推荐文章于 2024-03-04 14:18:13 发布