List<ExcelExportEntity> entityList = new ArrayList<ExcelExportEntity>(); entityList.add(new ExcelExportEntity("姓名","studentName",20)); entityList.add(new ExcelExportEntity("班級", "className",20)); Integer index = 1; for(int i=0;i<shareNames.length;i++) { ExcelExportEntity excelExportEntity = new ExcelExportEntity(); excelExportEntity.setName(shareNames[i]); excelExportEntity.setKey(shareNames[i]); List<ExcelExportEntity> subEntityList = new ArrayList<ExcelExportEntity>(); for(int j=0;j<5;j++){ ExcelExportEntity subExcelExortEntity = new ExcelExportEntity(); subExcelExortEntity.setKey(nameMap.get(j)); subExcelExortEntity.setName(nameMap.get(j)); subExcelExortEntity.setWidth(20); if (j == 3) { subExcelExortEntity.setColumnHidden(!org.springframework.util.StringUtils.isEmpty(request.getDataString("shareMonthEnd"))); } subEntityList.add(subExcelExortEntity); } excelExportEntity.setList(subEntityList); entityList.add(excelExportEntity); }