PoiBaseView.render view的补救
假如因为不可抗拒或者其他神奇的原因,view导出无法使用,作者遇到过好几次了,各种神奇原因都有,提供一个统一的封装,算是一个补救措施吧 上面的modelMap写法和设置参数还是一样,最后直接输出就可以了 PoiBaseView.render(modelMap, request, response,View名称);
看个简单demo
@RequestMapping("load")
public void downloadByPoiBaseView(ModelMap map, HttpServletRequest request,
HttpServletResponse response) {
List<MsgClient> list = new ArrayList<MsgClient>();
for (int i = 0; i < 100; i++) {
MsgClient client = new MsgClient();
client.setBirthday(new Date());
client.setClientName("小明" + i);
client.setClientPhone("18797" + i);
client.setCreateBy("JueYue");
client.setId("1" + i);
client.setRemark("测试" + i);
MsgClientGroup group = new MsgClientGroup();
group.setGroupName("测试" + i);
client.setGroup(group);
list.add(client);
}
ExportParams params = new ExportParams("2412312", "测试", ExcelType.XSSF);
params.setFreezeCol(2);
map.put(NormalExcelConstants.DATA_LIST, list);
map.put(NormalExcelConstants.CLASS, MsgClient.class);
map.put(NormalExcelConstants.PARAMS, params);
PoiBaseView.render(map, request, response, NormalExcelConstants.EASYPOI_EXCEL_VIEW);
}