#### 7.4 注解變種Map類型的導出View
作為動態注解存在的 List ,也提供的單獨的View方便大家使用,**AutopoiMapExcelView** 使用方法都是一樣,直接看下例子吧
~~~
@RequestMapping()
public String download(ModelMap modelMap) {
List<ExcelExportEntity> entity = new ArrayList<ExcelExportEntity>();
ExcelExportEntity excelentity = new ExcelExportEntity("姓名", "name");
excelentity.setNeedMerge(true);
entity.add(excelentity);
entity.add(new ExcelExportEntity("性別", "sex"));
excelentity = new ExcelExportEntity(null, "students");
List<ExcelExportEntity> temp = new ArrayList<ExcelExportEntity>();
temp.add(new ExcelExportEntity("姓名", "name"));
temp.add(new ExcelExportEntity("性別", "sex"));
excelentity.setList(temp);
entity.add(excelentity);
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
Map<String, Object> map;
for (int i = 0; i < 10; i++) {
map = new HashMap<String, Object>();
map.put("name", "1" + i);
map.put("sex", "2" + i);
List<Map<String, Object>> tempList = new ArrayList<Map<String, Object>>();
tempList.add(map);
tempList.add(map);
map.put("students", tempList);
list.add(map);
}
ExportParams params = new ExportParams("2412312", "測試", ExcelType.XSSF);
params.setFreezeCol(2);
modelMap.put(MapExcelConstants.MAP_LIST, list); //數據集合
modelMap.put(MapExcelConstants.ENTITY_LIST, entity); //注解集合
modelMap.put(MapExcelConstants.PARAMS, params);//參數
modelMap.put(MapExcelConstants.FILE_NAME, "EasypoiMapExcelViewTest");//文件名稱
return MapExcelConstants.EASYPOI_MAP_EXCEL_VIEW;//View名稱
}
~~~
具體案例參考[AutopoiMapExcelViewTest](https://gitee.com/lemur/easypoi-test/blob/master/src/main/java/cn/afterturn/easypoi/view/EasypoiMapExcelViewTest.java)
- 1.前傳
- 1.1前言
- 1.2 Autopoi 介紹
- 1.3 使用
- 1.4 測試項目
- 1.5 快速文檔
- 1.6 示例
- 1.6.1 單表數據導出多表頭示例
- 單表數據多表頭導入注意bak
- 1.6.2 單表數據導出多sheet示例
- 1.6.3 excel根據模板導出
- 1.6.4 一對多導出needMerge示例
- 1.6.5 大數據導出示例
- 1.7 導出自定義選擇列導出
- 2. Excel 注解版
- 2.0 @excel注解的使用
- 2.1 Excel導入導出
- 2.2 注解
- 2.3 注解導出,導入
- 2.3.1 對象定義
- 2.3.2 集合定義
- 2.3.3 圖片的導出
- 2.3.4 Excel導入介紹
- 2.3.5 Excel導入小功能
- 2.3.6 圖片的導入
- 2.3.7 Excel多Sheet導出
- 2.4 注解變種-更自由的導出
- 2.5 Map導入,自由發揮
- 2.6 Excel的樣式自定義
- 2.7 如何自定義數據處理
- 2.8 Excel導入校驗(暫不支持)
- 2.9 Excel 大批量讀取
- 2.10 Excel大數據導出
- 2.11 groupname和ExcelEntity的name屬性
- 3. Excel 模板版
- 3.1 模板 指令介紹
- 3.2 基本導出
- 3.3 模板當中使用注解
- 3.4 圖片導出
- 3.5 橫向遍歷
- 4. Excel<->Html
- 4.1 Excel 的Html預覽
- 4.2 html轉Excel更神奇的導出
- 5. Word
- 5.1 word模板導出
- 6. PDF
- 7. Spring MVC
- 7.1 View 介紹
- 7.2 大數據導出View的用法
- 7.3 注解導出View用法
- 7.4 注解變種Map類型的導出View
- 7.5Excel模板導出View
- 7.6 PoiBaseView.render view的補救
- 8.問題歸檔
- 9.大數據量處理
- 10.autopoi升級4.0版本修改記錄