Skip to content

Instantly share code, notes, and snippets.

@yongchun
Created November 28, 2013 08:23
Show Gist options
  • Save yongchun/7688767 to your computer and use it in GitHub Desktop.
Save yongchun/7688767 to your computer and use it in GitHub Desktop.
JSP页面到处excel解决中文名乱码
HSSFWorkbook wb = getExcelData(ippes);
response.setContentType("application/octet-stream");
if(StringUtils.isNotEmpty(timeSession)){
startTimeStr = new Date(new Date().getTime()-24*60*60*1000);
endTimeStr = new Date();
}
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("IP端口流量-from-" + sdf.format(startTimeStr) + "-to-" + sdf.format(endTimeStr) + ".xls","UTF-8") );
wb.write(response.getOutputStream());
response.getOutputStream().flush();
response.getOutputStream().close();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment