码迷,mamicode.com
首页 > 其他好文 > 详细

JXLS使用

时间:2019-07-04 09:18:56      阅读:103      评论:0      收藏:0      [点我收藏+]

标签:poi   org   control   type   NPU   使用   head   map   jxls   

public void searchexport(String idcards, HttpServletRequest request, HttpServletResponse response,String id) {
  OutputStream out = null;
  Map map = new HashMap();
  XLSTransformer transformer = new XLSTransformer();
  InputStream is = UserInfoController.class.getClassLoader().getResourceAsStream("template" + File.separator + "excel" +File.separator + "export" + File.separator + "search.xls");
  String downloadFileName = "";
  String fileName = "成绩表";
  List list = null;
  try {
    map = testPaperService.searchexport(idcards,id);
  } catch(QueryException e1) {
    e1.printStackTrace();
  }
  map.put("title", fileName);
  map.put("date", list);
try {
  downloadFileName = new String(fileName.getBytes("gbk"), "ISO-8859-1");
  response.reset();
  response.setContentType("application/octet-stream; charset=utf-8");
  response.setHeader("Content-Disposition", "attachment;filename=\"" + downloadFileName + ".xls\"");

  out = response.getOutputStream()

  org.apache.poi.ss.usermodel.Workbook workbook = transformer.transformXLS(is, map);
  workbook.write(out);
  } catch(Exception e) {
  e.printStackTrace();
  }
}

 

JXLS使用

标签:poi   org   control   type   NPU   使用   head   map   jxls   

原文地址:https://www.cnblogs.com/douhuan/p/11130270.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!