`
vcdemon
  • 浏览: 19551 次
社区版块
存档分类
最新评论
  • djx410249: 简单的自己想了几个数字测试了下,发现这个数会在经过几次跳动之后 ...
    3n+1
  • I白I: 怎么回事,好多字都卡在外面了 不显示。。。还要查看源代码看内容 ...
    3n+1
收藏列表
标题 标签 来源
Java Web利用POI导出Excel简单例子 poi, excel, java Java Web利用POI导出Excel简单例子
@Controller
public class StudentExportController{

    @Autowired
    private StudentExportService studentExportService;

    @RequestMapping(value = "/excel/export")
    public void exportExcel(HttpServletRequest request, HttpServletResponse response) 
    throws Exception {
        
        List<Student> list = new ArrayList<Student>();
        list.add(new Student(1000,"zhangsan","20"));
        list.add(new Student(1001,"lisi","23"));
        list.add(new Student(1002,"wangwu","25"));
        HSSFWorkbook wb = studentExportService.export(list);
        response.setContentType("application/vnd.ms-excel");
        response.setHeader("Content-disposition", "attachment;filename=student.xls");
        OutputStream ouputStream = response.getOutputStream();
        wb.write(ouputStream);
        ouputStream.flush();
        ouputStream.close();
   }
}
Global site tag (gtag.js) - Google Analytics