@@ -112,4 +112,10 @@ public @interface Excel { | |||||
* @return | * @return | ||||
*/ | */ | ||||
public boolean isStatistics() default false; | public boolean isStatistics() default false; | ||||
/** | |||||
* 冰冻列 | |||||
* @return | |||||
*/ | |||||
public boolean isFreeze() default false; | |||||
} | } |
@@ -27,7 +27,7 @@ | |||||
</dependency> | </dependency> | ||||
<dependency> | <dependency> | ||||
<groupId>xerces</groupId> | <groupId>xerces</groupId> | ||||
<artifactId>xerces</artifactId> | |||||
<artifactId>xercesImpl</artifactId> | |||||
</dependency> | </dependency> | ||||
<!-- google 工具类 --> | <!-- google 工具类 --> | ||||
@@ -58,6 +58,10 @@ public class ExcelExportEntity extends ExcelBaseEntity { | |||||
* 统计 | * 统计 | ||||
*/ | */ | ||||
private boolean isStatistics; | private boolean isStatistics; | ||||
/** | |||||
* 统计 | |||||
*/ | |||||
private boolean isFreeze; | |||||
private List<ExcelExportEntity> list; | private List<ExcelExportEntity> list; | ||||
@@ -184,4 +188,12 @@ public class ExcelExportEntity extends ExcelBaseEntity { | |||||
this.isStatistics = isStatistics; | this.isStatistics = isStatistics; | ||||
} | } | ||||
public boolean isFreeze() { | |||||
return isFreeze; | |||||
} | |||||
public void setFreeze(boolean isFreeze) { | |||||
this.isFreeze = isFreeze; | |||||
} | |||||
} | } |
@@ -140,6 +140,11 @@ public class ExcelExportServer extends ExcelExportBase { | |||||
break; | break; | ||||
} | } | ||||
mergeCells(sheet, excelParams, titleHeight); | mergeCells(sheet, excelParams, titleHeight); | ||||
for (int i = 0; i < excelParams.size(); i++) { | |||||
if (excelParams.get(i).isFreeze()) { | |||||
sheet.createFreezePane(i + 1, 0, i + 1, 0); | |||||
} | |||||
} | |||||
its = dataSet.iterator(); | its = dataSet.iterator(); | ||||
for (int i = 0, le = tempList.size(); i < le; i++) { | for (int i = 0, le = tempList.size(); i < le; i++) { | ||||
@@ -204,6 +204,7 @@ public class ExportBase { | |||||
excelEntity.setFormat(StringUtils.isNotEmpty(excel.exportFormat()) ? excel.exportFormat() | excelEntity.setFormat(StringUtils.isNotEmpty(excel.exportFormat()) ? excel.exportFormat() | ||||
: excel.format()); | : excel.format()); | ||||
excelEntity.setStatistics(excel.isStatistics()); | excelEntity.setStatistics(excel.isStatistics()); | ||||
excelEntity.setFreeze(excel.isFreeze()); | |||||
String fieldname = field.getName(); | String fieldname = field.getName(); | ||||
excelEntity.setMethod(POIPublicUtil.getMethod(fieldname, pojoClass)); | excelEntity.setMethod(POIPublicUtil.getMethod(fieldname, pojoClass)); | ||||
} | } | ||||
@@ -1,13 +1,13 @@ | |||||
<?xml version="1.0" encoding="UTF-8"?> | <?xml version="1.0" encoding="UTF-8"?> | ||||
<classpath> | <classpath> | ||||
<classpathentry kind="src" output="target/test-classes" path="src/main/java"> | |||||
<classpathentry kind="src" output="target/classes" path="src/main/java"> | |||||
<attributes> | <attributes> | ||||
<attribute name="optional" value="true"/> | <attribute name="optional" value="true"/> | ||||
<attribute name="maven.pomderived" value="true"/> | <attribute name="maven.pomderived" value="true"/> | ||||
</attributes> | </attributes> | ||||
</classpathentry> | </classpathentry> | ||||
<classpathentry kind="src" path="src/test"/> | <classpathentry kind="src" path="src/test"/> | ||||
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/main/resources"> | |||||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"> | |||||
<attributes> | <attributes> | ||||
<attribute name="maven.pomderived" value="true"/> | <attribute name="maven.pomderived" value="true"/> | ||||
</attributes> | </attributes> | ||||
@@ -22,5 +22,5 @@ | |||||
<attribute name="maven.pomderived" value="true"/> | <attribute name="maven.pomderived" value="true"/> | ||||
</attributes> | </attributes> | ||||
</classpathentry> | </classpathentry> | ||||
<classpathentry kind="output" path="target/classes"/> | |||||
<classpathentry kind="output" path="target/test-classes"/> | |||||
</classpath> | </classpath> |
@@ -18,7 +18,7 @@ public class MsgClient implements java.io.Serializable { | |||||
/** id */ | /** id */ | ||||
private java.lang.String id; | private java.lang.String id; | ||||
// 电话号码(主键) | // 电话号码(主键) | ||||
@Excel(name = "电话号码") | |||||
@Excel(name = "电话号码", isFreeze = true) | |||||
private String clientPhone = null; | private String clientPhone = null; | ||||
// 客户姓名 | // 客户姓名 | ||||
@Excel(name = "姓名") | @Excel(name = "姓名") | ||||
@@ -18,7 +18,7 @@ public class TeacherEntity implements java.io.Serializable { | |||||
@Excel(name = "老师ID_teacherEntity,老师属性_courseEntity", orderNum = "2", needMerge = false) | @Excel(name = "老师ID_teacherEntity,老师属性_courseEntity", orderNum = "2", needMerge = false) | ||||
private String id; | private String id; | ||||
/** name */ | /** name */ | ||||
@Excel(name = "语文老师_yuwen,数学老师_shuxue", orderNum = "2", mergeVertical = true) | |||||
@Excel(name = "语文老师_yuwen,数学老师_shuxue", orderNum = "2", mergeVertical = true, isFreeze = true) | |||||
private String name; | private String name; | ||||
/* | /* | ||||
@@ -5,12 +5,14 @@ import static org.junit.Assert.*; | |||||
import java.io.File; | import java.io.File; | ||||
import java.io.FileNotFoundException; | import java.io.FileNotFoundException; | ||||
import java.io.FileOutputStream; | import java.io.FileOutputStream; | ||||
import java.lang.reflect.Field; | |||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.Date; | import java.util.Date; | ||||
import java.util.List; | import java.util.List; | ||||
import org.apache.poi.ss.usermodel.Workbook; | import org.apache.poi.ss.usermodel.Workbook; | ||||
import org.jeecgframework.poi.excel.ExcelExportUtil; | 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.ExportParams; | ||||
import org.jeecgframework.poi.excel.entity.enmus.ExcelType; | import org.jeecgframework.poi.excel.entity.enmus.ExcelType; | ||||
import org.jeecgframework.poi.excel.entity.vo.PoiBaseConstants; | import org.jeecgframework.poi.excel.entity.vo.PoiBaseConstants; | ||||
@@ -28,6 +30,12 @@ public class ExcelExportMsgClient { | |||||
@Test | @Test | ||||
public void test() throws Exception { | 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>(); | List<MsgClient> list = new ArrayList<MsgClient>(); | ||||
for (int i = 0; i < 50000; i++) { | for (int i = 0; i < 50000; i++) { | ||||
MsgClient client = new MsgClient(); | MsgClient client = new MsgClient(); | ||||
@@ -70,7 +70,6 @@ public class ExcelExportUtilIdTest { | |||||
@Test | @Test | ||||
public void testExportExcel() throws Exception { | public void testExportExcel() throws Exception { | ||||
ExportParams params = new ExportParams("2412312", "测试", "测试"); | ExportParams params = new ExportParams("2412312", "测试", "测试"); | ||||
params.setAddIndex(true); | |||||
Workbook workbook = ExcelExportUtil.exportExcel(params, CourseEntity.class, list); | Workbook workbook = ExcelExportUtil.exportExcel(params, CourseEntity.class, list); | ||||
FileOutputStream fos = new FileOutputStream("d:/tt.xls"); | FileOutputStream fos = new FileOutputStream("d:/tt.xls"); | ||||
workbook.write(fos); | workbook.write(fos); | ||||
@@ -26,7 +26,7 @@ | |||||
<properties> | <properties> | ||||
<sub.version>2.0.8-SNAPSHOT</sub.version> | <sub.version>2.0.8-SNAPSHOT</sub.version> | ||||
<poi.version>3.9</poi.version> | <poi.version>3.9</poi.version> | ||||
<xerces.version>2.4.0</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>2.6</commons-lang.version> | <commons-lang.version>2.6</commons-lang.version> | ||||
<slf4j.version>1.6.1</slf4j.version> | <slf4j.version>1.6.1</slf4j.version> | ||||
@@ -103,7 +103,7 @@ | |||||
</dependency> | </dependency> | ||||
<dependency> | <dependency> | ||||
<groupId>xerces</groupId> | <groupId>xerces</groupId> | ||||
<artifactId>xerces</artifactId> | |||||
<artifactId>xercesImpl</artifactId> | |||||
<version>${xerces.version}</version> | <version>${xerces.version}</version> | ||||
</dependency> | </dependency> | ||||