参考http://blog.163.com/lover_j_j/blog/static/1682474472006752454547/ 感谢原作者
public void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
{
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet();
HSSFRow row1 = sheet.createRow((short) 0);
HSSFCell a1 = row1.createCell((short) 0);
a1.setCellValue("中文");
res.setHeader("Content-Disposition", "attachment;filename=" + new String("测试文件.xls".getBytes("gbk"), "iso-8859-1"));
res.setContentType("application/octet-stream");
OutputStream out = res.getOutputStream();
wb.write(out);
out.close();
}
浙公网安备 33010602011771号