Przeglądaj źródła

跳转了包引用,导出 集合name可以为空了,就不会创建2行

4.1.3.A
jueyue 10 lat temu
rodzic
commit
6747f77086
19 zmienionych plików z 84 dodań i 71 usunięć
  1. +1
    -1
      README.md
  2. +0
    -10
      easypoi-annotation/.classpath
  3. +14
    -4
      easypoi-base/pom.xml
  4. +1
    -1
      easypoi-base/src/main/java/org/jeecgframework/poi/cache/manager/POICacheManager.java
  5. +16
    -9
      easypoi-base/src/main/java/org/jeecgframework/poi/excel/export/ExcelExportServer.java
  6. +3
    -3
      easypoi-base/src/main/java/org/jeecgframework/poi/excel/export/template/ExcelExportOfTemplateUtil.java
  7. +0
    -1
      easypoi-test/.classpath
  8. +1
    -1
      easypoi-test/src/main/java/org/jeecgframework/poi/test/entity/CourseEntity.java
  9. +9
    -9
      easypoi-test/src/main/java/org/jeecgframework/poi/test/entity/StudentEntity.java
  10. BIN
      easypoi-test/src/main/java/org/jeecgframework/poi/test/excel/doc/foreach.xlsx
  11. +10
    -1
      easypoi-test/src/main/java/org/jeecgframework/poi/test/excel/template/TemplateForEachTest.java
  12. +3
    -3
      easypoi-test/src/main/java/org/jeecgframework/poi/test/excel/test/ExcelExportForMap.java
  13. +9
    -9
      easypoi-test/src/main/java/org/jeecgframework/poi/test/excel/test/ExcelExportUtilTest.java
  14. +2
    -2
      easypoi-test/src/main/java/org/jeecgframework/poi/test/read/ExcelImportUtilTest.java
  15. +2
    -2
      easypoi-test/src/main/java/org/jeecgframework/poi/test/word/WordExportUtilAnnExcelTest.java
  16. +3
    -3
      easypoi-test/src/main/java/org/jeecgframework/poi/test/word/WordExportUtilBaseExcelTest.java
  17. +2
    -2
      easypoi-test/src/main/java/org/jeecgframework/poi/test/word/WordExportUtilTest.java
  18. +0
    -5
      easypoi-web/.classpath
  19. +8
    -5
      pom.xml

+ 1
- 1
README.md Wyświetl plik

@@ -41,7 +41,7 @@ EasyPoi的几个入口工具类
2.easypoi-annotation 基础注解包,作用与实体对象上,拆分后方便maven多工程的依赖管理
3.easypoi-base 导入导出的工具包,可以完成Excel导出,导入,Word的导出,Excel的导出功能
4.easypoi-web 耦合了spring-mvc 基于AbstractView,极大的简化spring-mvc下的导出功能
5.sax 导入使用xercesImpl这个包(这个包可能造成奇怪的问题哈),word导出使用poi-scratchpad,都作为可选包了
--------------------------
maven
--------------------------


+ 0
- 10
easypoi-annotation/.classpath Wyświetl plik

@@ -6,22 +6,12 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
<attributes>
<attribute name="maven.pomderived" value="true"/>


+ 14
- 4
easypoi-base/pom.xml Wyświetl plik

@@ -20,14 +20,24 @@
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<exclusions>
<exclusion>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-scratchpad</artifactId>
</dependency>
<!-- Sax 读入的时候使用 -->
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<optional>true</optional>
</dependency>
<!-- Word 时候用到 -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-scratchpad</artifactId>
<optional>true</optional>
</dependency>
<!-- google 工具类 -->


+ 1
- 1
easypoi-base/src/main/java/org/jeecgframework/poi/cache/manager/POICacheManager.java Wyświetl plik

