@@ -1,4 +1,4 @@ | |||||
activeProfiles= | |||||
activeProfiles=cc-mzone-profile | |||||
eclipse.preferences.version=1 | eclipse.preferences.version=1 | ||||
resolveWorkspaceProjects=true | resolveWorkspaceProjects=true | ||||
version=1 | version=1 |
@@ -67,6 +67,12 @@ maven | |||||
-------------------------- | -------------------------- | ||||
版本修改 | 版本修改 | ||||
-------------------------- | -------------------------- | ||||
- 2.2.0-SNAPSHOT | |||||
- !!!没有功能更新,但是groupId 改成org.jeecg,为了以后可以直接提交到中央库了 | |||||
- 把test 那个模块删除了 | |||||
- 2.1.1-release -小更新/防止下一个预览功能太久不能发布更新 | - 2.1.1-release -小更新/防止下一个预览功能太久不能发布更新 | ||||
- $fe标签 | - $fe标签 | ||||
- 几个可能影响使用的bug | - 几个可能影响使用的bug | ||||
@@ -2,9 +2,9 @@ | |||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||||
<modelVersion>4.0.0</modelVersion> | <modelVersion>4.0.0</modelVersion> | ||||
<parent> | <parent> | ||||
<groupId>org.jeecgframework</groupId> | |||||
<groupId>org.jeecg</groupId> | |||||
<artifactId>easypoi</artifactId> | <artifactId>easypoi</artifactId> | ||||
<version>2.1.2-SNAPSHOT</version> | |||||
<version>2.2.0-SNAPSHOT</version> | |||||
</parent> | </parent> | ||||
<artifactId>easypoi-annotation</artifactId> | <artifactId>easypoi-annotation</artifactId> | ||||
<description>基础注解类,解耦合</description> | <description>基础注解类,解耦合</description> |
@@ -2,9 +2,9 @@ | |||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||||
<modelVersion>4.0.0</modelVersion> | <modelVersion>4.0.0</modelVersion> | ||||
<parent> | <parent> | ||||
<groupId>org.jeecgframework</groupId> | |||||
<groupId>org.jeecg</groupId> | |||||
<artifactId>easypoi</artifactId> | <artifactId>easypoi</artifactId> | ||||
<version>2.1.2-SNAPSHOT</version> | |||||
<version>2.2.0-SNAPSHOT</version> | |||||
</parent> | </parent> | ||||
<artifactId>easypoi-base</artifactId> | <artifactId>easypoi-base</artifactId> | ||||
<dependencies> | <dependencies> | ||||
@@ -59,7 +59,7 @@ | |||||
</dependency> | </dependency> | ||||
<dependency> | <dependency> | ||||
<groupId>org.jeecgframework</groupId> | |||||
<groupId>org.jeecg</groupId> | |||||
<artifactId>easypoi-annotation</artifactId> | <artifactId>easypoi-annotation</artifactId> | ||||
</dependency> | </dependency> | ||||
</dependencies> | </dependencies> |
@@ -143,6 +143,9 @@ public class ExcelImportServer extends ImportBaseService { | |||||
case Cell.CELL_TYPE_NUMERIC: | case Cell.CELL_TYPE_NUMERIC: | ||||
obj = cell.getNumericCellValue(); | obj = cell.getNumericCellValue(); | ||||
break; | break; | ||||
case Cell.CELL_TYPE_FORMULA: | |||||
obj = cell.getCellFormula(); | |||||
break; | |||||
} | } | ||||
return obj == null ? null : obj.toString().trim(); | return obj == null ? null : obj.toString().trim(); | ||||
} | } | ||||
@@ -1,31 +0,0 @@ | |||||
<?xml version="1.0" encoding="UTF-8"?> | |||||
<classpath> | |||||
<classpathentry kind="src" output="target/classes" path="src/main/java"> | |||||
<attributes> | |||||
<attribute name="optional" value="true"/> | |||||
<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="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"/> | |||||
</attributes> | |||||
</classpathentry> | |||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> | |||||
<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 kind="output" path="target/classes"/> | |||||
</classpath> |
@@ -1 +0,0 @@ | |||||
/target |
@@ -1,23 +0,0 @@ | |||||
<?xml version="1.0" encoding="UTF-8"?> | |||||
<projectDescription> | |||||
<name>easypoi-test</name> | |||||
<comment></comment> | |||||
<projects> | |||||
</projects> | |||||
<buildSpec> | |||||
<buildCommand> | |||||
<name>org.eclipse.jdt.core.javabuilder</name> | |||||
<arguments> | |||||
</arguments> | |||||
</buildCommand> | |||||
<buildCommand> | |||||
<name>org.eclipse.m2e.core.maven2Builder</name> | |||||
<arguments> | |||||
</arguments> | |||||
</buildCommand> | |||||
</buildSpec> | |||||
<natures> | |||||
<nature>org.eclipse.jdt.core.javanature</nature> | |||||
<nature>org.eclipse.m2e.core.maven2Nature</nature> | |||||
</natures> | |||||
</projectDescription> |
@@ -1,2 +0,0 @@ | |||||
eclipse.preferences.version=1 | |||||
encoding//src/main/java=UTF-8 |
@@ -1,5 +0,0 @@ | |||||
eclipse.preferences.version=1 | |||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 | |||||
org.eclipse.jdt.core.compiler.compliance=1.6 | |||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning | |||||
org.eclipse.jdt.core.compiler.source=1.6 |
@@ -1,4 +0,0 @@ | |||||
activeProfiles= | |||||
eclipse.preferences.version=1 | |||||
resolveWorkspaceProjects=true | |||||
version=1 |
@@ -1,26 +0,0 @@ | |||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |||||
<modelVersion>4.0.0</modelVersion> | |||||
<parent> | |||||
<groupId>org.jeecgframework</groupId> | |||||
<artifactId>easypoi</artifactId> | |||||
<version>2.1.2-SNAPSHOT</version> | |||||
</parent> | |||||
<artifactId>easypoi-test</artifactId> | |||||
<dependencies> | |||||
<dependency> | |||||
<groupId>org.jeecgframework</groupId> | |||||
<artifactId>easypoi-base</artifactId> | |||||
</dependency> | |||||
<dependency> | |||||
<groupId>org.slf4j</groupId> | |||||
<artifactId>slf4j-log4j12</artifactId> | |||||
</dependency> | |||||
<dependency> | |||||
<groupId>junit</groupId> | |||||
<artifactId>junit</artifactId> | |||||
</dependency> | |||||
</dependencies> | |||||
</project> |
@@ -1,91 +0,0 @@ | |||||
package org.jeecgframework.poi.excel; | |||||
import static org.junit.Assert.*; | |||||
import java.io.File; | |||||
import java.io.FileInputStream; | |||||
import java.io.FileNotFoundException; | |||||
import java.io.FileWriter; | |||||
import java.io.IOException; | |||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook; | |||||
import org.apache.poi.ss.usermodel.Workbook; | |||||
import org.jeecgframework.poi.util.PoiPublicUtil; | |||||
import org.junit.Test; | |||||
public class ExcelToHtmlUtilTest { | |||||
//@Test | |||||
public void testToTableHtmlWorkbook() { | |||||
try { | |||||
Workbook wb = new HSSFWorkbook(new FileInputStream( | |||||
new File( | |||||
PoiPublicUtil | |||||
.getWebRootPath("org/jeecgframework/poi/test/excel/doc/专项支出用款申请书.xls")))); | |||||
String html = ExcelToHtmlUtil.toTableHtml(wb); | |||||
FileWriter fw = new FileWriter("d:/专项支出用款申请书_table.html"); | |||||
fw.write(html); | |||||
fw.close(); | |||||
} catch (FileNotFoundException e) { | |||||
e.printStackTrace(); | |||||
} catch (IOException e) { | |||||
e.printStackTrace(); | |||||
} | |||||
} | |||||
//@Test | |||||
public void testToTableHtmlWorkbookInt() { | |||||
try { | |||||
Workbook wb = new HSSFWorkbook(new FileInputStream(new File( | |||||
PoiPublicUtil | |||||
.getWebRootPath("org/jeecgframework/poi/test/excel/doc/exportTemp.xls")))); | |||||
String html = ExcelToHtmlUtil.toTableHtml(wb, 1); | |||||
FileWriter fw = new FileWriter("d:/exportTemp_table.html"); | |||||
fw.write(html); | |||||
fw.close(); | |||||
} catch (FileNotFoundException e) { | |||||
e.printStackTrace(); | |||||
} catch (IOException e) { | |||||
e.printStackTrace(); | |||||
} | |||||
} | |||||
@Test | |||||
public void testToAllHtmlWorkbook() { | |||||
try { | |||||
Workbook wb = new HSSFWorkbook(new FileInputStream( | |||||
new File("d:/tt.xls"))); | |||||
// Workbook wb = new HSSFWorkbook(new FileInputStream( | |||||
// new File( | |||||
// PoiPublicUtil | |||||
// .getWebRootPath("org/jeecgframework/poi/test/excel/doc/专项支出用款申请书.xls")))); | |||||
String html = ExcelToHtmlUtil.toTableHtml(wb); | |||||
FileWriter fw = new FileWriter("d:/专项支出用款申请书_all.html"); | |||||
fw.write(html); | |||||
fw.close(); | |||||
} catch (FileNotFoundException e) { | |||||
e.printStackTrace(); | |||||
} catch (IOException e) { | |||||
e.printStackTrace(); | |||||
} | |||||
} | |||||
//@Test | |||||
public void testToAllHtmlWorkbookInt() { | |||||
try { | |||||
Workbook wb = new HSSFWorkbook(new FileInputStream(new File( | |||||
PoiPublicUtil | |||||
.getWebRootPath("org/jeecgframework/poi/test/excel/doc/exportTemp.xls")))); | |||||
String html = ExcelToHtmlUtil.toAllHtml(wb, 1); | |||||
FileWriter fw = new FileWriter("d:/exportTemp_all.html"); | |||||
fw.write(html); | |||||
fw.close(); | |||||
} catch (FileNotFoundException e) { | |||||
e.printStackTrace(); | |||||
} catch (IOException e) { | |||||
e.printStackTrace(); | |||||
} | |||||
} | |||||
} |
@@ -1 +0,0 @@ | |||||
/read |
@@ -1,15 +0,0 @@ | |||||
package org.jeecgframework.poi.test; | |||||
public class UtilTest { | |||||
public static void main(String[] args) { | |||||
String text = " {{ p in pList}}"; | |||||
text = text.replace("{{", "").replace("}}", "").replaceAll("\\s{1,}", " ").trim(); | |||||
System.out.println(text); | |||||
System.out.println(text.length()); | |||||
} | |||||
} |
@@ -1,108 +0,0 @@ | |||||
package org.jeecgframework.poi.test.entity; | |||||
import java.util.List; | |||||
import org.jeecgframework.poi.excel.annotation.Excel; | |||||
import org.jeecgframework.poi.excel.annotation.ExcelCollection; | |||||
import org.jeecgframework.poi.excel.annotation.ExcelEntity; | |||||
import org.jeecgframework.poi.excel.annotation.ExcelTarget; | |||||
import org.jeecgframework.poi.excel.annotation.ExcelVerify; | |||||
/** | |||||
* @Title: Entity | |||||
* @Description: 课程 | |||||
* @author JueYue | |||||
* @date 2013-08-31 22:53:07 | |||||
* @version V1.0 | |||||
* | |||||
*/ | |||||
@SuppressWarnings("serial") | |||||
@ExcelTarget("courseEntity") | |||||
public class CourseEntity implements java.io.Serializable { | |||||
/** 主键 */ | |||||
private String id; | |||||
/** 课程名称 */ | |||||
@Excel(name = "课程名称", orderNum = "1", width = 15, needMerge = true) | |||||
private String name; | |||||
/** 老师主键 */ | |||||
@ExcelEntity(id = "yuwen") | |||||
@ExcelVerify() | |||||
private TeacherEntity teacher; | |||||
/** 老师主键 */ | |||||
//@ExcelEntity(id = "shuxue") | |||||
private TeacherEntity shuxueteacher; | |||||
@ExcelCollection(name = "", orderNum = "4") | |||||
private List<StudentEntity> students; | |||||
/** | |||||
* 方法: 取得java.lang.String | |||||
* | |||||
* @return: java.lang.String 主键 | |||||
*/ | |||||
public String getId() { | |||||
return this.id; | |||||
} | |||||
/** | |||||
* 方法: 取得java.lang.String | |||||
* | |||||
* @return: java.lang.String 课程名称 | |||||
*/ | |||||
public String getName() { | |||||
return this.name; | |||||
} | |||||
public TeacherEntity getShuxueteacher() { | |||||
return shuxueteacher; | |||||
} | |||||
public List<StudentEntity> getStudents() { | |||||
return students; | |||||
} | |||||
/** | |||||
* 方法: 取得java.lang.String | |||||
* | |||||
* @return: java.lang.String 老师主键 | |||||
*/ | |||||
public TeacherEntity getTeacher() { | |||||
return teacher; | |||||
} | |||||
/** | |||||
* 方法: 设置java.lang.String | |||||
* | |||||
* @param: java.lang.String 主键 | |||||
*/ | |||||
public void setId(String id) { | |||||
this.id = id; | |||||
} | |||||
/** | |||||
* 方法: 设置java.lang.String | |||||
* | |||||
* @param: java.lang.String 课程名称 | |||||
*/ | |||||
public void setName(String name) { | |||||
this.name = name; | |||||
} | |||||
public void setShuxueteacher(TeacherEntity shuxueteacher) { | |||||
this.shuxueteacher = shuxueteacher; | |||||
} | |||||
public void setStudents(List<StudentEntity> students) { | |||||
this.students = students; | |||||
} | |||||
/** | |||||
* 方法: 设置java.lang.String | |||||
* | |||||
* @param: java.lang.String 老师主键 | |||||
*/ | |||||
public void setTeacher(TeacherEntity teacher) { | |||||
this.teacher = teacher; | |||||
} | |||||
} |
@@ -1,124 +0,0 @@ | |||||
package org.jeecgframework.poi.test.entity; | |||||
import org.jeecgframework.poi.excel.annotation.Excel; | |||||
import org.jeecgframework.poi.excel.annotation.ExcelVerify; | |||||
/** | |||||
* Excel导入校验类 | |||||
* @author JueYue | |||||
* @date 2015年2月24日 下午2:21:07 | |||||
*/ | |||||
public class ExcelVerifyEntity { | |||||
/** | |||||
* Email校验 | |||||
*/ | |||||
@Excel(name = "Email", width = 25) | |||||
@ExcelVerify(isEmail = true, notNull = true) | |||||
private String email; | |||||
/** | |||||
* 手机号校验 | |||||
*/ | |||||
@Excel(name = "Mobile", width = 20) | |||||
@ExcelVerify(isMobile = true, notNull = true) | |||||
private String mobile; | |||||
/** | |||||
* 电话校验 | |||||
*/ | |||||
@Excel(name = "Tel", width = 20) | |||||
@ExcelVerify(isTel = true, notNull = true) | |||||
private String tel; | |||||
/** | |||||
* 最长校验 | |||||
*/ | |||||
@Excel(name = "MaxLength") | |||||
@ExcelVerify(maxLength = 15) | |||||
private String maxLength; | |||||
/** | |||||
* 最短校验 | |||||
*/ | |||||
@Excel(name = "MinLength") | |||||
@ExcelVerify(minLength = 3) | |||||
private String minLength; | |||||
/** | |||||
* 非空校验 | |||||
*/ | |||||
@Excel(name = "NotNull") | |||||
@ExcelVerify(notNull = true) | |||||
private String notNull; | |||||
/** | |||||
* 正则校验 | |||||
*/ | |||||
@Excel(name = "Regex") | |||||
@ExcelVerify(regex = "[\u4E00-\u9FA5]*", regexTip = "不是中文") | |||||
private String regex; | |||||
/** | |||||
* 接口校验 | |||||
*/ | |||||
private String interHandler; | |||||
public String getEmail() { | |||||
return email; | |||||
} | |||||
public void setEmail(String email) { | |||||
this.email = email; | |||||
} | |||||
public String getMobile() { | |||||
return mobile; | |||||
} | |||||
public void setMobile(String mobile) { | |||||
this.mobile = mobile; | |||||
} | |||||
public String getTel() { | |||||
return tel; | |||||
} | |||||
public void setTel(String tel) { | |||||
this.tel = tel; | |||||
} | |||||
public String getMaxLength() { | |||||
return maxLength; | |||||
} | |||||
public void setMaxLength(String maxLength) { | |||||
this.maxLength = maxLength; | |||||
} | |||||
public String getMinLength() { | |||||
return minLength; | |||||
} | |||||
public void setMinLength(String minLength) { | |||||
this.minLength = minLength; | |||||
} | |||||
public String getNotNull() { | |||||
return notNull; | |||||
} | |||||
public void setNotNull(String notNull) { | |||||
this.notNull = notNull; | |||||
} | |||||
public String getRegex() { | |||||
return regex; | |||||
} | |||||
public void setRegex(String regex) { | |||||
this.regex = regex; | |||||
} | |||||
public String getInterHandler() { | |||||
return interHandler; | |||||
} | |||||
public void setInterHandler(String interHandler) { | |||||
this.interHandler = interHandler; | |||||
} | |||||
} |
@@ -1,146 +0,0 @@ | |||||
package org.jeecgframework.poi.test.entity; | |||||
import java.util.Date; | |||||
import org.jeecgframework.poi.excel.annotation.Excel; | |||||
import org.jeecgframework.poi.excel.annotation.ExcelEntity; | |||||
/** | |||||
* @Title: Entity | |||||
* @Description: 通讯录 | |||||
* @author JueYue | |||||
* @date 2014-09-22 16:03:32 | |||||
* @version V1.0 | |||||
* | |||||
*/ | |||||
@SuppressWarnings("serial") | |||||
public class MsgClient implements java.io.Serializable { | |||||
/** id */ | |||||
private java.lang.String id; | |||||
// 电话号码(主键) | |||||
@Excel(name = "电话号码") | |||||
private String clientPhone = null; | |||||
// 客户姓名 | |||||
@Excel(name = "姓名") | |||||
private String clientName = null; | |||||
// 所属分组 | |||||
@ExcelEntity | |||||
private MsgClientGroup group = null; | |||||
// 备注 | |||||
@Excel(name = "备注") | |||||
private String remark = null; | |||||
// 生日 | |||||
@Excel(name = "出生日期") | |||||
private Date birthday = null; | |||||
// 创建人 | |||||
private String createBy = null; | |||||
/** | |||||
* 方法: 取得java.util.Date | |||||
* | |||||
* @return: java.util.Date 生日 | |||||
*/ | |||||
public java.util.Date getBirthday() { | |||||
return this.birthday; | |||||
} | |||||
/** | |||||
* 方法: 取得java.lang.String | |||||
* | |||||
* @return: java.lang.String 客户姓名 | |||||
*/ | |||||
public java.lang.String getClientName() { | |||||
return this.clientName; | |||||
} | |||||
/** | |||||
* 方法: 取得java.lang.String | |||||
* | |||||
* @return: java.lang.String 电话号码 | |||||
*/ | |||||
public java.lang.String getClientPhone() { | |||||
return this.clientPhone; | |||||
} | |||||
public String getCreateBy() { | |||||
return createBy; | |||||
} | |||||
public MsgClientGroup getGroup() { | |||||
return group; | |||||
} | |||||
/** | |||||
* 方法: 取得java.lang.String | |||||
* | |||||
* @return: java.lang.String id | |||||
*/ | |||||
public java.lang.String getId() { | |||||
return this.id; | |||||
} | |||||
/** | |||||
* 方法: 取得java.lang.String | |||||
* | |||||
* @return: java.lang.String 备注 | |||||
*/ | |||||
public java.lang.String getRemark() { | |||||
return this.remark; | |||||
} | |||||
/** | |||||
* 方法: 设置java.util.Date | |||||
* | |||||
* @param: java.util.Date 生日 | |||||
*/ | |||||
public void setBirthday(java.util.Date birthday) { | |||||
this.birthday = birthday; | |||||
} | |||||
/** | |||||
* 方法: 设置java.lang.String | |||||
* | |||||
* @param: java.lang.String 客户姓名 | |||||
*/ | |||||
public void setClientName(java.lang.String clientName) { | |||||
this.clientName = clientName; | |||||
} | |||||
/** | |||||
* 方法: 设置java.lang.String | |||||
* | |||||
* @param: java.lang.String 电话号码 | |||||
*/ | |||||
public void setClientPhone(java.lang.String clientPhone) { | |||||
this.clientPhone = clientPhone; | |||||
} | |||||
public void setCreateBy(String createBy) { | |||||
this.createBy = createBy; | |||||
} | |||||
public void setGroup(MsgClientGroup group) { | |||||
this.group = group; | |||||
} | |||||
/** | |||||
* 方法: 设置java.lang.String | |||||
* | |||||
* @param: java.lang.String id | |||||
*/ | |||||
public void setId(java.lang.String id) { | |||||
this.id = id; | |||||
} | |||||
/** | |||||
* 方法: 设置java.lang.String | |||||
* | |||||
* @param remark | |||||
* | |||||
* @param: java.lang.String 备注 | |||||
*/ | |||||
public void setRemark(java.lang.String remark) { | |||||
this.remark = remark; | |||||
} | |||||
} |
@@ -1,55 +0,0 @@ | |||||
package org.jeecgframework.poi.test.entity; | |||||
import java.io.Serializable; | |||||
import org.jeecgframework.poi.excel.annotation.Excel; | |||||
/** | |||||
* 客户分组表 | |||||
* | |||||
* @author yjl | |||||
* | |||||
*/ | |||||
public class MsgClientGroup implements Serializable { | |||||
/** | |||||
* | |||||
*/ | |||||
private static final long serialVersionUID = 6946265640897464878L; | |||||
// 组名 | |||||
@Excel(name = "分组") | |||||
private String groupName = null; | |||||
/** | |||||
* 创建人 | |||||
*/ | |||||
private String createBy; | |||||
// 一个组下 可能存在N多客户 | |||||
//private List<MsgClientMine> clients = null; | |||||
/*@org.codehaus.jackson.annotate.JsonIgnore | |||||
@OneToMany(cascade = CascadeType.REMOVE,fetch = FetchType.LAZY,mappedBy = "group") | |||||
public List<MsgClientMine> getClients() { | |||||
return clients; | |||||
} | |||||
public void setClients(List<MsgClientMine> clients) { | |||||
this.clients = clients; | |||||
}*/ | |||||
public String getCreateBy() { | |||||
return createBy; | |||||
} | |||||
public String getGroupName() { | |||||
return groupName; | |||||
} | |||||
public void setCreateBy(String createBy) { | |||||
this.createBy = createBy; | |||||
} | |||||
public void setGroupName(String groupName) { | |||||
this.groupName = groupName; | |||||
} | |||||
} |
@@ -1,119 +0,0 @@ | |||||
package org.jeecgframework.poi.test.entity; | |||||
import java.util.Date; | |||||
import org.jeecgframework.poi.excel.annotation.Excel; | |||||
/** | |||||
* @author JueYue | |||||
* @version V1.0 | |||||
* @Title: Entity | |||||
* @Description: 学生 | |||||
* @date 2013-08-31 22:53:34 | |||||
*/ | |||||
@SuppressWarnings("serial") | |||||
public class StudentEntity implements java.io.Serializable { | |||||
/** | |||||
* id | |||||
*/ | |||||
private String id; | |||||
/** | |||||
* 学生姓名 | |||||
*/ | |||||
@Excel(name = "学生姓名", height = 20, width = 30) | |||||
private String name; | |||||
/** | |||||
* 学生性别 | |||||
*/ | |||||
@Excel(name = "学生性别", replace = { "男_1", "女_2" }, suffix = "生") | |||||
private int sex; | |||||
@Excel(name = "出生日期", databaseFormat = "yyyyMMddHHmmss", format = "yyyy-MM-dd") | |||||
private Date birthday; | |||||
@Excel(name = "进校日期", databaseFormat = "yyyyMMddHHmmss", format = "yyyy-MM-dd") | |||||
private java.sql.Time registrationDate; | |||||
/** | |||||
* 课程主键 | |||||
*/ | |||||
private CourseEntity course; | |||||
public CourseEntity getCourse() { | |||||
return course; | |||||
} | |||||
/** | |||||
* 方法: 取得java.lang.String | |||||
* | |||||
* @return: java.lang.String id | |||||
*/ | |||||
public String getId() { | |||||
return this.id; | |||||
} | |||||
/** | |||||
* 方法: 取得java.lang.String | |||||
* | |||||
* @return: java.lang.String 学生姓名 | |||||
*/ | |||||
public String getName() { | |||||
return this.name; | |||||
} | |||||
/** | |||||
* 方法: 取得java.lang.String | |||||
* | |||||
* @return: java.lang.String 学生性别 | |||||
*/ | |||||
public int getSex() { | |||||
return this.sex; | |||||
} | |||||
public void setCourse(CourseEntity course) { | |||||
this.course = course; | |||||
} | |||||
/** | |||||
* 方法: 设置java.lang.String | |||||
* | |||||
* @param: java.lang.String id | |||||
*/ | |||||
public void setId(String id) { | |||||
this.id = id; | |||||
} | |||||
/** | |||||
* 方法: 设置java.lang.String | |||||
* | |||||
* @param: java.lang.String 学生姓名 | |||||
*/ | |||||
public void setName(String name) { | |||||
this.name = name; | |||||
} | |||||
/** | |||||
* 方法: 设置java.lang.String | |||||
* | |||||
* @param: java.lang.String 学生性别 | |||||
*/ | |||||
public void setSex(int sex) { | |||||
this.sex = sex; | |||||
} | |||||
public Date getBirthday() { | |||||
return birthday; | |||||
} | |||||
public void setBirthday(Date birthday) { | |||||
this.birthday = birthday; | |||||
} | |||||
public java.sql.Time getRegistrationDate() { | |||||
return registrationDate; | |||||
} | |||||
public void setRegistrationDate(java.sql.Time registrationDate) { | |||||
this.registrationDate = registrationDate; | |||||
} | |||||
} |
@@ -1,72 +0,0 @@ | |||||
package org.jeecgframework.poi.test.entity; | |||||
import org.jeecgframework.poi.excel.annotation.Excel; | |||||
import org.jeecgframework.poi.excel.annotation.ExcelTarget; | |||||
/** | |||||
* @Title: Entity | |||||
* @Description: 课程老师 | |||||
* @author JueYue | |||||
* @date 2013-08-31 22:52:17 | |||||
* @version V1.0 | |||||
* | |||||
*/ | |||||
@SuppressWarnings("serial") | |||||
@ExcelTarget("teacherEntity") | |||||
public class TeacherEntity implements java.io.Serializable { | |||||
/** id */ | |||||
@Excel(name = "老师ID_teacherEntity,老师属性_courseEntity", orderNum = "2", needMerge = false) | |||||
private String id; | |||||
/** name */ | |||||
@Excel(name = "老师姓名_yuwen,数学老师_shuxue", orderNum = "2", mergeVertical = true) | |||||
private String name; | |||||
/* | |||||
* @Excel(exportName="老师照片",orderNum="3",exportType=2,exportFieldHeight=15, | |||||
* exportFieldWidth=20) private String pic; | |||||
*/ | |||||
/** | |||||
* 方法: 取得java.lang.String | |||||
* | |||||
* @return: java.lang.String id | |||||
*/ | |||||
public String getId() { | |||||
return this.id; | |||||
} | |||||
/** | |||||
* 方法: 取得java.lang.String | |||||
* | |||||
* @return: java.lang.String name | |||||
*/ | |||||
public String getName() { | |||||
return this.name; | |||||
} | |||||
/** | |||||
* 方法: 设置java.lang.String | |||||
* | |||||
* @param: java.lang.String id | |||||
*/ | |||||
public void setId(String id) { | |||||
this.id = id; | |||||
} | |||||
/** | |||||
* 方法: 设置java.lang.String | |||||
* | |||||
* @param: java.lang.String name | |||||
*/ | |||||
public void setName(String name) { | |||||
this.name = name; | |||||
} | |||||
/* | |||||
* public String getPic() { // if(StringUtils.isEmpty(pic)){ // pic = | |||||
* "plug-in/login/images/jeecg.png"; // } return pic; } | |||||
* | |||||
* public void setPic(String pic) { this.pic = pic; } | |||||
*/ | |||||
} |
@@ -1,28 +0,0 @@ | |||||
package org.jeecgframework.poi.test.entity; | |||||
import org.jeecgframework.poi.excel.annotation.Excel; | |||||
public class TestEntity { | |||||
@Excel(name = "蓝牙POS机") | |||||
private String lanya; | |||||
@Excel(name = "蓝牙点付宝") | |||||
private String pos; | |||||
public String getLanya() { | |||||
return lanya; | |||||
} | |||||
public void setLanya(String lanya) { | |||||
this.lanya = lanya; | |||||
} | |||||
public String getPos() { | |||||
return pos; | |||||
} | |||||
public void setPos(String pos) { | |||||
this.pos = pos; | |||||
} | |||||
} |
@@ -1,46 +0,0 @@ | |||||
package org.jeecgframework.poi.test.entity.samename; | |||||
import java.util.List; | |||||
import org.jeecgframework.poi.excel.annotation.Excel; | |||||
import org.jeecgframework.poi.excel.annotation.ExcelCollection; | |||||
import org.jeecgframework.poi.test.entity.StudentEntity; | |||||
public class ClassName { | |||||
@Excel(name="班级") | |||||
private String name; | |||||
@ExcelCollection(name="小组A") | |||||
private List<StudentEntity> arrA; | |||||
@ExcelCollection(name="小组B") | |||||
private List<StudentEntity> arrB; | |||||
public String getName() { | |||||
return name; | |||||
} | |||||
public void setName(String name) { | |||||
this.name = name; | |||||
} | |||||
public List<StudentEntity> getArrA() { | |||||
return arrA; | |||||
} | |||||
public void setArrA(List<StudentEntity> arrA) { | |||||
this.arrA = arrA; | |||||
} | |||||
public List<StudentEntity> getArrB() { | |||||
return arrB; | |||||
} | |||||
public void setArrB(List<StudentEntity> arrB) { | |||||
this.arrB = arrB; | |||||
} | |||||
} |
@@ -1,80 +0,0 @@ | |||||
package org.jeecgframework.poi.test.entity.statistics; | |||||
import java.math.BigDecimal; | |||||
import org.jeecgframework.poi.excel.annotation.Excel; | |||||
/** | |||||
* 统计测试类 | |||||
* @author JueYue | |||||
* @date 2014年12月17日 上午11:51:10 | |||||
*/ | |||||
public class StatisticEntity { | |||||
@Excel(name = "名称") | |||||
private String name; | |||||
@Excel(name = "int 测试", width = 15, isStatistics = true) | |||||
private int intTest; | |||||
@Excel(name = "long 测试", width = 15, isStatistics = true) | |||||
private long longTest; | |||||
@Excel(name = "double 测试", width = 15, isStatistics = true) | |||||
private double doubleTest; | |||||
@Excel(name = "string 测试", width = 15, isStatistics = true) | |||||
private String stringTest; | |||||
@Excel(name = "BigDecimal 测试", width = 15, isStatistics = true) | |||||
private BigDecimal bigDecimalTest; | |||||
public String getName() { | |||||
return name; | |||||
} | |||||
public void setName(String name) { | |||||
this.name = name; | |||||
} | |||||
public int getIntTest() { | |||||
return intTest; | |||||
} | |||||
public void setIntTest(int intTest) { | |||||
this.intTest = intTest; | |||||
} | |||||
public long getLongTest() { | |||||
return longTest; | |||||
} | |||||
public void setLongTest(long longTest) { | |||||
this.longTest = longTest; | |||||
} | |||||
public double getDoubleTest() { | |||||
return doubleTest; | |||||
} | |||||
public void setDoubleTest(double doubleTest) { | |||||
this.doubleTest = doubleTest; | |||||
} | |||||
public String getStringTest() { | |||||
return stringTest; | |||||
} | |||||
public void setStringTest(String stringTest) { | |||||
this.stringTest = stringTest; | |||||
} | |||||
public BigDecimal getBigDecimalTest() { | |||||
return bigDecimalTest; | |||||
} | |||||
public void setBigDecimalTest(BigDecimal bigDecimalTest) { | |||||
this.bigDecimalTest = bigDecimalTest; | |||||
} | |||||
} |
@@ -1,34 +0,0 @@ | |||||
package org.jeecgframework.poi.test.entity.temp; | |||||
import org.jeecgframework.poi.excel.annotation.Excel; | |||||
/** | |||||
* 预算 | |||||
* @author JueYue | |||||
* @date 2014年12月27日 下午9:08:03 | |||||
*/ | |||||
public class BudgetAccountsEntity { | |||||
@Excel(name = "编码") | |||||
private String code; | |||||
@Excel(name = "名称") | |||||
private String name; | |||||
public String getCode() { | |||||
return code; | |||||
} | |||||
public void setCode(String code) { | |||||
this.code = code; | |||||
} | |||||
public String getName() { | |||||
return name; | |||||
} | |||||
public void setName(String name) { | |||||
this.name = name; | |||||
} | |||||
} |
@@ -1,40 +0,0 @@ | |||||
package org.jeecgframework.poi.test.entity.temp; | |||||
import org.jeecgframework.poi.excel.annotation.Excel; | |||||
public class PayeeEntity { | |||||
@Excel(name = "全称") | |||||
private String name; | |||||
@Excel(name = "银行账号") | |||||
private String bankAccount; | |||||
@Excel(name = "开户银行") | |||||
private String bankName; | |||||
public String getName() { | |||||
return name; | |||||
} | |||||
public void setName(String name) { | |||||
this.name = name; | |||||
} | |||||
public String getBankAccount() { | |||||
return bankAccount; | |||||
} | |||||
public void setBankAccount(String bankAccount) { | |||||
this.bankAccount = bankAccount; | |||||
} | |||||
public String getBankName() { | |||||
return bankName; | |||||
} | |||||
public void setBankName(String bankName) { | |||||
this.bankName = bankName; | |||||
} | |||||
} |
@@ -1,99 +0,0 @@ | |||||
package org.jeecgframework.poi.test.entity.temp; | |||||
import java.io.Serializable; | |||||
import java.util.List; | |||||
import org.jeecgframework.poi.excel.annotation.Excel; | |||||
import org.jeecgframework.poi.excel.annotation.ExcelCollection; | |||||
import org.jeecgframework.poi.excel.annotation.ExcelEntity; | |||||
/** | |||||
* 模板导出 测试类 | |||||
* @author JueYue | |||||
* @date 2014年12月26日 上午9:39:13 | |||||
*/ | |||||
public class TemplateExcelExportEntity implements Serializable { | |||||
/** | |||||
* | |||||
*/ | |||||
private static final long serialVersionUID = 1L; | |||||
@Excel(name = "序号") | |||||
private String index; | |||||
@Excel(name = "资金性质") | |||||
private String accountType; | |||||
@ExcelCollection(name = "预算科目") | |||||
private List<BudgetAccountsEntity> budgetAccounts; | |||||
@Excel(name = "项目名称") | |||||
private String projectName; | |||||
@ExcelEntity(name = "收款人") | |||||
private PayeeEntity payee; | |||||
@Excel(name = "申请金额") | |||||
private String amountApplied; | |||||
@Excel(name = "核定金额") | |||||
private String approvedAmount; | |||||
public String getIndex() { | |||||
return index; | |||||
} | |||||
public void setIndex(String index) { | |||||
this.index = index; | |||||
} | |||||
public String getAccountType() { | |||||
return accountType; | |||||
} | |||||
public void setAccountType(String accountType) { | |||||
this.accountType = accountType; | |||||
} | |||||
public List<BudgetAccountsEntity> getBudgetAccounts() { | |||||
return budgetAccounts; | |||||
} | |||||
public void setBudgetAccounts(List<BudgetAccountsEntity> budgetAccounts) { | |||||
this.budgetAccounts = budgetAccounts; | |||||
} | |||||
public String getProjectName() { | |||||
return projectName; | |||||
} | |||||
public void setProjectName(String projectName) { | |||||
this.projectName = projectName; | |||||
} | |||||
public PayeeEntity getPayee() { | |||||
return payee; | |||||
} | |||||
public void setPayee(PayeeEntity payee) { | |||||
this.payee = payee; | |||||
} | |||||
public String getAmountApplied() { | |||||
return amountApplied; | |||||
} | |||||
public void setAmountApplied(String amountApplied) { | |||||
this.amountApplied = amountApplied; | |||||
} | |||||
public String getApprovedAmount() { | |||||
return approvedAmount; | |||||
} | |||||
public void setApprovedAmount(String approvedAmount) { | |||||
this.approvedAmount = approvedAmount; | |||||
} | |||||
} |
@@ -1,41 +0,0 @@ | |||||
package org.jeecgframework.poi.test.excel.styler; | |||||
import org.apache.poi.hssf.usermodel.HSSFDataFormat; | |||||
import org.apache.poi.ss.usermodel.BuiltinFormats; | |||||
import org.apache.poi.ss.usermodel.CellStyle; | |||||
import org.apache.poi.ss.usermodel.Workbook; | |||||
import org.jeecgframework.poi.excel.entity.params.ExcelExportEntity; | |||||
import org.jeecgframework.poi.excel.export.styler.ExcelExportStylerDefaultImpl; | |||||
/** | |||||
* Excel 自定义styler 的例子 | |||||
* @author JueYue | |||||
* @date 2015年3月29日 下午9:04:41 | |||||
*/ | |||||
public class ExcelExportStatisticStyler extends ExcelExportStylerDefaultImpl { | |||||
private CellStyle numberCellStyle; | |||||
public ExcelExportStatisticStyler(Workbook workbook) { | |||||
super(workbook); | |||||
createNumberCellStyler(); | |||||
} | |||||
private void createNumberCellStyler() { | |||||
numberCellStyle = workbook.createCellStyle(); | |||||
numberCellStyle.setAlignment(CellStyle.ALIGN_CENTER); | |||||
numberCellStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER); | |||||
numberCellStyle.setDataFormat((short) BuiltinFormats.getBuiltinFormat("0.00")); | |||||
numberCellStyle.setWrapText(true); | |||||
} | |||||
@Override | |||||
public CellStyle getStyles(boolean noneStyler, ExcelExportEntity entity) { | |||||
if (entity != null | |||||
&& (entity.getName().contains("int") || entity.getName().contains("double"))) { | |||||
return numberCellStyle; | |||||
} | |||||
return super.getStyles(noneStyler, entity); | |||||
} | |||||
} |
@@ -1,41 +0,0 @@ | |||||
package org.jeecgframework.poi.test.excel.template; | |||||
import org.apache.poi.ss.usermodel.CellStyle; | |||||
import org.apache.poi.ss.usermodel.Workbook; | |||||
import org.jeecgframework.poi.excel.export.styler.ExcelExportStylerDefaultImpl; | |||||
public class ManySheetOneSyler extends ExcelExportStylerDefaultImpl { | |||||
private static CellStyle stringSeptailStyle; | |||||
private static CellStyle stringNoneStyle; | |||||
public ManySheetOneSyler(Workbook workbook) { | |||||
super(workbook); | |||||
} | |||||
@Override | |||||
public CellStyle stringSeptailStyle(Workbook workbook, boolean isWarp) { | |||||
if (stringSeptailStyle == null) { | |||||
stringSeptailStyle = workbook.createCellStyle(); | |||||
stringSeptailStyle.setAlignment(CellStyle.ALIGN_CENTER); | |||||
stringSeptailStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER); | |||||
stringSeptailStyle.setDataFormat(STRING_FORMAT); | |||||
stringSeptailStyle.setWrapText(true); | |||||
} | |||||
return stringSeptailStyle; | |||||
} | |||||
@Override | |||||
public CellStyle stringNoneStyle(Workbook workbook, boolean isWarp) { | |||||
if (stringNoneStyle == null) { | |||||
stringNoneStyle = workbook.createCellStyle(); | |||||
stringNoneStyle.setAlignment(CellStyle.ALIGN_CENTER); | |||||
stringNoneStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER); | |||||
stringNoneStyle.setDataFormat(STRING_FORMAT); | |||||
stringNoneStyle.setWrapText(true); | |||||
} | |||||
return stringNoneStyle; | |||||
} | |||||
} |
@@ -1,84 +0,0 @@ | |||||
package org.jeecgframework.poi.test.excel.template; | |||||
import static org.junit.Assert.*; | |||||
import java.io.File; | |||||
import java.io.FileOutputStream; | |||||
import java.util.ArrayList; | |||||
import java.util.Date; | |||||
import java.util.HashMap; | |||||
import java.util.List; | |||||
import java.util.Map; | |||||
import org.apache.poi.ss.usermodel.Workbook; | |||||
import org.jeecgframework.poi.excel.ExcelExportUtil; | |||||
import org.jeecgframework.poi.excel.entity.TemplateExportParams; | |||||
import org.jeecgframework.poi.excel.export.styler.ExcelExportStylerBorderImpl; | |||||
import org.jeecgframework.poi.excel.export.styler.ExcelExportStylerColorImpl; | |||||
import org.jeecgframework.poi.excel.export.styler.ExcelExportStylerDefaultImpl; | |||||
import org.jeecgframework.poi.test.entity.statistics.StatisticEntity; | |||||
import org.jeecgframework.poi.test.entity.temp.BudgetAccountsEntity; | |||||
import org.jeecgframework.poi.test.entity.temp.PayeeEntity; | |||||
import org.jeecgframework.poi.test.entity.temp.TemplateExcelExportEntity; | |||||
import org.junit.Test; | |||||
import com.google.common.collect.Lists; | |||||
public class TemplateExcelExportTest { | |||||
@Test | |||||
public void test() throws Exception { | |||||
TemplateExportParams params = new TemplateExportParams( | |||||
"org/jeecgframework/poi/test/excel/doc/专项支出用款申请书.xls"); | |||||
params.setHeadingStartRow(3); | |||||
params.setHeadingRows(2); | |||||
params.setStyle(ExcelExportStylerColorImpl.class); | |||||
Map<String, Object> map = new HashMap<String, Object>(); | |||||
map.put("date", "2014-12-25"); | |||||
map.put("money", 2000000.00); | |||||
map.put("upperMoney", "贰佰万"); | |||||
map.put("company", "执笔潜行科技有限公司"); | |||||
map.put("bureau", "财政局"); | |||||
map.put("person", "JueYue"); | |||||
map.put("phone", "1879740****"); | |||||
List<TemplateExcelExportEntity> list = new ArrayList<TemplateExcelExportEntity>(); | |||||
for (int i = 0; i < 4; i++) { | |||||
TemplateExcelExportEntity entity = new TemplateExcelExportEntity(); | |||||
entity.setIndex(i + 1 + ""); | |||||
entity.setAccountType("开源项目"); | |||||
entity.setProjectName("EasyPoi " + i + "期"); | |||||
entity.setAmountApplied(i * 10000 + ""); | |||||
entity.setApprovedAmount((i + 1) * 10000 - 100 + ""); | |||||
List<BudgetAccountsEntity> budgetAccounts = Lists.newArrayList(); | |||||
for (int j = 0; j < 1; j++) { | |||||
BudgetAccountsEntity accountsEntity = new BudgetAccountsEntity(); | |||||
accountsEntity.setCode("A001"); | |||||
accountsEntity.setName("设计"); | |||||
budgetAccounts.add(accountsEntity); | |||||
accountsEntity = new BudgetAccountsEntity(); | |||||
accountsEntity.setCode("A002"); | |||||
accountsEntity.setName("开发"); | |||||
budgetAccounts.add(accountsEntity); | |||||
} | |||||
entity.setBudgetAccounts(budgetAccounts); | |||||
PayeeEntity payeeEntity = new PayeeEntity(); | |||||
payeeEntity.setBankAccount("6222 0000 1234 1234"); | |||||
payeeEntity.setBankName("中国银行"); | |||||
payeeEntity.setName("小明"); | |||||
entity.setPayee(payeeEntity); | |||||
list.add(entity); | |||||
} | |||||
Workbook workbook = ExcelExportUtil.exportExcel(params, TemplateExcelExportEntity.class, | |||||
list, map); | |||||
File savefile = new File("d:/"); | |||||
if (!savefile.exists()) { | |||||
savefile.mkdirs(); | |||||
} | |||||
FileOutputStream fos = new FileOutputStream("d:/tt.xls"); | |||||
workbook.write(fos); | |||||
fos.close(); | |||||
} | |||||
} |
@@ -1,113 +0,0 @@ | |||||
package org.jeecgframework.poi.test.excel.template; | |||||
import java.io.File; | |||||
import java.io.FileNotFoundException; | |||||
import java.io.FileOutputStream; | |||||
import java.util.ArrayList; | |||||
import java.util.Collection; | |||||
import java.util.HashMap; | |||||
import java.util.List; | |||||
import java.util.Map; | |||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook; | |||||
import org.apache.poi.ss.usermodel.Workbook; | |||||
import org.jeecgframework.poi.excel.entity.ExportParams; | |||||
import org.jeecgframework.poi.excel.entity.TemplateExportParams; | |||||
import org.jeecgframework.poi.excel.entity.params.ExcelExportEntity; | |||||
import org.jeecgframework.poi.excel.export.ExcelExportServer; | |||||
import org.jeecgframework.poi.excel.export.template.ExcelExportOfTemplateUtil; | |||||
import org.junit.Test; | |||||
public class TemplateExcelSheetTest { | |||||
@Test | |||||
public void test() throws Exception { | |||||
ExcelExportServer util = new ExcelExportServer(); | |||||
Workbook workbook = new HSSFWorkbook(); | |||||
ExportParams entity = new ExportParams(); | |||||
entity.setCreateHeadRows(false); | |||||
entity.setStyle(ManySheetOneSyler.class); | |||||
List<ExcelExportEntity> entityList = new ArrayList<ExcelExportEntity>(); | |||||
ExcelExportEntity e = new ExcelExportEntity(); | |||||
e.setHeight(40); | |||||
e.setWidth(40); | |||||
e.setWrap(true); | |||||
e.setName("one"); | |||||
e.setKey("one"); | |||||
entityList.add(e); | |||||
e = new ExcelExportEntity(); | |||||
e.setHeight(40); | |||||
e.setWidth(40); | |||||
e.setWrap(true); | |||||
e.setName("two"); | |||||
e.setKey("two"); | |||||
entityList.add(e); | |||||
e = new ExcelExportEntity(); | |||||
e.setHeight(40); | |||||
e.setWidth(40); | |||||
e.setWrap(true); | |||||
e.setName("three"); | |||||
e.setKey("three"); | |||||
entityList.add(e); | |||||
e = new ExcelExportEntity(); | |||||
e.setHeight(40); | |||||
e.setWidth(40); | |||||
e.setWrap(true); | |||||
e.setName("four"); | |||||
e.setKey("four"); | |||||
entityList.add(e); | |||||
e = new ExcelExportEntity(); | |||||
e.setHeight(40); | |||||
e.setWidth(40); | |||||
e.setWrap(true); | |||||
e.setName("five"); | |||||
e.setKey("five"); | |||||
entityList.add(e); | |||||
//这里加入了40个数据源 | |||||
List<Map<String, Object>> dataList = new ArrayList<Map<String, Object>>(); | |||||
for (int l = 0; l < 80; l++) { | |||||
Map<String, Object> map = new HashMap<String, Object>(); | |||||
map.put("one", | |||||
"卡片编号:2228\n资产名称:办公器\n开始使用日期:20090910\n使用状况:在用\n使用科室:财务科\n管理科室:总务科\n市妇幼2015年6月"); | |||||
map.put("two", | |||||
"卡片编号:2228\n资产名称:办公器\n开始使用日期:20090910\n使用状况:在用\n使用科室:财务科\n管理科室:总务科\n市妇幼2015年6月"); | |||||
map.put("three", | |||||
"卡片编号:2228\n资产名称:办公器\n开始使用日期:20090910\n使用状况:在用\n使用科室:财务科\n管理科室:总务科\n市妇幼2015年6月"); | |||||
map.put("five", | |||||
"卡片编号:2228\n资产名称:办公器\n开始使用日期:20090910\n使用状况:在用\n使用科室:财务科\n管理科室:总务科\n市妇幼2015年6月"); | |||||
map.put("four", | |||||
"卡片编号:2228\n资产名称:办公器\n开始使用日期:20090910\n使用状况:在用\n使用科室:财务科\n管理科室:总务科\n市妇幼2015年6月"); | |||||
dataList.add(map); | |||||
} | |||||
//补全数据好看一点 | |||||
for (int l = 0, le = (dataList.size() % 6) == 0 ? 0 : 6 - dataList.size() % 6; l < le; l++) { | |||||
Map<String, Object> map = new HashMap<String, Object>(); | |||||
map.put("one", ""); | |||||
map.put("two", ""); | |||||
map.put("three", ""); | |||||
map.put("five", ""); | |||||
map.put("four", ""); | |||||
dataList.add(map); | |||||
} | |||||
for (int i = 0, le = dataList.size() / 6; i < le; i++) { | |||||
util.createSheetForMap(workbook, entity, entityList, dataList.subList(0, 6)); | |||||
} | |||||
File savefile = new File("d:/"); | |||||
if (!savefile.exists()) { | |||||
savefile.mkdirs(); | |||||
} | |||||
FileOutputStream fos = new FileOutputStream("d:/foreach.xls"); | |||||
workbook.write(fos); | |||||
fos.close(); | |||||
} | |||||
public void createSheetForMap(Workbook workbook, ExportParams entity, | |||||
List<ExcelExportEntity> entityList, | |||||
Collection<? extends Map<?, ?>> dataSet) { | |||||
} | |||||
} |
@@ -1,77 +0,0 @@ | |||||
package org.jeecgframework.poi.test.excel.template; | |||||
import java.io.File; | |||||
import java.io.FileOutputStream; | |||||
import java.util.ArrayList; | |||||
import java.util.Date; | |||||
import java.util.HashMap; | |||||
import java.util.List; | |||||
import java.util.Map; | |||||
import org.apache.poi.ss.usermodel.Workbook; | |||||
import org.jeecgframework.poi.excel.ExcelExportUtil; | |||||
import org.jeecgframework.poi.excel.entity.TemplateExportParams; | |||||
import org.jeecgframework.poi.excel.export.styler.ExcelExportStylerColorImpl; | |||||
import org.jeecgframework.poi.test.entity.temp.BudgetAccountsEntity; | |||||
import org.jeecgframework.poi.test.entity.temp.PayeeEntity; | |||||
import org.jeecgframework.poi.test.entity.temp.TemplateExcelExportEntity; | |||||
import org.junit.Test; | |||||
import com.google.common.collect.Lists; | |||||
public class TemplateForEachTest { | |||||
@Test | |||||
public void test() throws Exception { | |||||
TemplateExportParams params = new TemplateExportParams( | |||||
"org/jeecgframework/poi/test/excel/doc/foreach.xlsx"); | |||||
Map<String, Object> map = new HashMap<String, Object>(); | |||||
List<TemplateExcelExportEntity> list = new ArrayList<TemplateExcelExportEntity>(); | |||||
for (int i = 0; i < 4; i++) { | |||||
TemplateExcelExportEntity entity = new TemplateExcelExportEntity(); | |||||
entity.setIndex(i + 1 + ""); | |||||
entity.setAccountType("开源项目"); | |||||
entity.setProjectName("EasyPoi " + i + "期"); | |||||
entity.setAmountApplied(i * 10000 + ""); | |||||
entity.setApprovedAmount((i + 1) * 10000 - 100 + ""); | |||||
list.add(entity); | |||||
} | |||||
map.put("entitylist", list); | |||||
map.put("letest", "12345678"); | |||||
map.put("fntest", "12345678.2341234"); | |||||
map.put("fdtest", null); | |||||
List<Map<String, Object>> mapList = new ArrayList<Map<String, Object>>(); | |||||
for (int i = 0; i < 4; i++) { | |||||
Map<String, Object> testMap = new HashMap<String, Object>(); | |||||
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()) { | |||||
savefile.mkdirs(); | |||||
} | |||||
FileOutputStream fos = new FileOutputStream("d:/foreach.xlsx"); | |||||
workbook.write(fos); | |||||
fos.close(); | |||||
workbook = ExcelExportUtil.exportExcel(params, map); | |||||
fos = new FileOutputStream("d:/foreach2.xlsx"); | |||||
workbook.write(fos); | |||||
fos.close(); | |||||
} | |||||
} |
@@ -1,20 +0,0 @@ | |||||
package org.jeecgframework.poi.test.excel.test; | |||||
import org.jeecgframework.poi.handler.impl.ExcelDataHandlerDefaultImpl; | |||||
public class CourseHanlder extends ExcelDataHandlerDefaultImpl { | |||||
@Override | |||||
public Object exportHandler(Object obj, String name, Object value) { | |||||
if (name.equals("课程名称")) { | |||||
return String.valueOf(value) + "课程"; | |||||
} | |||||
return super.exportHandler(obj, name, value); | |||||
} | |||||
@Override | |||||
public Object importHandler(Object obj, String name, Object value) { | |||||
return super.importHandler(obj, name, value); | |||||
} | |||||
} |
@@ -1,140 +0,0 @@ | |||||
package org.jeecgframework.poi.test.excel.test; | |||||
import java.io.FileNotFoundException; | |||||
import java.io.FileOutputStream; | |||||
import java.io.IOException; | |||||
import java.util.ArrayList; | |||||
import java.util.HashMap; | |||||
import java.util.List; | |||||
import java.util.Map; | |||||
//import org.apache.poi.hssf.usermodel.HSSFWorkbook; | |||||
import org.apache.poi.ss.usermodel.Workbook; | |||||
import org.jeecgframework.poi.excel.ExcelExportUtil; | |||||
import org.jeecgframework.poi.excel.entity.ExportParams; | |||||
import org.jeecgframework.poi.excel.entity.enmus.ExcelType; | |||||
import org.jeecgframework.poi.excel.entity.params.ExcelExportEntity; | |||||
import org.jeecgframework.poi.excel.entity.vo.PoiBaseConstants; | |||||
import org.junit.Test; | |||||
public class ExcelExportForMap { | |||||
/** | |||||
* Map 测试 | |||||
*/ | |||||
@Test | |||||
public void test() { | |||||
try { | |||||
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); | |||||
} | |||||
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("测试", "测试"), entity, | |||||
list); | |||||
FileOutputStream fos = new FileOutputStream("d:/tt.xls"); | |||||
workbook.write(fos); | |||||
fos.close(); | |||||
} catch (FileNotFoundException e) { | |||||
e.printStackTrace(); | |||||
} catch (IOException e) { | |||||
e.printStackTrace(); | |||||
} | |||||
} | |||||
/** | |||||
* 合并同类项 | |||||
*/ | |||||
//@Test | |||||
public void testMerge() { | |||||
try { | |||||
List<ExcelExportEntity> entity = new ArrayList<ExcelExportEntity>(); | |||||
ExcelExportEntity excelentity = new ExcelExportEntity("部门", "depart"); | |||||
excelentity.setMergeVertical(true); | |||||
excelentity.setMergeRely(new int[0]); | |||||
entity.add(excelentity); | |||||
entity.add(new ExcelExportEntity("姓名", "name")); | |||||
excelentity = new ExcelExportEntity("电话", "phone"); | |||||
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("depart", "设计部"); | |||||
map.put("name", "小明" + i); | |||||
map.put("phone", "1311234567" + i); | |||||
list.add(map); | |||||
} | |||||
for (int i = 0; i < 10; i++) { | |||||
map = new HashMap<String, Object>(); | |||||
map.put("depart", "开发部"); | |||||
map.put("name", "小蓝" + i); | |||||
map.put("phone", "1871234567" + i); | |||||
list.add(map); | |||||
} | |||||
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("员工通讯录", "通讯录"), | |||||
entity, list); | |||||
FileOutputStream fos = new FileOutputStream("d:/tt.xls"); | |||||
workbook.write(fos); | |||||
fos.close(); | |||||
} catch (FileNotFoundException e) { | |||||
e.printStackTrace(); | |||||
} catch (IOException e) { | |||||
e.printStackTrace(); | |||||
} | |||||
} | |||||
//@Test | |||||
public void testMany() { | |||||
try { | |||||
List<ExcelExportEntity> entity = new ArrayList<ExcelExportEntity>(); | |||||
for (int i = 0; i < 500; i++) { | |||||
entity.add(new ExcelExportEntity("姓名" + i, "name" + i)); | |||||
} | |||||
List<Map<String, String>> list = new ArrayList<Map<String, String>>(); | |||||
Map<String, String> map; | |||||
for (int i = 0; i < 10; i++) { | |||||
map = new HashMap<String, String>(); | |||||
for (int j = 0; j < 500; j++) { | |||||
map.put("name" + j, j + "_" + i); | |||||
} | |||||
list.add(map); | |||||
} | |||||
ExportParams params = new ExportParams("测试", "测试", ExcelType.XSSF); | |||||
params.setFreezeCol(5); | |||||
Workbook workbook = ExcelExportUtil.exportExcel(params, entity, list); | |||||
FileOutputStream fos = new FileOutputStream("d:/tt.xlsx"); | |||||
workbook.write(fos); | |||||
fos.close(); | |||||
} catch (FileNotFoundException e) { | |||||
e.printStackTrace(); | |||||
} catch (IOException e) { | |||||
e.printStackTrace(); | |||||
} | |||||
} | |||||
} |
@@ -1,67 +0,0 @@ | |||||
package org.jeecgframework.poi.test.excel.test; | |||||
import static org.junit.Assert.*; | |||||
import java.io.File; | |||||
import java.io.FileNotFoundException; | |||||
import java.io.FileOutputStream; | |||||
import java.lang.reflect.Field; | |||||
import java.util.ArrayList; | |||||
import java.util.Date; | |||||
import java.util.List; | |||||
import org.apache.poi.ss.usermodel.Workbook; | |||||
import org.jeecgframework.poi.excel.ExcelExportUtil; | |||||
import org.jeecgframework.poi.excel.annotation.Excel; | |||||
import org.jeecgframework.poi.excel.entity.ExportParams; | |||||
import org.jeecgframework.poi.excel.entity.enmus.ExcelType; | |||||
import org.jeecgframework.poi.excel.entity.vo.PoiBaseConstants; | |||||
import org.jeecgframework.poi.test.entity.CourseEntity; | |||||
import org.jeecgframework.poi.test.entity.MsgClient; | |||||
import org.jeecgframework.poi.test.entity.MsgClientGroup; | |||||
import org.junit.Test; | |||||
/** | |||||
* 当行大数据量测试 | |||||
* @author JueYue | |||||
* @date 2014年12月13日 下午3:42:57 | |||||
*/ | |||||
public class ExcelExportMsgClient { | |||||
@Test | |||||
public void test() throws Exception { | |||||
Field[] fields = MsgClient.class.getFields(); | |||||
for (int i = 0; i < fields.length; i++) { | |||||
Excel excel = fields[i].getAnnotation(Excel.class); | |||||
System.out.println(excel); | |||||
} | |||||
List<MsgClient> list = new ArrayList<MsgClient>(); | |||||
for (int i = 0; i < 1000000; i++) { | |||||
MsgClient client = new MsgClient(); | |||||
client.setBirthday(new Date()); | |||||
client.setClientName("小明" + i); | |||||
client.setClientPhone("18797" + i); | |||||
client.setCreateBy("JueYue"); | |||||
client.setId("1" + i); | |||||
client.setRemark("测试" + i); | |||||
MsgClientGroup group = new MsgClientGroup(); | |||||
group.setGroupName("测试" + i); | |||||
client.setGroup(group); | |||||
list.add(client); | |||||
} | |||||
Date start = new Date(); | |||||
ExportParams params = new ExportParams("2412312", "测试", ExcelType.XSSF); | |||||
params.setFreezeCol(2); | |||||
Workbook workbook = ExcelExportUtil.exportExcel(params, MsgClient.class, list); | |||||
System.out.println(new Date().getTime() - start.getTime()); | |||||
File savefile = new File("d:/"); | |||||
if (!savefile.exists()) { | |||||
savefile.mkdirs(); | |||||
} | |||||
FileOutputStream fos = new FileOutputStream("d:/tt.xlsx"); | |||||
workbook.write(fos); | |||||
fos.close(); | |||||
} | |||||
} |
@@ -1,48 +0,0 @@ | |||||
package org.jeecgframework.poi.test.excel.test; | |||||
import java.io.File; | |||||
import java.io.FileOutputStream; | |||||
import java.math.BigDecimal; | |||||
import java.util.ArrayList; | |||||
import java.util.Date; | |||||
import java.util.List; | |||||
import org.apache.poi.ss.usermodel.Workbook; | |||||
import org.jeecgframework.poi.excel.ExcelExportUtil; | |||||
import org.jeecgframework.poi.excel.entity.ExportParams; | |||||
import org.jeecgframework.poi.excel.entity.enmus.ExcelStyleType; | |||||
import org.jeecgframework.poi.excel.entity.enmus.ExcelType; | |||||
import org.jeecgframework.poi.excel.entity.vo.PoiBaseConstants; | |||||
import org.jeecgframework.poi.test.entity.statistics.StatisticEntity; | |||||
import org.jeecgframework.poi.test.excel.styler.ExcelExportStatisticStyler; | |||||
import org.junit.Test; | |||||
public class ExcelExportStatisticTest { | |||||
@Test | |||||
public void test() throws Exception { | |||||
List<StatisticEntity> list = new ArrayList<StatisticEntity>(); | |||||
for (int i = 0; i < 20; i++) { | |||||
StatisticEntity client = new StatisticEntity(); | |||||
client.setName("index" + i); | |||||
client.setIntTest(1 + i); | |||||
client.setLongTest(1 + i); | |||||
client.setDoubleTest(1.2D + i); | |||||
client.setBigDecimalTest(new BigDecimal(1.2 + i)); | |||||
client.setStringTest("12" + i); | |||||
list.add(client); | |||||
} | |||||
Date start = new Date(); | |||||
ExportParams params = new ExportParams("2412312", "测试", ExcelType.XSSF); | |||||
params.setStyle(ExcelExportStatisticStyler.class); | |||||
Workbook workbook = ExcelExportUtil.exportExcel(params, StatisticEntity.class, list); | |||||
System.out.println(new Date().getTime() - start.getTime()); | |||||
File savefile = new File("d:/"); | |||||
if (!savefile.exists()) { | |||||
savefile.mkdirs(); | |||||
} | |||||
FileOutputStream fos = new FileOutputStream("d:/tt.xlsx"); | |||||
workbook.write(fos); | |||||
fos.close(); | |||||
} | |||||
} |
@@ -1,116 +0,0 @@ | |||||
package org.jeecgframework.poi.test.excel.test; | |||||
import java.io.File; | |||||
import java.io.FileOutputStream; | |||||
import java.util.ArrayList; | |||||
import java.util.Date; | |||||
import java.util.HashMap; | |||||
import java.util.List; | |||||
import java.util.Map; | |||||
import org.apache.poi.ss.usermodel.Workbook; | |||||
import org.jeecgframework.poi.excel.ExcelExportUtil; | |||||
import org.jeecgframework.poi.excel.entity.TemplateExportParams; | |||||
import org.jeecgframework.poi.excel.entity.enmus.ExcelStyleType; | |||||
import org.jeecgframework.poi.test.entity.CourseEntity; | |||||
import org.jeecgframework.poi.test.entity.StudentEntity; | |||||
import org.jeecgframework.poi.test.entity.TeacherEntity; | |||||
import org.junit.Before; | |||||
import org.junit.Test; | |||||
public class ExcelExportTemplateTest { | |||||
List<CourseEntity> list = new ArrayList<CourseEntity>(); | |||||
CourseEntity courseEntity; | |||||
@Test | |||||
public void one() throws Exception { | |||||
TemplateExportParams params = new TemplateExportParams( | |||||
"org/jeecgframework/poi/test/excel/doc/exportTemp.xls", true); | |||||
params.setHeadingRows(2); | |||||
params.setHeadingStartRow(2); | |||||
params.setStyle(ExcelStyleType.BORDER.getClazz()); | |||||
Map<String, Object> map = new HashMap<String, Object>(); | |||||
//sheet 1 | |||||
map.put("year", "2013"); | |||||
map.put("sunCourses", list.size()); | |||||
Map<String, Object> obj = new HashMap<String, Object>(); | |||||
map.put("obj", obj); | |||||
obj.put("name", list.size()); | |||||
// sheet 2 | |||||
map.put("month", 10); | |||||
Map<String, Object> temp; | |||||
for (int i = 1; i < 8; i++) { | |||||
temp = new HashMap<String, Object>(); | |||||
temp.put("per", i * 10); | |||||
temp.put("mon", i * 1000); | |||||
temp.put("summon", i * 10000); | |||||
map.put("i" + i, temp); | |||||
} | |||||
Workbook book = ExcelExportUtil.exportExcel(params, CourseEntity.class, list, map); | |||||
File savefile = new File("d:/"); | |||||
if (!savefile.exists()) { | |||||
savefile.mkdirs(); | |||||
} | |||||
FileOutputStream fos = new FileOutputStream("d:/exportTemp.xls"); | |||||
book.write(fos); | |||||
fos.close(); | |||||
} | |||||
@Before | |||||
public void testBefore() { | |||||
courseEntity = new CourseEntity(); | |||||
courseEntity.setId("1131"); | |||||
courseEntity.setName("小白"); | |||||
TeacherEntity teacherEntity = new TeacherEntity(); | |||||
teacherEntity.setId("12131231"); | |||||
teacherEntity.setName("你们"); | |||||
courseEntity.setTeacher(teacherEntity); | |||||
teacherEntity = new TeacherEntity(); | |||||
teacherEntity.setId("121312314312421131"); | |||||
teacherEntity.setName("老王"); | |||||
courseEntity.setShuxueteacher(teacherEntity); | |||||
StudentEntity studentEntity = new StudentEntity(); | |||||
studentEntity.setId("11231"); | |||||
studentEntity.setName("撒旦法司法局"); | |||||
studentEntity.setBirthday(new Date()); | |||||
studentEntity.setSex(1); | |||||
List<StudentEntity> studentList = new ArrayList<StudentEntity>(); | |||||
studentList.add(studentEntity); | |||||
studentList.add(studentEntity); | |||||
courseEntity.setStudents(studentList); | |||||
for (int i = 0; i < 3; i++) { | |||||
list.add(courseEntity); | |||||
} | |||||
} | |||||
//@Test | |||||
public void two() throws Exception { | |||||
TemplateExportParams params = new TemplateExportParams( | |||||
"org/jeecgframework/poi/test/excel/doc/exportTemp.xls", 1); | |||||
Map<String, Object> map = new HashMap<String, Object>(); | |||||
map.put("month", 10); | |||||
Map<String, Object> temp; | |||||
for (int i = 1; i < 8; i++) { | |||||
temp = new HashMap<String, Object>(); | |||||
temp.put("per", i * 10); | |||||
temp.put("mon", i * 1000); | |||||
temp.put("summon", i * 10000); | |||||
map.put("i" + i, temp); | |||||
} | |||||
Workbook book = ExcelExportUtil.exportExcel(params, map); | |||||
File savefile = new File("d:/"); | |||||
if (!savefile.exists()) { | |||||
savefile.mkdirs(); | |||||
} | |||||
FileOutputStream fos = new FileOutputStream("d:/exportTemp2.xls"); | |||||
book.write(fos); | |||||
fos.close(); | |||||
} | |||||
} |
@@ -1,73 +0,0 @@ | |||||
package org.jeecgframework.poi.test.excel.test; | |||||
import java.io.FileOutputStream; | |||||
import java.util.ArrayList; | |||||
import java.util.Date; | |||||
import java.util.List; | |||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook; | |||||
import org.apache.poi.ss.usermodel.Workbook; | |||||
import org.jeecgframework.poi.excel.ExcelExportUtil; | |||||
import org.jeecgframework.poi.excel.entity.ExportParams; | |||||
import org.jeecgframework.poi.test.entity.CourseEntity; | |||||
import org.jeecgframework.poi.test.entity.StudentEntity; | |||||
import org.jeecgframework.poi.test.entity.TeacherEntity; | |||||
import org.junit.Before; | |||||
import org.junit.Test; | |||||
/** | |||||
* 数据处理测试 Created by jue on 14-4-19. | |||||
*/ | |||||
public class ExcelExportUtilDataHandlerTest { | |||||
List<CourseEntity> list = new ArrayList<CourseEntity>(); | |||||
CourseEntity courseEntity; | |||||
@Before | |||||
public void testBefore() { | |||||
courseEntity = new CourseEntity(); | |||||
courseEntity.setId("1131"); | |||||
courseEntity.setName("小白"); | |||||
TeacherEntity teacherEntity = new TeacherEntity(); | |||||
teacherEntity.setId("12131231"); | |||||
teacherEntity.setName("你们"); | |||||
courseEntity.setTeacher(teacherEntity); | |||||
teacherEntity = new TeacherEntity(); | |||||
teacherEntity.setId("121312314312421131"); | |||||
teacherEntity.setName("老王"); | |||||
courseEntity.setShuxueteacher(teacherEntity); | |||||
StudentEntity studentEntity = new StudentEntity(); | |||||
studentEntity.setId("11231"); | |||||
studentEntity.setName("撒旦法司法局"); | |||||
studentEntity.setBirthday(new Date()); | |||||
studentEntity.setSex(1); | |||||
List<StudentEntity> studentList = new ArrayList<StudentEntity>(); | |||||
studentList.add(studentEntity); | |||||
studentList.add(studentEntity); | |||||
courseEntity.setStudents(studentList); | |||||
for (int i = 0; i < 3; i++) { | |||||
list.add(courseEntity); | |||||
} | |||||
} | |||||
/** | |||||
* 基本导出测试 | |||||
* | |||||
* @throws Exception | |||||
*/ | |||||
@Test | |||||
public void testExportExcel() throws Exception { | |||||
ExportParams exportParams = new ExportParams("2412312", "测试", "测试"); | |||||
CourseHanlder hanlder = new CourseHanlder(); | |||||
hanlder.setNeedHandlerFields(new String[] { "课程名称" }); | |||||
exportParams.setDataHanlder(hanlder); | |||||
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, CourseEntity.class, list); | |||||
FileOutputStream fos = new FileOutputStream("d:/tt.xls"); | |||||
workbook.write(fos); | |||||
fos.close(); | |||||
} | |||||
} |
@@ -1,79 +0,0 @@ | |||||
package org.jeecgframework.poi.test.excel.test; | |||||
import java.io.FileOutputStream; | |||||
import java.util.ArrayList; | |||||
import java.util.Date; | |||||
import java.util.List; | |||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook; | |||||
import org.apache.poi.ss.usermodel.Workbook; | |||||
import org.jeecgframework.poi.excel.ExcelExportUtil; | |||||
import org.jeecgframework.poi.excel.entity.ExportParams; | |||||
import org.jeecgframework.poi.test.entity.CourseEntity; | |||||
import org.jeecgframework.poi.test.entity.StudentEntity; | |||||
import org.jeecgframework.poi.test.entity.TeacherEntity; | |||||
import org.junit.Before; | |||||
import org.junit.Test; | |||||
/** | |||||
* 关系导出测试 Created by JueYue on 14-4-19. | |||||
*/ | |||||
public class ExcelExportUtilIdTest { | |||||
List<CourseEntity> list = new ArrayList<CourseEntity>(); | |||||
List<TeacherEntity> telist = new ArrayList<TeacherEntity>(); | |||||
CourseEntity courseEntity; | |||||
@Before | |||||
public void testBefor2() { | |||||
TeacherEntity teacherEntity = new TeacherEntity(); | |||||
teacherEntity.setId("12132131231231231"); | |||||
teacherEntity.setName("你们"); | |||||
for (int i = 0; i < 3; i++) { | |||||
telist.add(teacherEntity); | |||||
} | |||||
} | |||||
@Before | |||||
public void testBefore() { | |||||
courseEntity = new CourseEntity(); | |||||
courseEntity.setId("1131"); | |||||
courseEntity.setName("小白"); | |||||
TeacherEntity teacherEntity = new TeacherEntity(); | |||||
teacherEntity.setId("12131231"); | |||||
teacherEntity.setName("你们"); | |||||
courseEntity.setTeacher(teacherEntity); | |||||
StudentEntity studentEntity = new StudentEntity(); | |||||
studentEntity.setId("11231"); | |||||
studentEntity.setName("撒旦法司法局"); | |||||
studentEntity.setBirthday(new Date()); | |||||
studentEntity.setRegistrationDate(new java.sql.Time(new Date().getTime())); | |||||
studentEntity.setSex(1); | |||||
List<StudentEntity> studentList = new ArrayList<StudentEntity>(); | |||||
studentList.add(studentEntity); | |||||
studentList.add(studentEntity); | |||||
courseEntity.setStudents(studentList); | |||||
for (int i = 0; i < 3; i++) { | |||||
list.add(courseEntity); | |||||
} | |||||
} | |||||
/** | |||||
* 单行表头导出测试 | |||||
* | |||||
* @throws Exception | |||||
*/ | |||||
@Test | |||||
public void testExportExcel() throws Exception { | |||||
ExportParams params = new ExportParams("2412312", "测试", "测试"); | |||||
Workbook workbook = ExcelExportUtil.exportExcel(params, CourseEntity.class, list); | |||||
FileOutputStream fos = new FileOutputStream("d:/tt.xls"); | |||||
workbook.write(fos); | |||||
fos.close(); | |||||
} | |||||
} |
@@ -1,151 +0,0 @@ | |||||
package org.jeecgframework.poi.test.excel.test; | |||||
import java.io.File; | |||||
import java.io.FileOutputStream; | |||||
import java.util.ArrayList; | |||||
import java.util.Date; | |||||
import java.util.HashMap; | |||||
import java.util.List; | |||||
import org.apache.poi.ss.usermodel.Workbook; | |||||
import org.jeecgframework.poi.excel.ExcelExportUtil; | |||||
import org.jeecgframework.poi.excel.entity.ExportParams; | |||||
import org.jeecgframework.poi.excel.entity.TemplateExportParams; | |||||
import org.jeecgframework.poi.excel.entity.enmus.ExcelType; | |||||
import org.jeecgframework.poi.test.entity.CourseEntity; | |||||
import org.jeecgframework.poi.test.entity.StudentEntity; | |||||
import org.jeecgframework.poi.test.entity.TeacherEntity; | |||||
import org.junit.Before; | |||||
import org.junit.Test; | |||||
/** | |||||
* Created by jue on 14-4-19. | |||||
*/ | |||||
public class ExcelExportUtilTest { | |||||
List<CourseEntity> list = new ArrayList<CourseEntity>(); | |||||
CourseEntity courseEntity; | |||||
/** | |||||
* 25W行导出测试 | |||||
* | |||||
* @throws Exception | |||||
*/ | |||||
@Test | |||||
public void oneHundredThousandRowTest() throws Exception { | |||||
ExportParams params = new ExportParams("2412312", "测试", ExcelType.XSSF); | |||||
Date start = new Date(); | |||||
Workbook workbook = ExcelExportUtil.exportExcel(params, CourseEntity.class, list); | |||||
System.out.println(new Date().getTime() - start.getTime()); | |||||
File savefile = new File("d:/"); | |||||
if (!savefile.exists()) { | |||||
savefile.mkdirs(); | |||||
} | |||||
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(); | |||||
} | |||||
@Before | |||||
public void testBefore() { | |||||
for (int i = 0; i < 20000; i++) { | |||||
courseEntity = new CourseEntity(); | |||||
courseEntity.setId("1131"); | |||||
courseEntity.setName("海贼王必修(" + (i + 1) + ")"); | |||||
TeacherEntity teacherEntity = new TeacherEntity(); | |||||
teacherEntity.setId("12131231"); | |||||
teacherEntity.setName("路飞"); | |||||
courseEntity.setTeacher(teacherEntity); | |||||
teacherEntity = new TeacherEntity(); | |||||
teacherEntity.setId("121312314312421131"); | |||||
teacherEntity.setName("老王"); | |||||
courseEntity.setShuxueteacher(teacherEntity); | |||||
StudentEntity studentEntity = new StudentEntity(); | |||||
studentEntity.setId("11231"); | |||||
studentEntity.setName("撒旦法司法局"); | |||||
studentEntity.setBirthday(new Date()); | |||||
studentEntity.setSex(1); | |||||
List<StudentEntity> studentList = new ArrayList<StudentEntity>(); | |||||
studentList.add(studentEntity); | |||||
studentList.add(studentEntity); | |||||
courseEntity.setStudents(studentList); | |||||
list.add(courseEntity); | |||||
} | |||||
} | |||||
/** | |||||
* 基本导出测试 | |||||
* | |||||
* @throws Exception | |||||
*/ | |||||
//@Test | |||||
public void testExportExcel() throws Exception { | |||||
Date start = new Date(); | |||||
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("2412312", "测试", "测试"), | |||||
CourseEntity.class, list); | |||||
System.out.println(new Date().getTime() - start.getTime()); | |||||
File savefile = new File("d:/"); | |||||
if (!savefile.exists()) { | |||||
savefile.mkdirs(); | |||||
} | |||||
FileOutputStream fos = new FileOutputStream("d:/tt.xls"); | |||||
workbook.write(fos); | |||||
fos.close(); | |||||
} | |||||
/** | |||||
* 单行表头测试 | |||||
* | |||||
* @throws Exception | |||||
*/ | |||||
//@Test | |||||
public void testExportTitleExcel() throws Exception { | |||||
Date start = new Date(); | |||||
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("2412312", "测试"), | |||||
CourseEntity.class, list); | |||||
System.out.println(new Date().getTime() - start.getTime()); | |||||
File savefile = new File("d:/"); | |||||
if (!savefile.exists()) { | |||||
savefile.mkdirs(); | |||||
} | |||||
FileOutputStream fos = new FileOutputStream("d:/tt.xls"); | |||||
workbook.write(fos); | |||||
fos.close(); | |||||
} | |||||
/** | |||||
* 模板导出测试 | |||||
* | |||||
* @throws Exception | |||||
*/ | |||||
//@Test | |||||
public void testTempExportExcel() throws Exception { | |||||
TemplateExportParams params = new TemplateExportParams(); | |||||
params.setHeadingRows(2); | |||||
params.setHeadingStartRow(2); | |||||
params.setTemplateUrl("tt.xls"); | |||||
Workbook book = ExcelExportUtil.exportExcel(params, CourseEntity.class, list, | |||||
new HashMap<String, Object>()); | |||||
File savefile = new File("d:/"); | |||||
if (!savefile.exists()) { | |||||
savefile.mkdirs(); | |||||
} | |||||
FileOutputStream fos = new FileOutputStream("d:/t_tt.xls"); | |||||
book.write(fos); | |||||
fos.close(); | |||||
} | |||||
} |
@@ -1,69 +0,0 @@ | |||||
package org.jeecgframework.poi.test.read; | |||||
import java.io.File; | |||||
import java.io.FileInputStream; | |||||
import java.io.FileNotFoundException; | |||||
import java.util.Date; | |||||
import java.util.List; | |||||
import java.util.Map; | |||||
import org.apache.commons.lang3.StringUtils; | |||||
import org.apache.commons.lang3.builder.ReflectionToStringBuilder; | |||||
import org.jeecgframework.poi.excel.ExcelImportUtil; | |||||
import org.jeecgframework.poi.excel.entity.ImportParams; | |||||
import org.jeecgframework.poi.test.entity.CourseEntity; | |||||
import org.jeecgframework.poi.test.entity.MsgClient; | |||||
import org.jeecgframework.poi.test.entity.TestEntity; | |||||
import org.jeecgframework.poi.test.entity.statistics.StatisticEntity; | |||||
import org.junit.Test; | |||||
public class ExcelImportUtilTest { | |||||
///ExcelExportMsgClient 测试是这个到处的数据 | |||||
//@Test | |||||
public void test() { | |||||
try { | |||||
ImportParams params = new ImportParams(); | |||||
params.setTitleRows(1); | |||||
long start = new Date().getTime(); | |||||
List<StatisticEntity> list = ExcelImportUtil.importExcelBySax(new FileInputStream( | |||||
new File("d:/tt.xlsx")), StatisticEntity.class, params); | |||||
// List<StatisticEntity> list = ExcelImportUtil.importExcelBySax(new File("d:/tt.xlsx"), | |||||
// StatisticEntity.class, params); | |||||
/*for (int i = 0; i < list.size(); i++) { | |||||
System.out.println(ReflectionToStringBuilder.toString(list.get(i))); | |||||
}*/ | |||||
System.out.println(list.size() + "-----" + (new Date().getTime() - start)); | |||||
} catch (FileNotFoundException e) { | |||||
// TODO Auto-generated catch block | |||||
e.printStackTrace(); | |||||
} | |||||
} | |||||
@Test | |||||
public void test2() { | |||||
ImportParams params = new ImportParams(); | |||||
params.setTitleRows(1); | |||||
params.setHeadRows(1); | |||||
long start = new Date().getTime(); | |||||
List<MsgClient> list = ExcelImportUtil.importExcel(new File("d:/tt.xlsx"), MsgClient.class, | |||||
params); | |||||
System.out.println(new Date().getTime() - start); | |||||
System.out.println(list.size()); | |||||
System.out.println(ReflectionToStringBuilder.toString(list.get(0))); | |||||
} | |||||
@Test | |||||
public void testMapImport() { | |||||
ImportParams params = new ImportParams(); | |||||
params.setTitleRows(1); | |||||
params.setHeadRows(1); | |||||
long start = new Date().getTime(); | |||||
List<Map<String, Object>> list = ExcelImportUtil.importExcel(new File("d:/tt.xlsx"), | |||||
Map.class, params); | |||||
System.out.println(new Date().getTime() - start); | |||||
System.out.println(list.size()); | |||||
System.out.println(list.get(0)); | |||||
} | |||||
} |
@@ -1,117 +0,0 @@ | |||||
package org.jeecgframework.poi.test.word; | |||||
import java.io.FileOutputStream; | |||||
import java.text.SimpleDateFormat; | |||||
import java.util.ArrayList; | |||||
import java.util.Date; | |||||
import java.util.HashMap; | |||||
import java.util.List; | |||||
import java.util.Map; | |||||
import org.apache.poi.xwpf.usermodel.XWPFDocument; | |||||
import org.jeecgframework.poi.test.entity.CourseEntity; | |||||
import org.jeecgframework.poi.test.entity.StudentEntity; | |||||
import org.jeecgframework.poi.test.entity.TeacherEntity; | |||||
import org.jeecgframework.poi.test.word.entity.Person; | |||||
import org.jeecgframework.poi.word.WordExportUtil; | |||||
import org.jeecgframework.poi.word.entity.params.ExcelListEntity; | |||||
import org.junit.Before; | |||||
import org.junit.Test; | |||||
/** | |||||
* 注解导出测试 | |||||
* | |||||
* @author JueYue | |||||
* @date 2014年8月9日 下午11:36:33 | |||||
*/ | |||||
public class WordExportUtilAnnExcelTest { | |||||
private static SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd"); | |||||
List<CourseEntity> list = new ArrayList<CourseEntity>(); | |||||
CourseEntity courseEntity; | |||||
/** | |||||
* 简单导出没有图片和Excel | |||||
*/ | |||||
@Test | |||||
public void SimpleWordExport() { | |||||
Map<String, Object> map = new HashMap<String, Object>(); | |||||
map.put("department", "Jeecg"); | |||||
map.put("person", "JueYue"); | |||||
map.put("auditPerson", "JueYue"); | |||||
map.put("time", format.format(new Date())); | |||||
List<Person> list = new ArrayList<Person>(); | |||||
Person p = new Person(); | |||||
p.setName("小明"); | |||||
p.setTel("18711111111"); | |||||
p.setEmail("18711111111@139.com"); | |||||
list.add(p); | |||||
p = new Person(); | |||||
p.setName("小红"); | |||||
p.setTel("18711111112"); | |||||
p.setEmail("18711111112@139.com"); | |||||
list.add(p); | |||||
map.put("pList", new ExcelListEntity(list, Person.class)); | |||||
try { | |||||
XWPFDocument doc = WordExportUtil.exportWord07( | |||||
"org/jeecgframework/poi/test/word/doc/SimpleExcel.docx", map); | |||||
FileOutputStream fos = new FileOutputStream("d:/simpleExcel.docx"); | |||||
doc.write(fos); | |||||
fos.close(); | |||||
} catch (Exception e) { | |||||
e.printStackTrace(); | |||||
} | |||||
} | |||||
@Before | |||||
public void testBefore() { | |||||
courseEntity = new CourseEntity(); | |||||
courseEntity.setId("1131"); | |||||
courseEntity.setName("小白"); | |||||
TeacherEntity teacherEntity = new TeacherEntity(); | |||||
teacherEntity.setId("12131231"); | |||||
teacherEntity.setName("你们"); | |||||
courseEntity.setTeacher(teacherEntity); | |||||
teacherEntity = new TeacherEntity(); | |||||
teacherEntity.setId("121312314312421131"); | |||||
teacherEntity.setName("老王"); | |||||
courseEntity.setShuxueteacher(teacherEntity); | |||||
StudentEntity studentEntity = new StudentEntity(); | |||||
studentEntity.setId("11231"); | |||||
studentEntity.setName("撒旦法司法局"); | |||||
studentEntity.setBirthday(new Date()); | |||||
studentEntity.setSex(1); | |||||
List<StudentEntity> studentList = new ArrayList<StudentEntity>(); | |||||
studentList.add(studentEntity); | |||||
studentList.add(studentEntity); | |||||
courseEntity.setStudents(studentList); | |||||
for (int i = 0; i < 3; i++) { | |||||
list.add(courseEntity); | |||||
} | |||||
} | |||||
@Test | |||||
public void WordExport() { | |||||
Map<String, Object> map = new HashMap<String, Object>(); | |||||
map.put("department", "Jeecg"); | |||||
map.put("person", "JueYue"); | |||||
map.put("auditPerson", "JueYue"); | |||||
map.put("time", format.format(new Date())); | |||||
map.put("cs", new ExcelListEntity(list, CourseEntity.class)); | |||||
try { | |||||
XWPFDocument doc = WordExportUtil.exportWord07( | |||||
"org/jeecgframework/poi/test/word/doc/Excel.docx", map); | |||||
FileOutputStream fos = new FileOutputStream("d:/Excel.docx"); | |||||
doc.write(fos); | |||||
fos.close(); | |||||
} catch (Exception e) { | |||||
e.printStackTrace(); | |||||
} | |||||
} | |||||
} |
@@ -1,80 +0,0 @@ | |||||
package org.jeecgframework.poi.test.word; | |||||
import java.io.FileOutputStream; | |||||
import java.text.SimpleDateFormat; | |||||
import java.util.ArrayList; | |||||
import java.util.Date; | |||||
import java.util.HashMap; | |||||
import java.util.List; | |||||
import java.util.Map; | |||||
import org.apache.poi.xwpf.usermodel.XWPFDocument; | |||||
import org.jeecgframework.poi.test.word.entity.Person; | |||||
import org.jeecgframework.poi.word.WordExportUtil; | |||||
import org.jeecgframework.poi.word.entity.WordImageEntity; | |||||
import org.junit.Test; | |||||
public class WordExportUtilBaseExcelTest { | |||||
private static SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd"); | |||||
/** | |||||
* 简单导出包含图片 | |||||
*/ | |||||
@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/test/word/img/testCode.png"); | |||||
image.setType(WordImageEntity.URL); | |||||
map.put("testCode", image); | |||||
try { | |||||
XWPFDocument doc = WordExportUtil.exportWord07( | |||||
"org/jeecgframework/poi/test/word/doc/Image.docx", map); | |||||
FileOutputStream fos = new FileOutputStream("d:/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", "Jeecg"); | |||||
map.put("person", "JueYue"); | |||||
map.put("auditPerson", "JueYue"); | |||||
map.put("time", format.format(new Date())); | |||||
List<Person> list = new ArrayList<Person>(); | |||||
Person p = new Person(); | |||||
p.setName("小明"); | |||||
p.setTel("18711111111"); | |||||
p.setEmail("18711111111@139.com"); | |||||
list.add(p); | |||||
p = new Person(); | |||||
p.setName("小红"); | |||||
p.setTel("18711111112"); | |||||
p.setEmail("18711111112@139.com"); | |||||
list.add(p); | |||||
map.put("pList", list); | |||||
try { | |||||
XWPFDocument doc = WordExportUtil.exportWord07( | |||||
"org/jeecgframework/poi/test/word/doc/SimpleExcel.docx", map); | |||||
FileOutputStream fos = new FileOutputStream("d:/simpleExcel.docx"); | |||||
doc.write(fos); | |||||
fos.close(); | |||||
} catch (Exception e) { | |||||
e.printStackTrace(); | |||||
} | |||||
} | |||||
} |
@@ -1,66 +0,0 @@ | |||||
package org.jeecgframework.poi.test.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.WordExportUtil; | |||||
import org.jeecgframework.poi.word.entity.WordImageEntity; | |||||
import org.junit.Test; | |||||
public class WordExportUtilTest { | |||||
private static SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd"); | |||||
/** | |||||
* 简单导出包含图片 | |||||
*/ | |||||
//@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/test/word/doc/Image.docx", map); | |||||
FileOutputStream fos = new FileOutputStream("d:/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", "Jeecg"); | |||||
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( | |||||
"org/jeecgframework/poi/test/word/doc/Simple.docx", map); | |||||
FileOutputStream fos = new FileOutputStream("d:/simple.docx"); | |||||
doc.write(fos); | |||||
fos.close(); | |||||
} catch (Exception e) { | |||||
e.printStackTrace(); | |||||
} | |||||
} | |||||
} |
@@ -1,43 +0,0 @@ | |||||
package org.jeecgframework.poi.test.word.entity; | |||||
import org.jeecgframework.poi.excel.annotation.Excel; | |||||
/** | |||||
* 测试人员类 | |||||
* @author JueYue | |||||
* @date 2014年7月26日 下午10:51:30 | |||||
*/ | |||||
public class Person { | |||||
@Excel(name = "姓名") | |||||
private String name; | |||||
@Excel(name = "手机") | |||||
private String tel; | |||||
@Excel(name = "Email") | |||||
private String email; | |||||
public String getEmail() { | |||||
return email; | |||||
} | |||||
public String getName() { | |||||
return name; | |||||
} | |||||
public String getTel() { | |||||
return tel; | |||||
} | |||||
public void setEmail(String email) { | |||||
this.email = email; | |||||
} | |||||
public void setName(String name) { | |||||
this.name = name; | |||||
} | |||||
public void setTel(String tel) { | |||||
this.tel = tel; | |||||
} | |||||
} |
@@ -1,103 +0,0 @@ | |||||
package org.jeecgframework.poi.util; | |||||
import static org.junit.Assert.*; | |||||
import java.util.Date; | |||||
import java.util.HashMap; | |||||
import java.util.Map; | |||||
import junit.framework.Assert; | |||||
import org.junit.Test; | |||||
public class PoiElUtilTest { | |||||
@Test | |||||
public void testEval() throws Exception { | |||||
Map<String, Object> map = new HashMap<String, Object>(); | |||||
map.put("jueyue", "jueyue"); | |||||
//length 测试 | |||||
Object obj = PoiElUtil.eval("le:(jueyue)", map); | |||||
Assert.assertEquals("6", obj); | |||||
//format date 测试 | |||||
map.put("date", new Date()); | |||||
obj = PoiElUtil.eval("fd:(date;yyyy-MM-dd)", map); | |||||
System.out.println(obj); | |||||
obj = PoiElUtil.eval("fd:(date;yyyy-MM-dd HH:mm:ss)", map); | |||||
System.out.println(obj); | |||||
obj = PoiElUtil.eval("fd:(date;yyyy-MM-dd HH:mm)", map); | |||||
System.out.println(obj); | |||||
obj = PoiElUtil.eval("fd:(date;yyyy/MM/dd HH:mm:ss)", map); | |||||
System.out.println(obj); | |||||
map.put("date2", new Date().getTime()); | |||||
obj = PoiElUtil.eval("fd:(date2;yyyy-MM-dd)", map); | |||||
System.out.println(obj); | |||||
obj = PoiElUtil.eval("fd:(date2;yyyy-MM-dd HH:mm:ss)", map); | |||||
System.out.println(obj); | |||||
obj = PoiElUtil.eval("fd:(date2;yyyy-MM-dd HH:mm)", map); | |||||
System.out.println(obj); | |||||
obj = PoiElUtil.eval("fd:(date2;yyyy/MM/dd HH:mm:ss)", map); | |||||
System.out.println(obj); | |||||
//format number 测试 | |||||
map.put("number", 213123123123.34234234); | |||||
obj = PoiElUtil.eval("fn:(number;###.00)", map); | |||||
System.out.println(obj); | |||||
obj = PoiElUtil.eval("fn:(number;###.0)", map); | |||||
System.out.println(obj); | |||||
obj = PoiElUtil.eval("fn:(number;#,###.0)", map); | |||||
System.out.println(obj); | |||||
// !if 测试 | |||||
obj = PoiElUtil.eval("!if:(le:(jueyue) == '6')", map); | |||||
Assert.assertEquals(obj, true); | |||||
obj = PoiElUtil.eval("!if:(fd:(date2;yyyy-MM-dd) == '2015-04-25')", map); | |||||
Assert.assertEquals(obj, true); | |||||
obj = PoiElUtil.eval("!if:(fn:(number;###.0) > '3')", map); | |||||
Assert.assertEquals(obj, true); | |||||
map.put("key1", "测试1"); | |||||
//三目运算 | |||||
obj = PoiElUtil.eval("'6' == '6' ? 'jueyue' : '小明'", map); | |||||
Assert.assertEquals(obj, "jueyue"); | |||||
obj = PoiElUtil.eval("le:(jueyue) == '6' ? 'jueyue' : '小明'", map); | |||||
Assert.assertEquals(obj, "jueyue"); | |||||
obj = PoiElUtil.eval("'6' == le:(jueyue) ? 'jueyue' : '小明'", map); | |||||
Assert.assertEquals(obj, "jueyue"); | |||||
obj = PoiElUtil.eval("'6' == le:(jueyue) ? fd:(date;yyyy-MM-dd) : '小明'", map); | |||||
Assert.assertEquals(obj, "2015-04-25"); | |||||
obj = PoiElUtil.eval("'6' != le:(jueyue) ? '小明' : fd:(date;yyyy-MM-dd)", map); | |||||
Assert.assertEquals(obj, "2015-04-25"); | |||||
obj = PoiElUtil.eval("jueyue == 'jueyue' ? key1 : '小明'", map); | |||||
Assert.assertEquals(obj, "测试1"); | |||||
map.put("key1", "100"); | |||||
map.put("key2", "200"); | |||||
obj = PoiElUtil.eval("key1 == key2 ? key1 : '小明'", map); | |||||
Assert.assertEquals(obj, "小明"); | |||||
obj = PoiElUtil.eval("key1 < key2 ? key1 : '小明'", map); | |||||
Assert.assertEquals(obj, "100"); | |||||
obj = PoiElUtil.eval("key2 > key1 ? key1 : '小明'", map); | |||||
Assert.assertEquals(obj, "100"); | |||||
map.put("key1", "你好"); | |||||
obj = PoiElUtil.eval("key1 == '你好' ? '不好' : '小明'", map); | |||||
Assert.assertEquals(obj, "不好"); | |||||
} | |||||
} |
@@ -1,11 +0,0 @@ | |||||
log4j.rootLogger=debug,A1,R | |||||
log4j.appender.A1=org.apache.log4j.ConsoleAppender | |||||
log4j.appender.A1.Target=System.out | |||||
log4j.appender.A1.layout=org.apache.log4j.PatternLayout | |||||
log4j.appender.A1.layout.ConversionPattern=[%c]%m%n | |||||
log4j.appender.R=org.apache.log4j.RollingFileAppender | |||||
log4j.appender.R.File=/home/logs/easypoi.info | |||||
log4j.appender.R.MaxFileSize=10MB | |||||
log4j.appender.R.layout=org.apache.log4j.PatternLayout | |||||
log4j.appender.R.layout.ConversionPattern=[%p][%d{yyyy-MM-dd HH\:mm\:ss,SSS}][%c]%m%n |
@@ -2,9 +2,9 @@ | |||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||||
<modelVersion>4.0.0</modelVersion> | <modelVersion>4.0.0</modelVersion> | ||||
<parent> | <parent> | ||||
<groupId>org.jeecgframework</groupId> | |||||
<groupId>org.jeecg</groupId> | |||||
<artifactId>easypoi</artifactId> | <artifactId>easypoi</artifactId> | ||||
<version>2.1.2-SNAPSHOT</version> | |||||
<version>2.2.0-SNAPSHOT</version> | |||||
</parent> | </parent> | ||||
<artifactId>easypoi-web</artifactId> | <artifactId>easypoi-web</artifactId> | ||||
<dependencies> | <dependencies> | ||||
@@ -29,7 +29,7 @@ | |||||
</dependency> | </dependency> | ||||
<dependency> | <dependency> | ||||
<groupId>org.jeecgframework</groupId> | |||||
<groupId>org.jeecg</groupId> | |||||
<artifactId>easypoi-base</artifactId> | <artifactId>easypoi-base</artifactId> | ||||
</dependency> | </dependency> | ||||
</dependencies> | </dependencies> |
@@ -1,37 +1,49 @@ | |||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||||
<modelVersion>4.0.0</modelVersion> | <modelVersion>4.0.0</modelVersion> | ||||
<groupId>org.jeecgframework</groupId> | |||||
<groupId>org.jeecg</groupId> | |||||
<artifactId>easypoi</artifactId> | <artifactId>easypoi</artifactId> | ||||
<version>2.1.2-SNAPSHOT</version> | |||||
<version>2.2.0-SNAPSHOT</version> | |||||
<packaging>pom</packaging> | <packaging>pom</packaging> | ||||
<name>easypoi</name> | <name>easypoi</name> | ||||
<modules> | <modules> | ||||
<module>easypoi-base</module> | <module>easypoi-base</module> | ||||
<module>easypoi-web</module> | <module>easypoi-web</module> | ||||
<module>easypoi-test</module> | |||||
<module>easypoi-annotation</module> | <module>easypoi-annotation</module> | ||||
</modules> | </modules> | ||||
<url>www.jeecg.org</url> | |||||
<url>http://git.oschina.net/jueyue/easypoi</url> | |||||
<description> office 工具类 基于 poi</description> | <description> office 工具类 基于 poi</description> | ||||
<licenses> | |||||
<license> | |||||
<name>The Apache License, Version 2.0</name> | |||||
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url> | |||||
</license> | |||||
</licenses> | |||||
<scm> | |||||
<developerConnection>scm:https://git.oschina.net/jueyue/easypoi.git</developerConnection> | |||||
<connection>scm:https://git.oschina.net/jueyue/easypoi.git</connection> | |||||
</scm> | |||||
<developers> | <developers> | ||||
<developer> | <developer> | ||||
<name>JueYue</name> | <name>JueYue</name> | ||||
<email>qrb.jueyue@gmail.com</email> | <email>qrb.jueyue@gmail.com</email> | ||||
<organization>Jeecg</organization> | |||||
<organizationUrl>http://www.jeecg.org</organizationUrl> | |||||
</developer> | </developer> | ||||
</developers> | </developers> | ||||
<properties> | <properties> | ||||
<sub.version>2.1.2-SNAPSHOT</sub.version> | |||||
<sub.version>2.2.0-SNAPSHOT</sub.version> | |||||
<poi.version>3.9</poi.version> | <poi.version>3.9</poi.version> | ||||
<xerces.version>2.9.1</xerces.version> | <xerces.version>2.9.1</xerces.version> | ||||
<guava.version>16.0.1</guava.version> | <guava.version>16.0.1</guava.version> | ||||
<commons-lang.version>3.2.1</commons-lang.version> | <commons-lang.version>3.2.1</commons-lang.version> | ||||
<slf4j.version>1.6.1</slf4j.version> | <slf4j.version>1.6.1</slf4j.version> | ||||
<spring.version>3.1.1.RELEASE</spring.version> | <spring.version>3.1.1.RELEASE</spring.version> | ||||
<junit.version>4.7</junit.version> | |||||
</properties> | </properties> | ||||
<dependencyManagement> | <dependencyManagement> | ||||
<dependencies> | <dependencies> | ||||
@@ -46,7 +58,7 @@ | |||||
<artifactId>poi-ooxml</artifactId> | <artifactId>poi-ooxml</artifactId> | ||||
<version>${poi.version}</version> | <version>${poi.version}</version> | ||||
</dependency> | </dependency> | ||||
<dependency> | <dependency> | ||||
<groupId>org.apache.poi</groupId> | <groupId>org.apache.poi</groupId> | ||||
<artifactId>poi-ooxml-schemas</artifactId> | <artifactId>poi-ooxml-schemas</artifactId> | ||||
@@ -118,22 +130,14 @@ | |||||
<optional>true</optional> | <optional>true</optional> | ||||
</dependency> | </dependency> | ||||
<!-- test --> | |||||
<dependency> | |||||
<groupId>junit</groupId> | |||||
<artifactId>junit</artifactId> | |||||
<version>${junit.version}</version> | |||||
<scope>test</scope> | |||||
</dependency> | |||||
<!-- 模块版本 --> | <!-- 模块版本 --> | ||||
<dependency> | <dependency> | ||||
<groupId>org.jeecgframework</groupId> | |||||
<groupId>org.jeecg</groupId> | |||||
<artifactId>easypoi-base</artifactId> | <artifactId>easypoi-base</artifactId> | ||||
<version>${sub.version}</version> | <version>${sub.version}</version> | ||||
</dependency> | </dependency> | ||||
<dependency> | <dependency> | ||||
<groupId>org.jeecgframework</groupId> | |||||
<groupId>org.jeecg</groupId> | |||||
<artifactId>easypoi-annotation</artifactId> | <artifactId>easypoi-annotation</artifactId> | ||||
<version>${sub.version}</version> | <version>${sub.version}</version> | ||||
</dependency> | </dependency> | ||||
@@ -143,41 +147,93 @@ | |||||
<build> | <build> | ||||
<plugins> | <plugins> | ||||
<plugin> | <plugin> | ||||
<groupId>org.sonatype.plugins</groupId> | |||||
<artifactId>nexus-staging-maven-plugin</artifactId> | |||||
<version>1.6.5</version> | |||||
<configuration> | |||||
<serverId>ossrh</serverId> | |||||
<nexusUrl>https://oss.sonatype.org/</nexusUrl> | |||||
<autoReleaseAfterClose>true</autoReleaseAfterClose> | |||||
</configuration> | |||||
</plugin> | |||||
<plugin> | |||||
<groupId>org.apache.maven.plugins</groupId> | |||||
<artifactId>maven-release-plugin</artifactId> | |||||
<version>2.5</version> | |||||
<configuration> | |||||
<autoVersionSubmodules>true</autoVersionSubmodules> | |||||
<useReleaseProfile>false</useReleaseProfile> | |||||
<releaseProfiles>release</releaseProfiles> | |||||
<goals>deploy</goals> | |||||
</configuration> | |||||
</plugin> | |||||
<plugin> | |||||
<groupId>org.apache.maven.plugins</groupId> | |||||
<artifactId>maven-compiler-plugin</artifactId> | <artifactId>maven-compiler-plugin</artifactId> | ||||
<version>2.3.2</version> | |||||
<version>3.0</version> | |||||
<configuration> | <configuration> | ||||
<source>1.6</source> | <source>1.6</source> | ||||
<target>1.6</target> | <target>1.6</target> | ||||
<showWarnings>true</showWarnings> | |||||
<encoding>UTF-8</encoding> | <encoding>UTF-8</encoding> | ||||
</configuration> | </configuration> | ||||
</plugin> | </plugin> | ||||
<plugin> | <plugin> | ||||
<groupId>org.apache.maven.plugins</groupId> | |||||
<artifactId>maven-gpg-plugin</artifactId> | |||||
<version>1.5</version> | |||||
<executions> | |||||
<execution> | |||||
<id>sign-artifacts</id> | |||||
<phase>verify</phase> | |||||
<goals> | |||||
<goal>sign</goal> | |||||
</goals> | |||||
</execution> | |||||
</executions> | |||||
</plugin> | |||||
<plugin> | |||||
<groupId>org.apache.maven.plugins</groupId> | |||||
<artifactId>maven-source-plugin</artifactId> | <artifactId>maven-source-plugin</artifactId> | ||||
<version>2.1</version> | |||||
<version>2.2.1</version> | |||||
<executions> | |||||
<execution> | |||||
<id>attach-sources</id> | |||||
<goals> | |||||
<goal>jar-no-fork</goal> | |||||
</goals> | |||||
</execution> | |||||
</executions> | |||||
<configuration> | <configuration> | ||||
<attach>true</attach> | |||||
<encoding>UTF-8</encoding> | |||||
</configuration> | </configuration> | ||||
</plugin> | |||||
<plugin> | |||||
<groupId>org.apache.maven.plugins</groupId> | |||||
<artifactId>maven-javadoc-plugin</artifactId> | |||||
<version>2.9</version> | |||||
<executions> | <executions> | ||||
<execution> | <execution> | ||||
<phase>compile</phase> | |||||
<id>attach-javadocs</id> | |||||
<goals> | <goals> | ||||
<goal>jar</goal> | <goal>jar</goal> | ||||
</goals> | </goals> | ||||
</execution> | </execution> | ||||
</executions> | </executions> | ||||
<configuration> | |||||
<encoding>UTF-8</encoding> | |||||
</configuration> | |||||
</plugin> | </plugin> | ||||
</plugins> | </plugins> | ||||
</build> | </build> | ||||
<distributionManagement> | <distributionManagement> | ||||
<repository> | <repository> | ||||
<id>postaop-common-release</id> | |||||
<url>http://172.16.100.99:8081/nexus/content/repositories/postaop-common-release/</url> | |||||
<id>oss-release</id> | |||||
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url> | |||||
</repository> | </repository> | ||||
<snapshotRepository> | <snapshotRepository> | ||||
<id>postaop-common-snapshot</id> | |||||
<url>http://172.16.100.99:8081/nexus/content/repositories/postaop-common-snapshot/</url> | |||||
<id>oss-snapshot</id> | |||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url> | |||||
</snapshotRepository> | </snapshotRepository> | ||||
</distributionManagement> | </distributionManagement> | ||||