现在的位置: 首页 > 综合 > 正文

Jxls导出excel的若干方式总结(十一)– 同一个sheet中显示来自不同数据表的对象记录

2017年12月03日 ⁄ 综合 ⁄ 共 597字 ⁄ 字号 评论关闭

模板

代码:
List supplyAreaList = saBiz.getSupplyAreaById(supplyAreaId);
List stationList = staBiz.getRecordById("490");
String templateDir = "D:/excel/template/SupplyAreaMultipleEntityInSheet.xls";
String targetDir="D:/excel/export/testSupplyAreaMultipleEntityInSheet.xls";
InputStream is = new FileInputStream(templateDir);
OutputStream os = new FileOutputStream(targetDir);
Map beans = new HashMap();
beans.put("suplyArea", supplyAreaList);
beans.put("station", stationList);
XLSTransformer transFormer = new XLSTransformer();
HSSFWorkbook workBook = transFormer.transformXLS(is, beans);
workBook.write(os);
is.close();
os.flush();
os.close();

导出结果

抱歉!评论已关闭.