@@ -43,7 +43,7 @@ public final class POICacheManager {
private static LoadingCache<String, byte[]> loadingCache;
static {
loadingCache = CacheBuilder.newBuilder().expireAfterWrite(1, TimeUnit.DAYS).maximumSize(50)
loadingCache = CacheBuilder.newBuilder().expireAfterWrite(7, TimeUnit.DAYS).maximumSize(50)
.build(new CacheLoader<String, byte[]>() {
@Override
public byte[] load(String url) throws Exception {


+ 16
- 9
easypoi-base/src/main/java/org/jeecgframework/poi/excel/export/ExcelExportServer.java Wyświetl plik

@@ -23,6 +23,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Drawing;
import org.apache.poi.ss.usermodel.Row;
@@ -49,7 +50,7 @@ import org.slf4j.LoggerFactory;
* @date 2014年6月17日 下午5:30:54
*/
public class ExcelExportServer extends ExcelExportBase {
private final static Logger LOGGER = LoggerFactory.getLogger(ExcelExportServer.class);
// 最大行数,超过自动多Sheet
@@ -174,7 +175,7 @@ public class ExcelExportServer extends ExcelExportBase {
}
} catch (Exception e) {
LOGGER.error(e.getMessage(),e);
LOGGER.error(e.getMessage(), e);
LOGGER.error(e.getMessage(), e);
throw new ExcelExportException(ExcelExportEnum.EXPORT_ERROR, e.getCause());
}
@@ -272,15 +273,20 @@ public class ExcelExportServer extends ExcelExportBase {
CellStyle titleStyle = getExcelExportStyler().getTitleStyle(title.getColor());
for (int i = 0, exportFieldTitleSize = excelParams.size(); i < exportFieldTitleSize; i++) {
ExcelExportEntity entity = excelParams.get(i);
createStringCell(row, cellIndex, entity.getName(), titleStyle, entity);
if (StringUtils.isNoneBlank(entity.getName())) {
createStringCell(row, cellIndex, entity.getName(), titleStyle, entity);
}
if (entity.getList() != null) {
List<ExcelExportEntity> sTitel = entity.getList();
sheet.addMergedRegion(new CellRangeAddress(index, index, cellIndex, cellIndex
+ sTitel.size()
- 1));
if (StringUtils.isNoneBlank(entity.getName())) {
sheet.addMergedRegion(new CellRangeAddress(index, index, cellIndex, cellIndex
+ sTitel
.size()
- 1));
}
for (int j = 0, size = sTitel.size(); j < size; j++) {
createStringCell(listRow, cellIndex, sTitel.get(j).getName(), titleStyle,
entity);
createStringCell(rows == 2 ? listRow : row, cellIndex, sTitel.get(j).getName(),
titleStyle, entity);
cellIndex++;
}
} else if (rows == 2) {
@@ -301,7 +307,8 @@ public class ExcelExportServer extends ExcelExportBase {
*/
private int getRowNums(List<ExcelExportEntity> excelParams) {
for (int i = 0; i < excelParams.size(); i++) {
if (excelParams.get(i).getList() != null) {
if (excelParams.get(i).getList() != null
&& StringUtils.isNoneBlank(excelParams.get(i).getName())) {
return 2;
}
}


+ 3
- 3
easypoi-base/src/main/java/org/jeecgframework/poi/excel/export/template/ExcelExportOfTemplateUtil.java Wyświetl plik

@@ -96,9 +96,6 @@ public final class ExcelExportOfTemplateUtil extends ExcelExportBase {
if (etarget != null) {
targetId = etarget.value();
}
// 创建表格样式
setExcelExportStyler((IExcelExportStyler) teplateParams.getStyle()
.getConstructor(Workbook.class).newInstance(workbook));
// 获取实体对象的导出数据
List<ExcelExportEntity> excelParams = new ArrayList<ExcelExportEntity>();
getAllExcelField(null, targetId, fileds, excelParams, pojoClass, null);
@@ -172,6 +169,9 @@ public final class ExcelExportOfTemplateUtil extends ExcelExportBase {
try {
this.teplateParams = params;
wb = getCloneWorkBook();
// 创建表格样式
setExcelExportStyler((IExcelExportStyler) teplateParams.getStyle()
.getConstructor(Workbook.class).newInstance(wb));
// step 3. 解析模板
for (int i = 0, le = params.isScanAllsheet() ? wb.getNumberOfSheets() : params
.getSheetNum().length; i < le; i++) {


+ 0
- 1
easypoi-test/.classpath Wyświetl plik

@@ -6,7 +6,6 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src/test"/>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>


+ 1
- 1
easypoi-test/src/main/java/org/jeecgframework/poi/test/entity/CourseEntity.java Wyświetl plik

@@ -32,7 +32,7 @@ public class CourseEntity implements java.io.Serializable {
//@ExcelEntity(id = "shuxue")
private TeacherEntity shuxueteacher;
@ExcelCollection(name = "选课学生", orderNum = "4")
@ExcelCollection(name = "", orderNum = "4")
private List<StudentEntity> students;
/**


+ 9
- 9
easypoi-test/src/main/java/org/jeecgframework/poi/test/entity/StudentEntity.java Wyświetl plik

@@ -16,27 +16,27 @@ public class StudentEntity implements java.io.Serializable {
/**
* id
*/
private String id;
private String id;
/**
* 学生姓名
*/
@Excel(name = "学生姓名", height = 20, width = 30)
private String name;
private String name;
/**
* 学生性别
*/
@Excel(name = "学生性别", replace = { "男_1", "女_2" }, suffix = "生", mergeVertical = true)
private int sex;
@Excel(name = "学生性别", replace = { "男_1", "女_2" }, suffix = "生")
private int sex;
@Excel(name = "出生日期", databaseFormat = "yyyyMMddHHmmss", exportFormat = "yyyy-MM-dd")
private Date birthday;
@Excel(name = "出生日期", databaseFormat = "yyyyMMddHHmmss", exportFormat = "yyyy-MM-dd", mergeVertical = true)
private Date birthday;
@Excel(name = "进校日期", databaseFormat = "yyyyMMddHHmmss", exportFormat = "yyyy-MM-dd")
private java.sql.Time registrationDate;
private java.sql.Time registrationDate;
/**
* 课程主键
*/
private CourseEntity course;
private CourseEntity course;
public CourseEntity getCourse() {
return course;


BIN
easypoi-test/src/main/java/org/jeecgframework/poi/test/excel/doc/foreach.xlsx Wyświetl plik


+ 10
- 1
easypoi-test/src/main/java/org/jeecgframework/poi/test/excel/template/TemplateForEachTest.java Wyświetl plik

@@ -45,12 +45,21 @@ public class TemplateForEachTest {
for (int i = 0; i < 4; i++) {
Map<String, Object> testMap = new HashMap<String, Object>();
testMap.put("id", i);
testMap.put("id", "xman");
testMap.put("name", "小明" + i);
testMap.put("sex", "man");
mapList.add(testMap);
}
map.put("maplist", mapList);
mapList = new ArrayList<Map<String, Object>>();
for (int i = 0; i < 6; i++) {
Map<String, Object> testMap = new HashMap<String, Object>();
testMap.put("si", "xman");
mapList.add(testMap);
}
map.put("sitest", mapList);
Workbook workbook = ExcelExportUtil.exportExcel(params, map);
File savefile = new File("d:/");
if (!savefile.exists()) {


+ 3
- 3
easypoi-test/src/main/java/org/jeecgframework/poi/test/excel/test/ExcelExportForMap.java Wyświetl plik

@@ -21,7 +21,7 @@ public class ExcelExportForMap {
/**
* Map 测试
*/
//@Test
@Test
public void test() {
try {
List<ExcelExportEntity> entity = new ArrayList<ExcelExportEntity>();
@@ -29,7 +29,7 @@ public class ExcelExportForMap {
excelentity.setNeedMerge(true);
entity.add(excelentity);
entity.add(new ExcelExportEntity("性别", "sex"));
excelentity = new ExcelExportEntity("学生", "students");
excelentity = new ExcelExportEntity(null, "students");
List<ExcelExportEntity> temp = new ArrayList<ExcelExportEntity>();
temp.add(new ExcelExportEntity("姓名", "name"));
temp.add(new ExcelExportEntity("性别", "sex"));
@@ -65,7 +65,7 @@ public class ExcelExportForMap {
/**
* 合并同类项
*/
@Test
//@Test
public void testMerge() {
try {
List<ExcelExportEntity> entity = new ArrayList<ExcelExportEntity>();


+ 9
- 9
easypoi-test/src/main/java/org/jeecgframework/poi/test/excel/test/ExcelExportUtilTest.java Wyświetl plik

@@ -45,20 +45,20 @@ public class ExcelExportUtilTest {
FileOutputStream fos = new FileOutputStream("d:/tt.xlsx");
workbook.write(fos);
fos.close();
savefile = new File("d:/1");
if (!savefile.exists()) {
savefile.setWritable(true, false);
savefile.mkdirs();
}
fos = new FileOutputStream("d:/1/tt3.xlsx");
workbook.write(fos);
fos.close();
// savefile = new File("d:/1");
// if (!savefile.exists()) {
// savefile.setWritable(true, false);
// savefile.mkdirs();
// }
// fos = new FileOutputStream("d:/1/tt3.xlsx");
// workbook.write(fos);
// fos.close();
}
@Before
public void testBefore() {
for (int i = 0; i < 2000000; i++) {
for (int i = 0; i < 20; i++) {
courseEntity = new CourseEntity();
courseEntity.setId("1131");
courseEntity.setName("海贼王必修(" + (i + 1) + ")");


+ 2
- 2
easypoi-test/src/main/java/org/jeecgframework/poi/test/read/ExcelImportUtilTest.java Wyświetl plik

@@ -17,7 +17,7 @@ import org.junit.Test;
public class ExcelImportUtilTest {
@Test
//@Test
public void test() {
try {
ImportParams params = new ImportParams();
@@ -37,7 +37,7 @@ public class ExcelImportUtilTest {
}
}
// @Test
@Test
public void test2() {
ImportParams params = new ImportParams();
params.setTitleRows(1);


+ 2
- 2
easypoi-test/src/main/java/org/jeecgframework/poi/test/word/WordExportUtilAnnExcelTest.java Wyświetl plik

@@ -55,7 +55,7 @@ public class WordExportUtilAnnExcelTest {
map.put("pList", new ExcelListEntity(list, Person.class));
try {
XWPFDocument doc = WordExportUtil.exportWord07(
"org/jeecgframework/poi/word/doc/SimpleExcel.docx", map);
"org/jeecgframework/poi/test/word/doc/SimpleExcel.docx", map);
FileOutputStream fos = new FileOutputStream("d:/simpleExcel.docx");
doc.write(fos);
fos.close();
@@ -105,7 +105,7 @@ public class WordExportUtilAnnExcelTest {
map.put("cs", new ExcelListEntity(list, CourseEntity.class));
try {
XWPFDocument doc = WordExportUtil.exportWord07(
"org/jeecgframework/poi/word/doc/Excel.docx", map);
"org/jeecgframework/poi/test/word/doc/Excel.docx", map);
FileOutputStream fos = new FileOutputStream("d:/Excel.docx");
doc.write(fos);
fos.close();


+ 3
- 3
easypoi-test/src/main/java/org/jeecgframework/poi/test/word/WordExportUtilBaseExcelTest.java Wyświetl plik

@@ -30,12 +30,12 @@ public class WordExportUtilBaseExcelTest {
WordImageEntity image = new WordImageEntity();
image.setHeight(200);
image.setWidth(500);
image.setUrl("org/jeecgframework/poi/word/img/testCode.png");
image.setUrl("org/jeecgframework/poi/test/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);
"org/jeecgframework/poi/test/word/doc/Image.docx", map);
FileOutputStream fos = new FileOutputStream("d:/image.docx");
doc.write(fos);
fos.close();
@@ -68,7 +68,7 @@ public class WordExportUtilBaseExcelTest {
map.put("pList", list);
try {
XWPFDocument doc = WordExportUtil.exportWord07(
"org/jeecgframework/poi/word/doc/SimpleExcel.docx", map);
"org/jeecgframework/poi/test/word/doc/SimpleExcel.docx", map);
FileOutputStream fos = new FileOutputStream("d:/simpleExcel.docx");
doc.write(fos);
fos.close();


+ 2
- 2
easypoi-test/src/main/java/org/jeecgframework/poi/test/word/WordExportUtilTest.java Wyświetl plik

@@ -32,7 +32,7 @@ public class WordExportUtilTest {
map.put("testCode", image);
try {
XWPFDocument doc = WordExportUtil.exportWord07(
"org/jeecgframework/poi/word/doc/Image.docx", map);
"org/jeecgframework/poi/test/word/doc/Image.docx", map);
FileOutputStream fos = new FileOutputStream("d:/image.docx");
doc.write(fos);
fos.close();
@@ -54,7 +54,7 @@ public class WordExportUtilTest {
map.put("date", "2015-01-03");
try {
XWPFDocument doc = WordExportUtil.exportWord07(
"org/jeecgframework/poi/word/doc/Simple.docx", map);
"org/jeecgframework/poi/test/word/doc/Simple.docx", map);
FileOutputStream fos = new FileOutputStream("d:/simple.docx");
doc.write(fos);
fos.close();


+ 0
- 5
easypoi-web/.classpath Wyświetl plik

@@ -6,11 +6,6 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>


+ 8
- 5
pom.xml Wyświetl plik

@@ -46,11 +46,19 @@
<artifactId>poi-ooxml</artifactId>
<version>${poi.version}</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>${poi.version}</version>
</dependency>
<!-- sax 读取时候用到的 -->
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>${xerces.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-scratchpad</artifactId>
@@ -101,11 +109,6 @@
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>${xerces.version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>


Ładowanie…
Anuluj
Zapisz