try {
excelWriter = EasyExcel.write(response.getOutputStream()).build();
WriteSheet sheet = EasyExcel.writerSheet(0, fileName)
.head(GjWiredNetwork.class)
.registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
.build();
// 分页去数据库查询数据 这里可以去数据库查询每一页的数据
excelWriter.write(getwiredNetwork(params),sheet);
} finally {
if (excelWriter != null) {
excelWriter.finish();
}
}
获取表头:
WriteSheet sheet = EasyExcel.writerSheet(0, fileName)
.head(GjWiredNetwork.class)
.registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
.build();
获取数据的是getwiredNetwork方法:
excelWriter.write(getwiredNetwork(params),sheet)