跳到主要内容

大数据导出View的用法

AutopoiBigExcelExportView 是针对大数据量导出特定的View,在跳转到这个View的时候不需要查询数据,而且这个View自己去查询数据,用户只要实现IExcelExportServer接口就可以了 对应的常量类BigExcelConstants

public interface IExcelExportServer {
/**
* 查询数据接口
* @param obj 查询条件
* @param page 当前页数
* @return
*/
public List<Object> selectListForExcelExport(Object obj, int page);

}

AutopoiBigExcelExportView 判断是否还有下一页的条件是,如果selectListForExcelExport 返回null就认为是最后一页了,如果返回有数据这page+1继续查询 在我们自己的controller中

 @RequestMapping("load")
public void downloadByPoiBaseView(ModelMap map, HttpServletRequest request,
HttpServletResponse response) {
ExportParams params = new ExportParams("2412312", "测试", ExcelType.XSSF);
params.setFreezeCol(2);
map.put(BigExcelConstants.CLASS, MsgClient.class);
map.put(BigExcelConstants.PARAMS, params);
//就是我们的查询参数,会带到接口中,供接口查询使用
map.put(BigExcelConstants.DATA_PARAMS, new HashMap<String,String>());
map.put(BigExcelConstants.DATA_INTER,excelExportServer);
PoiBaseView.render(map, request, response, BigExcelConstants.EASYPOI_BIG_EXCEL_VIEW);

}

我们需要把参数条件封装成map或者其他类型,上面的obj可以把参数自己转回来 参数名字 BigExcelConstants.DATA_PARAM

然后把实现查询的接口注入进来就可以了 map.put(BigExcelConstants.DATA_INTER,excelExportServer);

后面就和其他View一样了