#### 5.1 word模板導出
word模板和Excel模板用法基本一致,支持的標簽也是一致的,僅僅支持07版本的word也是只能生成后綴是docx的文檔,poi對doc支持不好,所以這里也就懶得支持了,支持表格和圖片,具體demo如下
~~~
/**
* 簡單導出包含圖片
*/
@Test
public void imageWordExport() {
Map<String, Object> map = new HashMap<String, Object>();
map.put("department", "Easypoi");
map.put("person", "JueYue");
map.put("time", format.format(new Date()));
WordImageEntity image = new WordImageEntity();
image.setHeight(200);
image.setWidth(500);
image.setUrl("cn/afterturn/easypoi/test/word/img/testCode.png");
image.setType(WordImageEntity.URL);
map.put("testCode", image);
try {
XWPFDocument doc = WordExportUtil.exportWord07(
"cn/afterturn/easypoi/test/word/doc/Image.docx", map);
FileOutputStream fos = new FileOutputStream("D:/excel/image.docx");
doc.write(fos);
fos.close();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 簡單導出沒有圖片和Excel
*/
@Test
public void SimpleWordExport() {
Map<String, Object> map = new HashMap<String, Object>();
map.put("department", "Easypoi");
map.put("person", "JueYue");
map.put("time", format.format(new Date()));
map.put("me","JueYue");
map.put("date", "2015-01-03");
try {
XWPFDocument doc = WordExportUtil.exportWord07(
"cn/afterturn/easypoi/test/word/doc/Simple.docx", map);
FileOutputStream fos = new FileOutputStream("D:/excel/simple.docx");
doc.write(fos);
fos.close();
} catch (Exception e) {
e.printStackTrace();
}
}
~~~
- 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版本修改記錄