Browse Source

增加了word的简单导出,已经word的图片导出

4.1.3.A
jueyue 10 years ago
parent
commit
ced3d210cd
5 changed files with 62 additions and 1 deletions
  1. +61
    -0
      easypoi-test/src/main/java/org/jeecgframework/poi/word/WordExportUtilTest.java
  2. BIN
      easypoi-test/src/main/java/org/jeecgframework/poi/word/doc/Image.docx
  3. BIN
      easypoi-test/src/main/java/org/jeecgframework/poi/word/doc/Simple.docx
  4. BIN
      easypoi-test/src/main/java/org/jeecgframework/poi/word/img/testCode.png
  5. +1
    -1
      easypoi-test/target/classes/META-INF/maven/org.jeecgframework/easypoi-test/pom.properties

+ 61
- 0
easypoi-test/src/main/java/org/jeecgframework/poi/word/WordExportUtilTest.java View File

@@ -0,0 +1,61 @@
package org.jeecgframework.poi.word;
import java.io.FileOutputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.jeecgframework.poi.word.entity.WordImageEntity;
import org.junit.Test;
public class WordExportUtilTest {
private static SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd");
/**
* 简单导出没有图片和Excel
*/
@Test
public void SimpleWordExport() {
Map<String, Object> map = new HashMap<String, Object>();
map.put("department", "Jeecg");
map.put("person", "JueYue");
map.put("time", format.format(new Date()));
try {
XWPFDocument doc = WordExportUtil.exportWord07(
"org/jeecgframework/poi/word/doc/Simple.docx", map);
FileOutputStream fos = new FileOutputStream("d:/simple.docx");
doc.write(fos);
fos.close();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 简单导出包含图片
*/
@Test
public void imageWordExport() {
Map<String, Object> map = new HashMap<String, Object>();
map.put("department", "Jeecg");
map.put("person", "JueYue");
map.put("time", format.format(new Date()));
WordImageEntity image = new WordImageEntity();
image.setHeight(200);
image.setWidth(500);
image.setUrl("org/jeecgframework/poi/word/img/testCode.png");
image.setType(WordImageEntity.URL);
map.put("testCode", image);
try {
XWPFDocument doc = WordExportUtil.exportWord07(
"org/jeecgframework/poi/word/doc/Image.docx", map);
FileOutputStream fos = new FileOutputStream("d:/image.docx");
doc.write(fos);
fos.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}

BIN
easypoi-test/src/main/java/org/jeecgframework/poi/word/doc/Image.docx View File


BIN
easypoi-test/src/main/java/org/jeecgframework/poi/word/doc/Simple.docx View File


BIN
easypoi-test/src/main/java/org/jeecgframework/poi/word/img/testCode.png View File

Before After
Width: 705  |  Height: 315  |  Size: 19 KiB

+ 1
- 1
easypoi-test/target/classes/META-INF/maven/org.jeecgframework/easypoi-test/pom.properties View File

@@ -1,5 +1,5 @@
#Generated by Maven Integration for Eclipse #Generated by Maven Integration for Eclipse
#Thu Jul 24 22:34:48 CST 2014
#Sat Jul 26 00:49:28 CST 2014
version=2.0.1 version=2.0.1
groupId=org.jeecgframework groupId=org.jeecgframework
m2e.projectName=easypoi-test m2e.projectName=easypoi-test


Loading…
Cancel
Save