需求背景:
动态导出表头,特定表头下数据记录一样的需要合并单元格。在导出的首列加上导出序号。
解决方案:
使用EasyPoi 的map 方式来实现。直接贴代码。
EasyPoi文档地址:风铃开源文档-旧版
public static void main(String[] args) {
try {
List<ExcelExportEntity> colList = new ArrayList<ExcelExportEntity>();
ExcelExportEntity xh = new ExcelExportEntity("序号", "xh");
xh.setFormat("isAddIndex");
colList.add(xh);
ExcelExportEntity colEntity = new ExcelExportEntity("工厂单元", "factoryArea");
//colEntity.setNeedMerge(true);
colEntity.setMergeVertical(true);
colList.add(colEntity);
colEntity = new ExcelExportEntity("物料", "material");
//colEntity.setNeedMerge(true);
colEntity.setMerge