├── easypoi-base
├── .gitignore
├── .settings
│ ├── org.eclipse.m2e.core.prefs
│ ├── org.eclipse.core.resources.prefs
│ └── org.eclipse.jdt.core.prefs
├── src
│ └── main
│ │ └── java
│ │ └── org
│ │ └── jeecgframework
│ │ └── poi
│ │ ├── excel
│ │ ├── imports
│ │ │ ├── package-info.java
│ │ │ ├── sax
│ │ │ │ ├── parse
│ │ │ │ │ └── ISaxRowRead.java
│ │ │ │ ├── SaxReadExcel.java
│ │ │ │ └── SheetHandler.java
│ │ │ └── verifys
│ │ │ │ ├── VerifyHandlerServer.java
│ │ │ │ └── BaseVerifyHandler.java
│ │ ├── entity
│ │ │ ├── enmus
│ │ │ │ ├── ExcelType.java
│ │ │ │ ├── CellValueType.java
│ │ │ │ └── ExcelStyleType.java
│ │ │ ├── vo
│ │ │ │ └── PoiBaseConstants.java
│ │ │ ├── ExcelBaseParams.java
│ │ │ ├── params
│ │ │ │ ├── ExcelTemplateParams.java
│ │ │ │ ├── ExcelCollectionParams.java
│ │ │ │ ├── MergeEntity.java
│ │ │ │ ├── ExcelBaseEntity.java
│ │ │ │ ├── ExcelImportEntity.java
│ │ │ │ ├── ExcelVerifyEntity.java
│ │ │ │ └── ExcelExportEntity.java
│ │ │ ├── result
│ │ │ │ ├── ExcelVerifyHanlderResult.java
│ │ │ │ └── ExcelImportResult.java
│ │ │ ├── sax
│ │ │ │ └── SaxReadCellEntity.java
│ │ │ ├── ImportParams.java
│ │ │ ├── TemplateExportParams.java
│ │ │ └── ExportParams.java
│ │ ├── html
│ │ │ ├── helper
│ │ │ │ ├── excelStyle.css
│ │ │ │ ├── MergedRegionHelper.java
│ │ │ │ └── CellValueHelper.java
│ │ │ └── ExcelToHtmlServer.java
│ │ ├── ExcelToHtmlUtil.java
│ │ ├── export
│ │ │ └── styler
│ │ │ │ ├── IExcelExportStyler.java
│ │ │ │ ├── AbstractExcelExportStyler.java
│ │ │ │ ├── ExcelExportStylerDefaultImpl.java
│ │ │ │ ├── ExcelExportStylerBorderImpl.java
│ │ │ │ └── ExcelExportStylerColorImpl.java
│ │ ├── ExcelExportUtil.java
│ │ └── ExcelImportUtil.java
│ │ ├── handler
│ │ ├── package-info.java
│ │ ├── impl
│ │ │ ├── package-info.java
│ │ │ └── ExcelDataHandlerDefaultImpl.java
│ │ └── inter
│ │ │ ├── IExcelReadRowHanlder.java
│ │ │ ├── IExcelVerifyHandler.java
│ │ │ └── IExcelDataHandler.java
│ │ ├── cache
│ │ ├── package-info.java
│ │ ├── WordCache.java
│ │ ├── manager
│ │ │ ├── POICacheManager.java
│ │ │ └── FileLoade.java
│ │ └── ExcelCache.java
│ │ ├── package-info.java
│ │ ├── exception
│ │ ├── excel
│ │ │ ├── enums
│ │ │ │ ├── ExcelImportEnum.java
│ │ │ │ └── ExcelExportEnum.java
│ │ │ ├── ExcelImportException.java
│ │ │ └── ExcelExportException.java
│ │ └── word
│ │ │ ├── enmus
│ │ │ └── WordExportEnum.java
│ │ │ └── WordExportException.java
│ │ ├── word
│ │ ├── WordExportUtil.java
│ │ ├── entity
│ │ │ ├── params
│ │ │ │ ├── ListParamEntity.java
│ │ │ │ └── ExcelListEntity.java
│ │ │ ├── WordImageEntity.java
│ │ │ └── MyXWPFDocument.java
│ │ └── parse
│ │ │ └── excel
│ │ │ └── ExcelMapParse.java
│ │ └── util
│ │ ├── PoiSheetUtility.java
│ │ └── PoiFunctionUtil.java
├── .project
├── .classpath
└── pom.xml
├── easypoi-web
├── .gitignore
├── .settings
│ ├── org.eclipse.core.resources.prefs
│ ├── org.eclipse.m2e.core.prefs
│ └── org.eclipse.jdt.core.prefs
├── .project
├── .classpath
├── pom.xml
└── src
│ └── main
│ └── java
│ └── org
│ └── jeecgframework
│ └── poi
│ └── excel
│ ├── entity
│ └── vo
│ │ ├── BasePOIConstants.java
│ │ ├── NormalExcelConstants.java
│ │ ├── MapExcelConstants.java
│ │ ├── TemplateWordConstants.java
│ │ └── TemplateExcelConstants.java
│ └── view
│ ├── MiniAbstractExcelView.java
│ ├── JeecgTemplateWordView.java
│ ├── JeecgMapExcelView.java
│ ├── JeecgTemplateExcelView.java
│ └── JeecgSingleExcelView.java
├── install.bat
├── deploy.bat
├── .gitignore
├── .settings
└── org.eclipse.m2e.core.prefs
├── easypoi-annotation
├── .settings
│ ├── org.eclipse.m2e.core.prefs
│ ├── org.eclipse.core.resources.prefs
│ └── org.eclipse.jdt.core.prefs
├── pom.xml
├── .project
├── .classpath
└── src
│ └── main
│ └── java
│ └── org
│ └── jeecgframework
│ └── poi
│ └── excel
│ └── annotation
│ ├── ExcelIgnore.java
│ ├── ExcelTarget.java
│ ├── ExcelEntity.java
│ ├── ExcelCollection.java
│ ├── ExcelVerify.java
│ └── Excel.java
└── .project
/easypoi-base/.gitignore:
--------------------------------------------------------------------------------
1 | /target
2 |
--------------------------------------------------------------------------------
/easypoi-web/.gitignore:
--------------------------------------------------------------------------------
1 | /target
2 |
--------------------------------------------------------------------------------
/install.bat:
--------------------------------------------------------------------------------
1 | cmd /k mvn clean install -D skipTest
--------------------------------------------------------------------------------
/deploy.bat:
--------------------------------------------------------------------------------
1 | cmd /k mvn clean deploy -Dmaven.test.skip=true -Dgpg.passphrase=jeecg123456
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.class
2 |
3 | # Package Files #
4 | *.jar
5 | *.war
6 | *.ear
7 | target/
8 | deploy.bat
9 |
--------------------------------------------------------------------------------
/easypoi-web/.settings/org.eclipse.core.resources.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | encoding//src/main/java=UTF-8
3 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.m2e.core.prefs:
--------------------------------------------------------------------------------
1 | activeProfiles=cc-mzone-profile
2 | eclipse.preferences.version=1
3 | resolveWorkspaceProjects=true
4 | version=1
5 |
--------------------------------------------------------------------------------
/easypoi-base/.settings/org.eclipse.m2e.core.prefs:
--------------------------------------------------------------------------------
1 | activeProfiles=
2 | eclipse.preferences.version=1
3 | resolveWorkspaceProjects=true
4 | version=1
5 |
--------------------------------------------------------------------------------
/easypoi-web/.settings/org.eclipse.m2e.core.prefs:
--------------------------------------------------------------------------------
1 | activeProfiles=
2 | eclipse.preferences.version=1
3 | resolveWorkspaceProjects=true
4 | version=1
5 |
--------------------------------------------------------------------------------
/easypoi-annotation/.settings/org.eclipse.m2e.core.prefs:
--------------------------------------------------------------------------------
1 | activeProfiles=
2 | eclipse.preferences.version=1
3 | resolveWorkspaceProjects=true
4 | version=1
5 |
--------------------------------------------------------------------------------
/easypoi-base/.settings/org.eclipse.core.resources.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | encoding//src/main/java=UTF-8
3 | encoding//src/test/java=UTF-8
4 |
--------------------------------------------------------------------------------
/easypoi-annotation/.settings/org.eclipse.core.resources.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | encoding//src/main/java=UTF-8
3 | encoding//src/test/java=UTF-8
4 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/org/jeecgframework/poi/excel/imports/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * 导入类
3 | * @author JueYue
4 | * @date 2014年6月23日 下午11:05:59
5 | */
6 | package org.jeecgframework.poi.excel.imports;
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/org/jeecgframework/poi/handler/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * 数据处理中心,对导入导出进行数据处理
3 | * @author JueYue
4 | * @date 2014年6月20日 上午12:08:09
5 | */
6 | package org.jeecgframework.poi.handler;
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/org/jeecgframework/poi/handler/impl/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * 对接口的抽象的默认实现,避免用户实现过多方法
3 | * @author JueYue
4 | * @date 2014年6月20日 上午12:09:27
5 | */
6 | package org.jeecgframework.poi.handler.impl;
--------------------------------------------------------------------------------
/easypoi-base/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
3 | org.eclipse.jdt.core.compiler.compliance=1.6
4 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
5 | org.eclipse.jdt.core.compiler.source=1.6
6 |
--------------------------------------------------------------------------------
/easypoi-web/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
3 | org.eclipse.jdt.core.compiler.compliance=1.6
4 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
5 | org.eclipse.jdt.core.compiler.source=1.6
6 |
--------------------------------------------------------------------------------
/easypoi-annotation/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
3 | org.eclipse.jdt.core.compiler.compliance=1.6
4 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
5 | org.eclipse.jdt.core.compiler.source=1.6
6 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/org/jeecgframework/poi/cache/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * 对POI用到的模板进行缓存,进行统一管理,缓存工具暂时使用guava(脱离配置文件)
3 | * 缓存方式统一为byte[] 屏蔽文件类型的差异
4 | * 缓存获取方式,URL或者URL+index(EXcel的)
5 | */
6 | /**
7 | * @author JueYue
8 | * @date 2014年2月10日
9 | * @version 1.0
10 | */
11 | package org.jeecgframework.poi.cache;
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/org/jeecgframework/poi/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @author JueYue
3 | * @date 2014年2月10日
4 | * @version 1.0
5 | * 对POI进行封装,通过注解的使用,完成POI的简易重复操作
6 | * 通过模板完成较为复杂的操作
7 | * 进阶步骤:
8 | *
1.了解注解,图片类
9 | * 2.模板语言
10 | * 3.模板组合
11 | *
12 | */
13 | package org.jeecgframework.poi;
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | easypoi
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.m2e.core.maven2Builder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.m2e.core.maven2Nature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/easypoi-annotation/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 |
5 | org.jeecg
6 | easypoi
7 | 2.1.3
8 |
9 | easypoi-annotation
10 | 基础注解类,解耦合
11 |
--------------------------------------------------------------------------------
/easypoi-base/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | easypoi-base
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.m2e.core.maven2Builder
15 |
16 |
17 |
18 |
19 |
20 | org.eclipse.jdt.core.javanature
21 | org.eclipse.m2e.core.maven2Nature
22 |
23 |
24 |
--------------------------------------------------------------------------------
/easypoi-annotation/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | easypoi-annotation
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.m2e.core.maven2Builder
15 |
16 |
17 |
18 |
19 |
20 | org.eclipse.jdt.core.javanature
21 | org.eclipse.m2e.core.maven2Nature
22 |
23 |
24 |
--------------------------------------------------------------------------------
/easypoi-web/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | easypoi-web
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.springframework.ide.eclipse.core.springbuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.m2e.core.maven2Builder
20 |
21 |
22 |
23 |
24 |
25 | org.springframework.ide.eclipse.core.springnature
26 | org.eclipse.jdt.core.javanature
27 | org.eclipse.m2e.core.maven2Nature
28 |
29 |
30 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/org/jeecgframework/poi/excel/entity/enmus/ExcelType.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.jeecgframework.poi.excel.entity.enmus;
17 |
18 | /**
19 | * Excel Type
20 | * @author JueYue
21 | * @date 2014年12月29日 下午9:08:21
22 | */
23 | public enum ExcelType {
24 |
25 | HSSF, XSSF;
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/org/jeecgframework/poi/excel/entity/enmus/CellValueType.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.jeecgframework.poi.excel.entity.enmus;
17 |
18 | /**
19 | * Cell 值得类型
20 | * @author JueYue
21 | * @date 2014年12月29日 下午10:20:49
22 | */
23 | public enum CellValueType {
24 |
25 | String, Number, Boolean, Date, TElement, Null, None;
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/org/jeecgframework/poi/handler/inter/IExcelReadRowHanlder.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.jeecgframework.poi.handler.inter;
17 |
18 | /**
19 | * 接口自定义处理类
20 | * @author JueYue
21 | * @date 2015年1月16日 下午8:06:26
22 | * @param
23 | */
24 | public interface IExcelReadRowHanlder {
25 | /**
26 | * 处理解析对象
27 | * @param t
28 | */
29 | public void hanlder(T t);
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/easypoi-base/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/easypoi-web/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/org/jeecgframework/poi/excel/html/helper/excelStyle.css:
--------------------------------------------------------------------------------
1 | .excelDefaults {
2 | background-color: white;
3 | color: black;
4 | text-decoration: none;
5 | direction: ltr;
6 | text-transform: none;
7 | text-indent: 0;
8 | letter-spacing: 0;
9 | word-spacing: 0;
10 | white-space: normal;
11 | unicode-bidi: normal;
12 | vertical-align: 0;
13 | text-shadow: none;
14 | padding: 0;
15 | margin: 0;
16 | border-collapse: collapse;
17 | white-space: pre-wrap;
18 | word-wrap: break-word;
19 | word-break: break-all;
20 | }
21 |
22 | .excelDefaults td {
23 | padding: 1px 5px;
24 | border: 1px solid silver;
25 | border-color: #000000;
26 | text-align: center;
27 | vertical-align: middle;
28 | font-size: 12pt;
29 | }
30 |
31 | .excelDefaults .colHeader {
32 | background-color: silver;
33 | font-weight: bold;
34 | border: 1px solid black;
35 | text-align: center;
36 | padding: 1px 5px;
37 | }
38 |
39 | .excelDefaults .rowHeader {
40 | background-color: silver;
41 | font-weight: bold;
42 | border: 1px solid black;
43 | text-align: right;
44 | padding: 1px 5px;
45 | }
--------------------------------------------------------------------------------
/easypoi-annotation/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/easypoi-web/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 |
5 | org.jeecg
6 | easypoi
7 | 2.1.3
8 |
9 | easypoi-web
10 |
11 |
12 |
13 | org.springframework
14 | spring-web
15 |
16 |
17 | org.springframework
18 | spring-webmvc
19 |
20 |
21 | org.springframework
22 | spring-core
23 |
24 |
25 |
26 | javax.servlet
27 | servlet-api
28 | provided
29 |
30 |
31 |
32 | org.jeecg
33 | easypoi-base
34 |
35 |
36 |
--------------------------------------------------------------------------------
/easypoi-annotation/src/main/java/org/jeecgframework/poi/excel/annotation/ExcelIgnore.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.jeecgframework.poi.excel.annotation;
17 |
18 | import java.lang.annotation.ElementType;
19 | import java.lang.annotation.Retention;
20 | import java.lang.annotation.RetentionPolicy;
21 | import java.lang.annotation.Target;
22 |
23 | /**
24 | * 标记为excel 创建实体忽略,放置死循环的造成
25 | * @author JueYue
26 | * @date 2013-9-24
27 | * @version 1.0
28 | */
29 | @Retention(RetentionPolicy.RUNTIME)
30 | @Target(ElementType.FIELD)
31 | public @interface ExcelIgnore {
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/easypoi-web/src/main/java/org/jeecgframework/poi/excel/entity/vo/BasePOIConstants.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.jeecgframework.poi.excel.entity.vo;
17 |
18 | /**
19 | * 基础POI常量
20 | * @author JueYue
21 | * @date 2014年6月30日 下午9:23:37
22 | */
23 | interface BasePOIConstants {
24 |
25 | /**
26 | * 注解对象
27 | */
28 | public final static String CLASS = "entity";
29 | /**
30 | *表格参数
31 | */
32 | public final static String PARAMS = "params";
33 | /**
34 | *下载文件名称
35 | */
36 | public final static String FILE_NAME = "fileName";
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/org/jeecgframework/poi/excel/imports/sax/parse/ISaxRowRead.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.jeecgframework.poi.excel.imports.sax.parse;
17 |
18 | import java.util.List;
19 |
20 | import org.jeecgframework.poi.excel.entity.sax.SaxReadCellEntity;
21 |
22 | public interface ISaxRowRead {
23 | /**
24 | * 获取返回数据
25 | * @param
26 | * @return
27 | */
28 | public List getList();
29 | /**
30 | * 解析数据
31 | * @param index
32 | * @param datas
33 | */
34 | public void parse(int index, List datas);
35 |
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/easypoi-annotation/src/main/java/org/jeecgframework/poi/excel/annotation/ExcelTarget.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.jeecgframework.poi.excel.annotation;
17 |
18 | import java.lang.annotation.ElementType;
19 | import java.lang.annotation.Retention;
20 | import java.lang.annotation.RetentionPolicy;
21 | import java.lang.annotation.Target;
22 |
23 | /**
24 | * excel 导出是用于标记id的
25 | *
26 | * @author JueYue
27 | *
28 | */
29 | @Retention(RetentionPolicy.RUNTIME)
30 | @Target({ ElementType.TYPE })
31 | public @interface ExcelTarget {
32 | /**
33 | * 定义excel导出ID 来限定导出字段
34 | */
35 | public String value();
36 | }
37 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/org/jeecgframework/poi/exception/excel/enums/ExcelImportEnum.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.jeecgframework.poi.exception.excel.enums;
17 |
18 | /**
19 | * 导出异常类型枚举
20 | * @author JueYue
21 | * @date 2014年6月19日 下午10:59:51
22 | */
23 | public enum ExcelImportEnum {
24 |
25 | GET_VALUE_ERROR("Excel 值获取失败"), VERIFY_ERROR("值校验失败");
26 |
27 | private String msg;
28 |
29 | ExcelImportEnum(String msg) {
30 | this.msg = msg;
31 | }
32 |
33 | public String getMsg() {
34 | return msg;
35 | }
36 |
37 | public void setMsg(String msg) {
38 | this.msg = msg;
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/easypoi-web/src/main/java/org/jeecgframework/poi/excel/entity/vo/NormalExcelConstants.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.jeecgframework.poi.excel.entity.vo;
17 |
18 | /**
19 | * 正常导出Excel
20 | * @Author JueYue on 14-3-8.
21 | * 静态常量
22 | */
23 | public interface NormalExcelConstants extends BasePOIConstants {
24 | /**
25 | * 单Sheet导出
26 | */
27 | public final static String JEECG_EXCEL_VIEW = "jeecgExcelView";
28 | /**
29 | * 数据列表
30 | */
31 | public final static String DATA_LIST = "data";
32 | /**
33 | * 多Sheet 对象
34 | */
35 | public final static String MAP_LIST = "mapList";
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/org/jeecgframework/poi/exception/excel/enums/ExcelExportEnum.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.jeecgframework.poi.exception.excel.enums;
17 |
18 | /**
19 | * 导出异常类型枚举
20 | * @author JueYue
21 | * @date 2014年6月19日 下午10:59:51
22 | */
23 | public enum ExcelExportEnum {
24 |
25 | PARAMETER_ERROR("Excel 导出 参数错误"), EXPORT_ERROR("Excel导出错误");
26 |
27 | private String msg;
28 |
29 | ExcelExportEnum(String msg) {
30 | this.msg = msg;
31 | }
32 |
33 | public String getMsg() {
34 | return msg;
35 | }
36 |
37 | public void setMsg(String msg) {
38 | this.msg = msg;
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/easypoi-web/src/main/java/org/jeecgframework/poi/excel/entity/vo/MapExcelConstants.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.jeecgframework.poi.excel.entity.vo;
17 |
18 | /**
19 | * 正常导出Excel
20 | * @Author JueYue on 14-3-8.
21 | * 静态常量
22 | */
23 | public interface MapExcelConstants extends BasePOIConstants {
24 | /**
25 | * 单Sheet导出
26 | */
27 | public final static String JEECG_MAP_EXCEL_VIEW = "jeecgMapExcelView";
28 | /**
29 | * Entity List
30 | */
31 | public final static String ENTITY_LIST = "data";
32 | /**
33 | * 数据列表
34 | */
35 | public final static String MAP_LIST = "mapList";
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/org/jeecgframework/poi/excel/entity/vo/PoiBaseConstants.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.jeecgframework.poi.excel.entity.vo;
17 |
18 | /**
19 | * 基础常量
20 | * Created by jue on 14-4-21.
21 | */
22 | public interface PoiBaseConstants {
23 | /**
24 | * 字段属性对应方法
25 | */
26 | public static String GET = "get";
27 | /**
28 | * 字段属性对应方法
29 | */
30 | public static String SET = "set";
31 | /**
32 | * 字段属性对应方法
33 | */
34 | public static String IS = "is";
35 | /**
36 | * 是否增加属性列
37 | */
38 | public static String IS_ADD_INDEX = "isAddIndex";
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/easypoi-web/src/main/java/org/jeecgframework/poi/excel/entity/vo/TemplateWordConstants.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.jeecgframework.poi.excel.entity.vo;
17 |
18 | /**
19 | * Word 导出模板常量
20 | * @author JueYue
21 | * @date 2014年7月24日 下午11:26:46
22 | */
23 | public interface TemplateWordConstants extends BasePOIConstants {
24 | /**
25 | * 模板导出
26 | */
27 | public final static String JEECG_TEMPLATE_WORD_VIEW = "jeecgTemplateWordView";
28 | /**
29 | * 数据列表
30 | */
31 | public final static String URL = "url";
32 | /**
33 | * 模板参数
34 | */
35 | public final static String MAP_DATA = "map";
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/easypoi-web/src/main/java/org/jeecgframework/poi/excel/entity/vo/TemplateExcelConstants.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.jeecgframework.poi.excel.entity.vo;
17 |
18 | /**
19 | * 模板Excel导出常量
20 | * @author JueYue
21 | * @date 2014年6月30日 下午9:26:52
22 | */
23 | public interface TemplateExcelConstants extends BasePOIConstants {
24 | /**
25 | * 模板导出
26 | */
27 | public final static String JEECG_TEMPLATE_EXCEL_VIEW = "jeecgTemplateExcelView";
28 | /**
29 | * 数据列表
30 | */
31 | public final static String LIST_DATA = "list";
32 | /**
33 | * 模板参数
34 | */
35 | public final static String MAP_DATA = "map";
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/org/jeecgframework/poi/excel/entity/ExcelBaseParams.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.jeecgframework.poi.excel.entity;
17 |
18 | import org.jeecgframework.poi.handler.inter.IExcelDataHandler;
19 |
20 | /**
21 | * 基础参数
22 | * @author JueYue
23 | * @date 2014年6月20日 下午1:56:52
24 | */
25 | public class ExcelBaseParams {
26 |
27 | /**
28 | * 数据处理接口,以此为主,replace,format都在这后面
29 | */
30 | private IExcelDataHandler dataHanlder;
31 |
32 | public IExcelDataHandler getDataHanlder() {
33 | return dataHanlder;
34 | }
35 |
36 | public void setDataHanlder(IExcelDataHandler dataHanlder) {
37 | this.dataHanlder = dataHanlder;
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/org/jeecgframework/poi/exception/word/enmus/WordExportEnum.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.jeecgframework.poi.exception.word.enmus;
17 |
18 | /**
19 | * 导出异常枚举
20 | *
21 | * @author JueYue
22 | * @date 2014年8月9日 下午10:34:58
23 | */
24 | public enum WordExportEnum {
25 |
26 | EXCEL_PARAMS_ERROR ("Excel 导出 参数错误") ,
27 | EXCEL_HEAD_HAVA_NULL ("Excel 表头 有的字段为空") ,
28 | EXCEL_NO_HEAD ("Excel 没有表头");
29 |
30 | private String msg;
31 |
32 | WordExportEnum(String msg) {
33 | this.msg = msg;
34 | }
35 |
36 | public String getMsg() {
37 | return msg;
38 | }
39 |
40 | public void setMsg(String msg) {
41 | this.msg = msg;
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/org/jeecgframework/poi/exception/word/WordExportException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.jeecgframework.poi.exception.word;
17 |
18 | import org.jeecgframework.poi.exception.word.enmus.WordExportEnum;
19 |
20 | /**
21 | * word导出异常
22 | *
23 | * @author JueYue
24 | * @date 2014年8月9日 下午10:32:51
25 | */
26 | public class WordExportException extends RuntimeException {
27 |
28 | private static final long serialVersionUID = 1L;
29 |
30 | public WordExportException() {
31 | super();
32 | }
33 |
34 | public WordExportException(String msg) {
35 | super(msg);
36 | }
37 |
38 | public WordExportException(WordExportEnum exception) {
39 | super(exception.getMsg());
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/easypoi-annotation/src/main/java/org/jeecgframework/poi/excel/annotation/ExcelEntity.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.jeecgframework.poi.excel.annotation;
17 |
18 | import java.lang.annotation.ElementType;
19 | import java.lang.annotation.Retention;
20 | import java.lang.annotation.RetentionPolicy;
21 | import java.lang.annotation.Target;
22 |
23 | /**
24 | * 标记是不是导出excel 标记为实体类
25 | *
26 | * @author JueYue
27 | *
28 | */
29 | @Retention(RetentionPolicy.RUNTIME)
30 | @Target(ElementType.FIELD)
31 | public @interface ExcelEntity {
32 |
33 | /**
34 | * 定义excel导出ID 来限定导出字段,处理一个类对应多个不同名称的情况
35 | */
36 | public String id() default "";
37 |
38 | /**
39 | * 导出时,对应数据库的字段 主要是用户区分每个字段, 不能有annocation重名的 导出时的列名
40 | * 导出排序跟定义了annotation的字段的顺序有关 可以使用a_id,b_id来确实是否使用
41 | */
42 | public String name() default "";
43 | }
44 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/org/jeecgframework/poi/excel/ExcelToHtmlUtil.java:
--------------------------------------------------------------------------------
1 | package org.jeecgframework.poi.excel;
2 |
3 | import org.apache.poi.ss.usermodel.Workbook;
4 | import org.jeecgframework.poi.excel.html.ExcelToHtmlServer;
5 |
6 | /**
7 | * Excel 变成界面
8 | * @author JueYue
9 | * @date 2015年5月10日 上午11:51:48
10 | */
11 | public final class ExcelToHtmlUtil {
12 |
13 | private ExcelToHtmlUtil() {
14 | }
15 |
16 | /**
17 | * 转换成为Table
18 | * @param wb Excel
19 | * @return
20 | */
21 | public static String toTableHtml(Workbook wb) {
22 | return new ExcelToHtmlServer(wb, false, 0).printPage();
23 | }
24 |
25 | /**
26 | * 转换成为Table
27 | * @param wb Excel
28 | * @param sheetNum sheetNum
29 | * @return
30 | */
31 | public static String toTableHtml(Workbook wb, int sheetNum) {
32 | return new ExcelToHtmlServer(wb, false, sheetNum).printPage();
33 | }
34 |
35 | /**
36 | * 转换成为完整界面
37 | * @param wb Excel
38 | * @param sheetNum sheetNum
39 | * @return
40 | */
41 | public static String toAllHtml(Workbook wb) {
42 | return new ExcelToHtmlServer(wb, true, 0).printPage();
43 | }
44 |
45 | /**
46 | * 转换成为完整界面
47 | * @param wb Excel
48 | * @param sheetNum sheetNum
49 | * @return
50 | */
51 | public static String toAllHtml(Workbook wb, int sheetNum) {
52 | return new ExcelToHtmlServer(wb, true, sheetNum).printPage();
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/org/jeecgframework/poi/excel/entity/params/ExcelTemplateParams.java:
--------------------------------------------------------------------------------
1 | package org.jeecgframework.poi.excel.entity.params;
2 |
3 | import java.io.Serializable;
4 |
5 | import org.apache.poi.ss.usermodel.CellStyle;
6 |
7 | /**
8 | * 模板便利是的参数
9 | * @author JueYue
10 | * @date 2015年4月29日 下午9:22:48
11 | */
12 | public class ExcelTemplateParams implements Serializable {
13 |
14 | /**
15 | *
16 | */
17 | private static final long serialVersionUID = 1L;
18 | /**
19 | * key
20 | */
21 | private String name;
22 | /**
23 | * 模板的cellStyle
24 | */
25 | private CellStyle cellStyle;
26 | /**
27 | * 行高
28 | */
29 | private short height;
30 |
31 | public ExcelTemplateParams() {
32 |
33 | }
34 |
35 | public ExcelTemplateParams(String name, CellStyle cellStyle, short height) {
36 | this.name = name;
37 | this.cellStyle = cellStyle;
38 | this.height = height;
39 | }
40 |
41 | public String getName() {
42 | return name;
43 | }
44 |
45 | public void setName(String name) {
46 | this.name = name;
47 | }
48 |
49 | public CellStyle getCellStyle() {
50 | return cellStyle;
51 | }
52 |
53 | public void setCellStyle(CellStyle cellStyle) {
54 | this.cellStyle = cellStyle;
55 | }
56 |
57 | public short getHeight() {
58 | return height;
59 | }
60 |
61 | public void setHeight(short height) {
62 | this.height = height;
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/org/jeecgframework/poi/excel/export/styler/IExcelExportStyler.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.jeecgframework.poi.excel.export.styler;
17 |
18 | import org.apache.poi.ss.usermodel.CellStyle;
19 | import org.jeecgframework.poi.excel.entity.params.ExcelExportEntity;
20 |
21 | /**
22 | * Excel导出样式接口
23 | * @author JueYue
24 | * @date 2015年1月9日 下午5:32:30
25 | */
26 | public interface IExcelExportStyler {
27 |
28 | /**
29 | * 列表头样式
30 | * @param headerColor
31 | * @return
32 | */
33 | public CellStyle getHeaderStyle(short headerColor);
34 |
35 | /**
36 | * 标题样式
37 | * @param color
38 | * @return
39 | */
40 | public CellStyle getTitleStyle(short color);
41 |
42 | /**
43 | * 获取样式方法
44 | * @param noneStyler
45 | * @param entity
46 | * @return
47 | */
48 | public CellStyle getStyles(boolean noneStyler, ExcelExportEntity entity);
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/easypoi-web/src/main/java/org/jeecgframework/poi/excel/view/MiniAbstractExcelView.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.jeecgframework.poi.excel.view;
17 |
18 | import javax.servlet.http.HttpServletRequest;
19 |
20 | import org.springframework.web.servlet.view.AbstractView;
21 |
22 | /**
23 | * 基础抽象Excel View
24 | * @author JueYue
25 | * @date 2015年2月28日 下午1:41:05
26 | */
27 | public abstract class MiniAbstractExcelView extends AbstractView {
28 |
29 | private static final String CONTENT_TYPE = "application/vnd.ms-excel";
30 |
31 | protected static final String HSSF = ".xls";
32 | protected static final String XSSF = ".xlsx";
33 |
34 | public MiniAbstractExcelView() {
35 | setContentType(CONTENT_TYPE);
36 | }
37 |
38 | protected boolean isIE(HttpServletRequest request) {
39 | return (request.getHeader("USER-AGENT").toLowerCase().indexOf("msie") > 0 || request
40 | .getHeader("USER-AGENT").toLowerCase().indexOf("rv:11.0") > 0) ? true : false;
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/org/jeecgframework/poi/handler/inter/IExcelVerifyHandler.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.jeecgframework.poi.handler.inter;
17 |
18 | import org.jeecgframework.poi.excel.entity.result.ExcelVerifyHanlderResult;
19 |
20 | /**
21 | * 导入校验接口
22 | *
23 | * @author JueYue
24 | * @date 2014年6月23日 下午11:08:21
25 | */
26 | public interface IExcelVerifyHandler {
27 |
28 | /**
29 | * 获取需要处理的字段,导入和导出统一处理了, 减少书写的字段
30 | *
31 | * @return
32 | */
33 | public String[] getNeedVerifyFields();
34 |
35 | /**
36 | * 获取需要处理的字段,导入和导出统一处理了, 减少书写的字段
37 | *
38 | * @return
39 | */
40 | public void setNeedVerifyFields(String[] arr);
41 |
42 | /**
43 | * 导出处理方法
44 | *
45 | * @param obj
46 | * 当前对象
47 | * @param name
48 | * 当前字段名称
49 | * @param value
50 | * 当前值
51 | * @return
52 | */
53 | public ExcelVerifyHanlderResult verifyHandler(Object obj, String name, Object value);
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/org/jeecgframework/poi/excel/entity/enmus/ExcelStyleType.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.jeecgframework.poi.excel.entity.enmus;
17 |
18 | import org.jeecgframework.poi.excel.export.styler.ExcelExportStylerBorderImpl;
19 | import org.jeecgframework.poi.excel.export.styler.ExcelExportStylerColorImpl;
20 | import org.jeecgframework.poi.excel.export.styler.ExcelExportStylerDefaultImpl;
21 |
22 | /**
23 | * 插件提供的几个默认样式
24 | * @author JueYue
25 | * @date 2015年1月9日 下午9:02:24
26 | */
27 | public enum ExcelStyleType {
28 |
29 | NONE("默认样式", ExcelExportStylerDefaultImpl.class),
30 | BORDER("边框样式", ExcelExportStylerBorderImpl.class),
31 | COLOR("间隔行样式", ExcelExportStylerColorImpl.class);
32 |
33 | private String name;
34 | private Class> clazz;
35 |
36 | ExcelStyleType(String name, Class> clazz) {
37 | this.name = name;
38 | this.clazz = clazz;
39 | }
40 |
41 | public Class> getClazz() {
42 | return clazz;
43 | }
44 |
45 | public String getName() {
46 | return name;
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/easypoi-annotation/src/main/java/org/jeecgframework/poi/excel/annotation/ExcelCollection.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.jeecgframework.poi.excel.annotation;
17 |
18 | import java.lang.annotation.ElementType;
19 | import java.lang.annotation.Retention;
20 | import java.lang.annotation.RetentionPolicy;
21 | import java.lang.annotation.Target;
22 | import java.util.ArrayList;
23 |
24 | /**
25 | * 导出的集合
26 | *
27 | * @author JueYue 2013年8月24日
28 | */
29 | @Retention(RetentionPolicy.RUNTIME)
30 | @Target(ElementType.FIELD)
31 | public @interface ExcelCollection {
32 |
33 | /**
34 | * 定义excel导出ID 来限定导出字段,处理一个类对应多个不同名称的情况
35 | */
36 | public String id() default "";
37 |
38 | /**
39 | * 导出时,对应数据库的字段 主要是用户区分每个字段, 不能有annocation重名的 导出时的列名
40 | * 导出排序跟定义了annotation的字段的顺序有关 可以使用a_id,b_id来确实是否使用
41 | */
42 | public String name();
43 |
44 | /**
45 | * 展示到第几个同样可以使用a_id,b_id
46 | *
47 | */
48 | public String orderNum() default "0";
49 |
50 | /**
51 | * 创建时创建的类型 默认值是 arrayList
52 | */
53 | public Class> type() default ArrayList.class;
54 | }
55 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/org/jeecgframework/poi/excel/entity/result/ExcelVerifyHanlderResult.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.jeecgframework.poi.excel.entity.result;
17 |
18 | /**
19 | * Excel导入处理返回结果
20 | *
21 | * @author JueYue
22 | * @date 2014年6月23日 下午11:03:29
23 | */
24 | public class ExcelVerifyHanlderResult {
25 | /**
26 | * 是否正确
27 | */
28 | private boolean success;
29 | /**
30 | * 错误信息
31 | */
32 | private String msg;
33 |
34 | public ExcelVerifyHanlderResult() {
35 |
36 | }
37 |
38 | public ExcelVerifyHanlderResult(boolean success) {
39 | this.success = success;
40 | }
41 |
42 | public ExcelVerifyHanlderResult(boolean success, String msg) {
43 | this.success = success;
44 | this.msg = msg;
45 | }
46 |
47 | public String getMsg() {
48 | return msg;
49 | }
50 |
51 | public boolean isSuccess() {
52 | return success;
53 | }
54 |
55 | public void setMsg(String msg) {
56 | this.msg = msg;
57 | }
58 |
59 | public void setSuccess(boolean success) {
60 | this.success = success;
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/org/jeecgframework/poi/cache/WordCache.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.jeecgframework.poi.cache;
17 |
18 | import java.io.InputStream;
19 |
20 | import org.jeecgframework.poi.cache.manager.POICacheManager;
21 | import org.jeecgframework.poi.word.entity.MyXWPFDocument;
22 | import org.slf4j.Logger;
23 | import org.slf4j.LoggerFactory;
24 |
25 | /**
26 | * word 缓存中心
27 | *
28 | * @author JueYue
29 | * @date 2014年7月24日 下午10:54:31
30 | */
31 | public class WordCache {
32 |
33 | private static final Logger LOGGER = LoggerFactory.getLogger(WordCache.class);
34 |
35 | public static MyXWPFDocument getXWPFDocumen(String url) {
36 | InputStream is = null;
37 | try {
38 | is = POICacheManager.getFile(url);
39 | MyXWPFDocument doc = new MyXWPFDocument(is);
40 | return doc;
41 | } catch (Exception e) {
42 | LOGGER.error(e.getMessage(),e);
43 | } finally {
44 | try {
45 | is.close();
46 | } catch (Exception e) {
47 | LOGGER.error(e.getMessage(),e);
48 | }
49 | }
50 | return null;
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/org/jeecgframework/poi/excel/entity/sax/SaxReadCellEntity.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.jeecgframework.poi.excel.entity.sax;
17 |
18 | import org.jeecgframework.poi.excel.entity.enmus.CellValueType;
19 |
20 | /**
21 | * Cell 对象
22 | * @author JueYue
23 | * @date 2014年12月29日 下午10:12:57
24 | */
25 | public class SaxReadCellEntity {
26 | /**
27 | * 值类型
28 | */
29 | private CellValueType cellType;
30 | /**
31 | * 值
32 | */
33 | private Object value;
34 |
35 | public SaxReadCellEntity(CellValueType cellType, Object value) {
36 | this.cellType = cellType;
37 | this.value = value;
38 | }
39 |
40 | public CellValueType getCellType() {
41 | return cellType;
42 | }
43 |
44 | public void setCellType(CellValueType cellType) {
45 | this.cellType = cellType;
46 | }
47 |
48 | public Object getValue() {
49 | return value;
50 | }
51 |
52 | public void setValue(Object value) {
53 | this.value = value;
54 | }
55 |
56 | @Override
57 | public String toString() {
58 | return "[type=" + cellType.toString() + ",value=" + value + "]";
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/org/jeecgframework/poi/handler/impl/ExcelDataHandlerDefaultImpl.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.jeecgframework.poi.handler.impl;
17 |
18 | import java.util.Map;
19 |
20 | import org.jeecgframework.poi.handler.inter.IExcelDataHandler;
21 |
22 | /**
23 | * 数据处理默认实现,返回空
24 | *
25 | * @author JueYue
26 | * @date 2014年6月20日 上午12:11:52
27 | */
28 | public abstract class ExcelDataHandlerDefaultImpl implements IExcelDataHandler {
29 | /**
30 | * 需要处理的字段
31 | */
32 | private String[] needHandlerFields;
33 |
34 | @Override
35 | public Object exportHandler(Object obj, String name, Object value) {
36 | return value;
37 | }
38 |
39 | @Override
40 | public String[] getNeedHandlerFields() {
41 | return needHandlerFields;
42 | }
43 |
44 | @Override
45 | public Object importHandler(Object obj, String name, Object value) {
46 | return value;
47 | }
48 |
49 | @Override
50 | public void setNeedHandlerFields(String[] needHandlerFields) {
51 | this.needHandlerFields = needHandlerFields;
52 | }
53 |
54 | @Override
55 | public void setMapValue(Map map, String originKey, Object value) {
56 | map.put(originKey, value);
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/org/jeecgframework/poi/exception/excel/ExcelImportException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.jeecgframework.poi.exception.excel;
17 |
18 | import org.jeecgframework.poi.exception.excel.enums.ExcelImportEnum;
19 |
20 | /**
21 | * 导入异常
22 | * @author JueYue
23 | * @date 2014年6月29日 下午2:23:43
24 | */
25 | public class ExcelImportException extends RuntimeException {
26 |
27 | private static final long serialVersionUID = 1L;
28 |
29 | private ExcelImportEnum type;
30 |
31 | public ExcelImportException() {
32 | super();
33 | }
34 |
35 | public ExcelImportException(ExcelImportEnum type) {
36 | super(type.getMsg());
37 | this.type = type;
38 | }
39 |
40 | public ExcelImportException(ExcelImportEnum type, Throwable cause) {
41 | super(type.getMsg(), cause);
42 | }
43 |
44 | public ExcelImportException(String message) {
45 | super(message);
46 | }
47 |
48 | public ExcelImportException(String message, ExcelImportEnum type) {
49 | super(message);
50 | this.type = type;
51 | }
52 |
53 | public ExcelImportEnum getType() {
54 | return type;
55 | }
56 |
57 | public void setType(ExcelImportEnum type) {
58 | this.type = type;
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/org/jeecgframework/poi/exception/excel/ExcelExportException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.jeecgframework.poi.exception.excel;
17 |
18 | import org.jeecgframework.poi.exception.excel.enums.ExcelExportEnum;
19 |
20 | /**
21 | * 导出异常
22 | *
23 | * @author JueYue
24 | * @date 2014年6月19日 下午10:56:18
25 | */
26 | public class ExcelExportException extends RuntimeException {
27 |
28 | private static final long serialVersionUID = 1L;
29 |
30 | private ExcelExportEnum type;
31 |
32 | public ExcelExportException() {
33 | super();
34 | }
35 |
36 | public ExcelExportException(ExcelExportEnum type) {
37 | super(type.getMsg());
38 | this.type = type;
39 | }
40 |
41 | public ExcelExportException(ExcelExportEnum type, Throwable cause) {
42 | super(type.getMsg(), cause);
43 | }
44 |
45 | public ExcelExportException(String message) {
46 | super(message);
47 | }
48 |
49 | public ExcelExportException(String message, ExcelExportEnum type) {
50 | super(message);
51 | this.type = type;
52 | }
53 |
54 | public ExcelExportEnum getType() {
55 | return type;
56 | }
57 |
58 | public void setType(ExcelExportEnum type) {
59 | this.type = type;
60 | }
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/org/jeecgframework/poi/word/WordExportUtil.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.jeecgframework.poi.word;
17 |
18 | import java.util.Map;
19 |
20 | import org.apache.poi.xwpf.usermodel.XWPFDocument;
21 | import org.jeecgframework.poi.word.parse.ParseWord07;
22 |
23 | /**
24 | * Word使用模板导出工具类
25 | *
26 | * @author JueYue
27 | * @date 2013-11-16
28 | * @version 1.0
29 | */
30 | public final class WordExportUtil {
31 |
32 | private WordExportUtil() {
33 |
34 | }
35 |
36 | /**
37 | * 解析Word2007版本
38 | *
39 | * @param url
40 | * 模板地址
41 | * @param map
42 | * 解析数据源
43 | * @return
44 | */
45 | public static XWPFDocument exportWord07(String url, Map map) throws Exception {
46 | return new ParseWord07().parseWord(url, map);
47 | }
48 |
49 | /**
50 | * 解析Word2007版本
51 | *
52 | * @param XWPFDocument
53 | * 模板
54 | * @param map
55 | * 解析数据源
56 | * @return
57 | */
58 | public static void exportWord07(XWPFDocument document, Map map)
59 | throws Exception {
60 | new ParseWord07().parseWord(document, map);
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/easypoi-base/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 |
5 | org.jeecg
6 | easypoi
7 | 2.1.3
8 |
9 | easypoi-base
10 |
11 |
12 |
13 | org.apache.poi
14 | poi
15 |
16 |
17 | org.apache.poi
18 | poi-ooxml
19 |
20 |
21 | org.apache.poi
22 | poi-ooxml-schemas
23 |
24 |
25 | xerces
26 | xercesImpl
27 |
28 |
29 |
30 |
31 |
32 | xerces
33 | xercesImpl
34 | true
35 |
36 |
37 |
38 | org.apache.poi
39 | poi-scratchpad
40 | true
41 |
42 |
43 |
44 |
45 | com.google.guava
46 | guava
47 |
48 |
49 |
50 | org.apache.commons
51 | commons-lang3
52 |
53 |
54 |
55 |
56 |
57 | org.slf4j
58 | slf4j-api
59 |
60 |
61 |
62 | org.jeecg
63 | easypoi-annotation
64 |
65 |
66 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/org/jeecgframework/poi/excel/entity/result/ExcelImportResult.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.jeecgframework.poi.excel.entity.result;
17 |
18 | import java.util.List;
19 |
20 | import org.apache.poi.ss.usermodel.Workbook;
21 |
22 | /**
23 | * 导入返回类
24 | *
25 | * @author JueYue
26 | * @date 2014年6月29日 下午5:12:10
27 | */
28 | public class ExcelImportResult {
29 |
30 | /**
31 | * 结果集
32 | */
33 | private List list;
34 |
35 | /**
36 | * 是否存在校验失败
37 | */
38 | private boolean verfiyFail;
39 |
40 | /**
41 | * 数据源
42 | */
43 | private Workbook workbook;
44 |
45 | public ExcelImportResult() {
46 |
47 | }
48 |
49 | public ExcelImportResult(List list, boolean verfiyFail, Workbook workbook) {
50 | this.list = list;
51 | this.verfiyFail = verfiyFail;
52 | this.workbook = workbook;
53 | }
54 |
55 | public List getList() {
56 | return list;
57 | }
58 |
59 | public Workbook getWorkbook() {
60 | return workbook;
61 | }
62 |
63 | public boolean isVerfiyFail() {
64 | return verfiyFail;
65 | }
66 |
67 | public void setList(List list) {
68 | this.list = list;
69 | }
70 |
71 | public void setVerfiyFail(boolean verfiyFail) {
72 | this.verfiyFail = verfiyFail;
73 | }
74 |
75 | public void setWorkbook(Workbook workbook) {
76 | this.workbook = workbook;
77 | }
78 |
79 | }
80 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/org/jeecgframework/poi/handler/inter/IExcelDataHandler.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.jeecgframework.poi.handler.inter;
17 |
18 | import java.util.Map;
19 |
20 | /**
21 | * Excel 导入导出 数据处理接口
22 | *
23 | * @author JueYue
24 | * @date 2014年6月19日 下午11:59:45
25 | */
26 | public interface IExcelDataHandler {
27 |
28 | /**
29 | * 导出处理方法
30 | *
31 | * @param obj
32 | * 当前对象
33 | * @param name
34 | * 当前字段名称
35 | * @param value
36 | * 当前值
37 | * @return
38 | */
39 | public Object exportHandler(Object obj, String name, Object value);
40 |
41 | /**
42 | * 获取需要处理的字段,导入和导出统一处理了, 减少书写的字段
43 | *
44 | * @return
45 | */
46 | public String[] getNeedHandlerFields();
47 |
48 | /**
49 | * 导入处理方法 当前对象,当前字段名称,当前值
50 | *
51 | * @param obj
52 | * 当前对象
53 | * @param name
54 | * 当前字段名称
55 | * @param value
56 | * 当前值
57 | * @return
58 | */
59 | public Object importHandler(Object obj, String name, Object value);
60 |
61 | /**
62 | * 设置需要处理的属性列表
63 | * @param fields
64 | */
65 | public void setNeedHandlerFields(String[] fields);
66 |
67 | /**
68 | * 设置Map导入,自定义 put
69 | * @param map
70 | * @param originKey
71 | * @param value
72 | */
73 | public void setMapValue(Map map, String originKey, Object value);
74 |
75 | }
76 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/org/jeecgframework/poi/excel/entity/params/ExcelCollectionParams.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.jeecgframework.poi.excel.entity.params;
17 |
18 | import java.util.Map;
19 |
20 | /**
21 | * Excel 对于的 Collection
22 | *
23 | * @author JueYue
24 | * @date 2013-9-26
25 | * @version 1.0
26 | */
27 | public class ExcelCollectionParams {
28 |
29 | /**
30 | * 集合对应的名称
31 | */
32 | private String name;
33 | /**
34 | * Excel 列名称
35 | */
36 | private String excelName;
37 | /**
38 | * 实体对象
39 | */
40 | private Class> type;
41 | /**
42 | * 这个list下面的参数集合实体对象
43 | */
44 | private Map excelParams;
45 |
46 | public Map getExcelParams() {
47 | return excelParams;
48 | }
49 |
50 | public String getName() {
51 | return name;
52 | }
53 |
54 | public Class> getType() {
55 | return type;
56 | }
57 |
58 | public void setExcelParams(Map excelParams) {
59 | this.excelParams = excelParams;
60 | }
61 |
62 | public void setName(String name) {
63 | this.name = name;
64 | }
65 |
66 | public void setType(Class> type) {
67 | this.type = type;
68 | }
69 |
70 | public String getExcelName() {
71 | return excelName;
72 | }
73 |
74 | public void setExcelName(String excelName) {
75 | this.excelName = excelName;
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/org/jeecgframework/poi/excel/entity/params/MergeEntity.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.jeecgframework.poi.excel.entity.params;
17 |
18 | import java.util.List;
19 |
20 | /**
21 | * 合并单元格使用对象
22 | *
23 | * Created by jue on 14-6-11.
24 | */
25 | public class MergeEntity {
26 | /**
27 | * 合并开始行
28 | */
29 | private int startRow;
30 | /**
31 | * 合并结束行
32 | */
33 | private int endRow;
34 | /**
35 | * 文字
36 | */
37 | private String text;
38 | /**
39 | * 依赖关系文本
40 | */
41 | private List relyList;
42 |
43 | public MergeEntity() {
44 |
45 | }
46 |
47 | public MergeEntity(String text, int startRow, int endRow) {
48 | this.text = text;
49 | this.endRow = endRow;
50 | this.startRow = startRow;
51 | }
52 |
53 | public int getEndRow() {
54 | return endRow;
55 | }
56 |
57 | public List getRelyList() {
58 | return relyList;
59 | }
60 |
61 | public int getStartRow() {
62 | return startRow;
63 | }
64 |
65 | public String getText() {
66 | return text;
67 | }
68 |
69 | public void setEndRow(int endRow) {
70 | this.endRow = endRow;
71 | }
72 |
73 | public void setRelyList(List relyList) {
74 | this.relyList = relyList;
75 | }
76 |
77 | public void setStartRow(int startRow) {
78 | this.startRow = startRow;
79 | }
80 |
81 | public void setText(String text) {
82 | this.text = text;
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/easypoi-annotation/src/main/java/org/jeecgframework/poi/excel/annotation/ExcelVerify.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.jeecgframework.poi.excel.annotation;
17 |
18 | import java.lang.annotation.ElementType;
19 | import java.lang.annotation.Retention;
20 | import java.lang.annotation.RetentionPolicy;
21 | import java.lang.annotation.Target;
22 |
23 | /**
24 | * Excel 导入校验
25 | *
26 | * @author JueYue
27 | * @date 2014年6月23日 下午10:46:26
28 | */
29 | @Retention(RetentionPolicy.RUNTIME)
30 | @Target(ElementType.FIELD)
31 | public @interface ExcelVerify {
32 | /**
33 | * 接口校验
34 | * @return
35 | */
36 | public boolean interHandler() default false;
37 |
38 | /**
39 | * 是电子邮件
40 | *
41 | * @return
42 | */
43 | public boolean isEmail() default false;
44 |
45 | /**
46 | * 是13位移动电话
47 | *
48 | * @return
49 | */
50 | public boolean isMobile() default false;
51 |
52 | /**
53 | * 是座机号码
54 | *
55 | * @return
56 | */
57 | public boolean isTel() default false;
58 |
59 | /**
60 | * 最大长度
61 | *
62 | * @return
63 | */
64 | public int maxLength() default -1;
65 |
66 | /**
67 | * 最小长度
68 | *
69 | * @return
70 | */
71 | public int minLength() default -1;
72 |
73 | /**
74 | * 不允许空
75 | *
76 | * @return
77 | */
78 | public boolean notNull() default false;
79 |
80 | /**
81 | * 正在表达式
82 | *
83 | * @return
84 | */
85 | public String regex() default "";
86 |
87 | /**
88 | * 正在表达式,错误提示信息
89 | *
90 | * @return
91 | */
92 | public String regexTip() default "数据不符合规范";
93 |
94 | }
95 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/org/jeecgframework/poi/cache/manager/POICacheManager.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.jeecgframework.poi.cache.manager;
17 |
18 | import java.io.ByteArrayInputStream;
19 | import java.io.InputStream;
20 | import java.util.Arrays;
21 | import java.util.concurrent.ExecutionException;
22 | import java.util.concurrent.TimeUnit;
23 |
24 | import org.slf4j.Logger;
25 | import org.slf4j.LoggerFactory;
26 |
27 | import com.google.common.cache.CacheBuilder;
28 | import com.google.common.cache.CacheLoader;
29 | import com.google.common.cache.LoadingCache;
30 |
31 | /**
32 | * 缓存管理
33 | *
34 | * @author JueYue
35 | * @date 2014年2月10日
36 | * @version 1.0
37 | */
38 | public final class POICacheManager {
39 |
40 | private static final Logger LOGGER = LoggerFactory
41 | .getLogger(POICacheManager.class);
42 |
43 | private static LoadingCache loadingCache;
44 |
45 | static {
46 | loadingCache = CacheBuilder.newBuilder().expireAfterWrite(7, TimeUnit.DAYS).maximumSize(50)
47 | .build(new CacheLoader() {
48 | @Override
49 | public byte[] load(String url) throws Exception {
50 | return new FileLoade().getFile(url);
51 | }
52 | });
53 | }
54 |
55 | public static InputStream getFile(String id) {
56 | try {
57 | //复杂数据,防止操作原数据
58 | byte[] result = Arrays.copyOf(loadingCache.get(id), loadingCache.get(id).length);
59 | return new ByteArrayInputStream(result);
60 | } catch (ExecutionException e) {
61 | LOGGER.error(e.getMessage(),e);
62 | }
63 | return null;
64 | }
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/org/jeecgframework/poi/cache/ExcelCache.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.jeecgframework.poi.cache;
17 |
18 | import java.io.InputStream;
19 | import java.util.Arrays;
20 | import java.util.List;
21 |
22 | import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
23 | import org.apache.poi.ss.usermodel.Workbook;
24 | import org.apache.poi.ss.usermodel.WorkbookFactory;
25 | import org.jeecgframework.poi.cache.manager.POICacheManager;
26 | import org.slf4j.Logger;
27 | import org.slf4j.LoggerFactory;
28 |
29 | /**
30 | * Excel类型的缓存
31 | *
32 | * @author JueYue
33 | * @date 2014年2月11日
34 | * @version 1.0
35 | */
36 | public final class ExcelCache {
37 |
38 | private static final Logger LOGGER = LoggerFactory.getLogger(ExcelCache.class);
39 |
40 | public static Workbook getWorkbook(String url, Integer[] sheetNums, boolean needAll) {
41 | InputStream is = null;
42 | List sheetList = Arrays.asList(sheetNums);
43 | try {
44 | is = POICacheManager.getFile(url);
45 | Workbook wb = WorkbookFactory.create(is);
46 | // 删除其他的sheet
47 | if (!needAll) {
48 | for (int i = wb.getNumberOfSheets() - 1; i >= 0; i--) {
49 | if (!sheetList.contains(i)) {
50 | wb.removeSheetAt(i);
51 | }
52 | }
53 | }
54 | return wb;
55 | } catch (InvalidFormatException e) {
56 | LOGGER.error(e.getMessage(), e);
57 | } catch (Exception e) {
58 | LOGGER.error(e.getMessage(), e);
59 | } finally {
60 | try {
61 | is.close();
62 | } catch (Exception e) {
63 | LOGGER.error(e.getMessage(), e);
64 | }
65 | }
66 | return null;
67 | }
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/org/jeecgframework/poi/word/entity/params/ListParamEntity.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.jeecgframework.poi.word.entity.params;
17 |
18 | /**
19 | * Excel 对象导出结构
20 | *
21 | * @author JueYue
22 | * @date 2014年7月26日 下午11:14:48
23 | */
24 | public class ListParamEntity {
25 | // 唯一值,在遍历中重复使用
26 | public static final String SINGLE = "single";
27 | // 属于数组类型
28 | public static final String LIST = "list";
29 | /**
30 | * 属性名称
31 | */
32 | private String name;
33 | /**
34 | * 目标
35 | */
36 | private String target;
37 | /**
38 | * 当是唯一值的时候直接求出值
39 | */
40 | private Object value;
41 | /**
42 | * 数据类型,SINGLE || LIST
43 | */
44 | private String type;
45 |
46 | public ListParamEntity() {
47 |
48 | }
49 |
50 | public ListParamEntity(String name, Object value) {
51 | this.name = name;
52 | this.value = value;
53 | this.type = LIST;
54 | }
55 |
56 | public ListParamEntity(String name, String target) {
57 | this.name = name;
58 | this.target = target;
59 | this.type = LIST;
60 | }
61 |
62 | public String getName() {
63 | return name;
64 | }
65 |
66 | public String getTarget() {
67 | return target;
68 | }
69 |
70 | public String getType() {
71 | return type;
72 | }
73 |
74 | public Object getValue() {
75 | return value;
76 | }
77 |
78 | public void setName(String name) {
79 | this.name = name;
80 | }
81 |
82 | public void setTarget(String target) {
83 | this.target = target;
84 | }
85 |
86 | public void setType(String type) {
87 | this.type = type;
88 | }
89 |
90 | public void setValue(Object value) {
91 | this.value = value;
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/org/jeecgframework/poi/cache/manager/FileLoade.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.jeecgframework.poi.cache.manager;
17 |
18 | import java.io.ByteArrayOutputStream;
19 | import java.io.FileInputStream;
20 | import java.io.FileNotFoundException;
21 | import java.io.IOException;
22 |
23 | import org.jeecgframework.poi.util.PoiPublicUtil;
24 | import org.slf4j.Logger;
25 | import org.slf4j.LoggerFactory;
26 |
27 | /**
28 | * 文件加载类,根据路径加载指定文件
29 | * @author JueYue
30 | * @date 2014年2月10日
31 | * @version 1.0
32 | */
33 | class FileLoade {
34 |
35 | private static final Logger LOGGER = LoggerFactory.getLogger(FileLoade.class);
36 |
37 | public byte[] getFile(String url) {
38 | FileInputStream fileis = null;
39 | ByteArrayOutputStream baos = null;
40 | try {
41 | //先用绝对路径查询,再查询相对路径
42 | try {
43 | fileis = new FileInputStream(url);
44 | } catch (FileNotFoundException e) {
45 | String path = PoiPublicUtil.getWebRootPath(url);
46 | fileis = new FileInputStream(path);
47 | }
48 | baos = new ByteArrayOutputStream();
49 | byte[] buffer = new byte[1024];
50 | int len;
51 | while ((len = fileis.read(buffer)) > -1) {
52 | baos.write(buffer, 0, len);
53 | }
54 | baos.flush();
55 | return baos.toByteArray();
56 | } catch (FileNotFoundException e) {
57 | LOGGER.error(e.getMessage(), e);
58 | } catch (IOException e) {
59 | LOGGER.error(e.getMessage(), e);
60 | } finally {
61 | try {
62 | if (fileis != null)
63 | fileis.close();
64 | if (fileis != null)
65 | baos.close();
66 | } catch (IOException e) {
67 | LOGGER.error(e.getMessage(), e);
68 | }
69 | }
70 | LOGGER.error(fileis + "这个路径文件没有找到,请查询");
71 | return null;
72 | }
73 |
74 | }
75 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/org/jeecgframework/poi/word/entity/WordImageEntity.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.jeecgframework.poi.word.entity;
17 |
18 | /**
19 | * word导出,图片设置和图片信息
20 | *
21 | * @author JueYue
22 | * @date 2013-11-17
23 | * @version 1.0
24 | */
25 | public class WordImageEntity {
26 |
27 | public static String URL = "url";
28 | public static String Data = "data";
29 | /**
30 | * 图片输入方式
31 | */
32 | private String type = URL;
33 | /**
34 | * 图片宽度
35 | */
36 | private int width;
37 | // 图片高度
38 | private int height;
39 | // 图片地址
40 | private String url;
41 | // 图片信息
42 | private byte[] data;
43 |
44 | public WordImageEntity() {
45 |
46 | }
47 |
48 | public WordImageEntity(byte[] data, int width, int height) {
49 | this.data = data;
50 | this.width = width;
51 | this.height = height;
52 | this.type = Data;
53 | }
54 |
55 | public WordImageEntity(String url, int width, int height) {
56 | this.url = url;
57 | this.width = width;
58 | this.height = height;
59 | }
60 |
61 | public byte[] getData() {
62 | return data;
63 | }
64 |
65 | public int getHeight() {
66 | return height;
67 | }
68 |
69 | public String getType() {
70 | return type;
71 | }
72 |
73 | public String getUrl() {
74 | return url;
75 | }
76 |
77 | public int getWidth() {
78 | return width;
79 | }
80 |
81 | public void setData(byte[] data) {
82 | this.data = data;
83 | }
84 |
85 | public void setHeight(int height) {
86 | this.height = height;
87 | }
88 |
89 | public void setType(String type) {
90 | this.type = type;
91 | }
92 |
93 | public void setUrl(String url) {
94 | this.url = url;
95 | }
96 |
97 | public void setWidth(int width) {
98 | this.width = width;
99 | }
100 |
101 | }
102 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/org/jeecgframework/poi/word/entity/params/ExcelListEntity.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.jeecgframework.poi.word.entity.params;
17 |
18 | import java.util.List;
19 |
20 | import org.jeecgframework.poi.excel.entity.ExcelBaseParams;
21 | import org.jeecgframework.poi.handler.inter.IExcelDataHandler;
22 |
23 | /**
24 | * Excel 导出对象
25 | *
26 | * @author JueYue
27 | * @date 2014年8月9日 下午10:21:13
28 | */
29 | public class ExcelListEntity extends ExcelBaseParams {
30 |
31 | /**
32 | * 数据源
33 | */
34 | private List> list;
35 |
36 | /**
37 | * 实体类对象
38 | */
39 | private Class> clazz;
40 |
41 | /**
42 | * 表头行数
43 | */
44 | private int headRows = 1;
45 |
46 | public ExcelListEntity() {
47 |
48 | }
49 |
50 | public ExcelListEntity(List> list, Class> clazz) {
51 | this.list = list;
52 | this.clazz = clazz;
53 | }
54 |
55 | public ExcelListEntity(List> list, Class> clazz, IExcelDataHandler dataHanlder) {
56 | this.list = list;
57 | this.clazz = clazz;
58 | setDataHanlder(dataHanlder);
59 | }
60 | public ExcelListEntity(List> list, Class> clazz, IExcelDataHandler dataHanlder, int headRows) {
61 | this.list = list;
62 | this.clazz = clazz;
63 | this.headRows = headRows;
64 | setDataHanlder(dataHanlder);
65 | }
66 | public ExcelListEntity(List> list, Class> clazz, int headRows) {
67 | this.list = list;
68 | this.clazz = clazz;
69 | this.headRows = headRows;
70 | }
71 |
72 | public Class> getClazz() {
73 | return clazz;
74 | }
75 |
76 | public int getHeadRows() {
77 | return headRows;
78 | }
79 |
80 | public List> getList() {
81 | return list;
82 | }
83 |
84 | public void setClazz(Class> clazz) {
85 | this.clazz = clazz;
86 | }
87 |
88 | public void setHeadRows(int headRows) {
89 | this.headRows = headRows;
90 | }
91 |
92 | public void setList(List> list) {
93 | this.list = list;
94 | }
95 |
96 | }
97 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/org/jeecgframework/poi/excel/export/styler/AbstractExcelExportStyler.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.jeecgframework.poi.excel.export.styler;
17 |
18 | import org.apache.poi.ss.usermodel.BuiltinFormats;
19 | import org.apache.poi.ss.usermodel.CellStyle;
20 | import org.apache.poi.ss.usermodel.Workbook;
21 | import org.jeecgframework.poi.excel.entity.params.ExcelExportEntity;
22 |
23 | /**
24 | * 抽象接口提供两个公共方法
25 | * @author JueYue
26 | * @date 2015年1月9日 下午5:48:55
27 | */
28 | public abstract class AbstractExcelExportStyler implements IExcelExportStyler {
29 | //单行
30 | protected CellStyle stringNoneStyle;
31 | protected CellStyle stringNoneWrapStyle;
32 | //间隔行
33 | protected CellStyle stringSeptailStyle;
34 | protected CellStyle stringSeptailWrapStyle;
35 |
36 | protected Workbook workbook;
37 |
38 | protected static final short STRING_FORMAT = (short) BuiltinFormats.getBuiltinFormat("TEXT");
39 |
40 | protected void createStyles(Workbook workbook) {
41 | this.stringNoneStyle = stringNoneStyle(workbook, false);
42 | this.stringNoneWrapStyle = stringNoneStyle(workbook, true);
43 | this.stringSeptailStyle = stringSeptailStyle(workbook, false);
44 | this.stringSeptailWrapStyle = stringSeptailStyle(workbook, true);
45 | this.workbook = workbook;
46 | }
47 |
48 | @Override
49 | public CellStyle getStyles(boolean noneStyler, ExcelExportEntity entity) {
50 | if (noneStyler && (entity == null || entity.isWrap())) {
51 | return stringNoneWrapStyle;
52 | }
53 | if (noneStyler) {
54 | return stringNoneStyle;
55 | }
56 | if (noneStyler == false && (entity == null || entity.isWrap())) {
57 | return stringSeptailWrapStyle;
58 | }
59 | return stringSeptailStyle;
60 | }
61 |
62 | public CellStyle stringNoneStyle(Workbook workbook, boolean isWarp) {
63 | return null;
64 | }
65 |
66 | public CellStyle stringSeptailStyle(Workbook workbook, boolean isWarp) {
67 | return null;
68 | }
69 |
70 | }
71 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/org/jeecgframework/poi/excel/entity/params/ExcelBaseEntity.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.jeecgframework.poi.excel.entity.params;
17 |
18 | import java.lang.reflect.Method;
19 | import java.util.List;
20 |
21 | /**
22 | * Excel 导入导出基础对象类
23 | * @author JueYue
24 | * @date 2014年6月20日 下午2:26:09
25 | */
26 | public class ExcelBaseEntity {
27 | /**
28 | * 对应name
29 | */
30 | protected String name;
31 | /**
32 | * 对应type
33 | */
34 | private int type = 1;
35 | /**
36 | * 数据库格式
37 | */
38 | private String databaseFormat;
39 | /**
40 | * 导出日期格式
41 | */
42 | private String format;
43 | /**
44 | * 导出日期格式
45 | */
46 | private String[] replace;
47 | /**
48 | * set/get方法
49 | */
50 | private Method method;
51 |
52 | private List methods;
53 |
54 | public String getDatabaseFormat() {
55 | return databaseFormat;
56 | }
57 |
58 | public String getFormat() {
59 | return format;
60 | }
61 |
62 | public Method getMethod() {
63 | return method;
64 | }
65 |
66 | public List getMethods() {
67 | return methods;
68 | }
69 |
70 | public String getName() {
71 | return name;
72 | }
73 |
74 | public String[] getReplace() {
75 | return replace;
76 | }
77 |
78 | public int getType() {
79 | return type;
80 | }
81 |
82 | public void setDatabaseFormat(String databaseFormat) {
83 | this.databaseFormat = databaseFormat;
84 | }
85 |
86 | public void setFormat(String format) {
87 | this.format = format;
88 | }
89 |
90 | public void setMethod(Method method) {
91 | this.method = method;
92 | }
93 |
94 | public void setMethods(List methods) {
95 | this.methods = methods;
96 | }
97 |
98 | public void setName(String name) {
99 | this.name = name;
100 | }
101 |
102 | public void setReplace(String[] replace) {
103 | this.replace = replace;
104 | }
105 |
106 | public void setType(int type) {
107 | this.type = type;
108 | }
109 |
110 | }
111 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/org/jeecgframework/poi/excel/html/helper/MergedRegionHelper.java:
--------------------------------------------------------------------------------
1 | package org.jeecgframework.poi.excel.html.helper;
2 |
3 | import java.util.HashMap;
4 | import java.util.HashSet;
5 | import java.util.Map;
6 | import java.util.Set;
7 |
8 | import org.apache.poi.ss.usermodel.Sheet;
9 |
10 | /**
11 | * 合并单元格帮助类
12 | * @author JueYue
13 | * @date 2015年5月9日 下午2:13:35
14 | */
15 | public class MergedRegionHelper {
16 |
17 | private Map mergedCache = new HashMap();
18 |
19 | private Set notNeedCread = new HashSet();
20 |
21 | public MergedRegionHelper(Sheet sheet) {
22 | getAllMergedRegion(sheet);
23 | }
24 |
25 | private void getAllMergedRegion(Sheet sheet) {
26 | int nums = sheet.getNumMergedRegions();
27 | for (int i = 0; i < nums; i++) {
28 | handerMergedString(sheet.getMergedRegion(i).formatAsString());
29 | }
30 | }
31 |
32 | /**
33 | * 根据合并输出内容,处理合并单元格事情
34 | * @param formatAsString
35 | */
36 | private void handerMergedString(String formatAsString) {
37 | String[] strArr = formatAsString.split(":");
38 | if (strArr.length == 2) {
39 | int startCol = strArr[0].charAt(0) - 65;
40 | if (strArr[0].charAt(1) >= 65) {
41 | startCol = (startCol + 1) * 26 + (strArr[0].charAt(1) - 65);
42 | }
43 | int startRol = Integer.valueOf(strArr[0].substring(strArr[0].charAt(1) >= 65 ? 2 : 1));
44 | int endCol = strArr[1].charAt(0) - 65;
45 | if (strArr[1].charAt(1) >= 65) {
46 | endCol = (endCol + 1) * 26 + (strArr[1].charAt(1) - 65);
47 | }
48 | int endRol = Integer.valueOf(strArr[1].substring(strArr[1].charAt(1) >= 65 ? 2 : 1));
49 | mergedCache.put(startRol + "_" + startCol, new Integer[] { endRol - startRol + 1,
50 | endCol - startCol + 1 });
51 | for (int i = startRol; i <= endRol; i++) {
52 | for (int j = startCol; j <= endCol; j++) {
53 | notNeedCread.add(i + "_" + j);
54 | }
55 | }
56 | notNeedCread.remove(startRol + "_" + startCol);
57 | }
58 |
59 | }
60 |
61 | /**
62 | * 是不是需要创建这个TD
63 | * @param row
64 | * @param col
65 | * @return
66 | */
67 | public boolean isNeedCreate(int row, int col) {
68 | return !notNeedCread.contains(row + "_" + col);
69 | }
70 |
71 | /**
72 | * 是不是合并区域
73 | * @param row
74 | * @param col
75 | * @return
76 | */
77 | public boolean isMergedRegion(int row, int col) {
78 | return mergedCache.containsKey(row + "_" + col);
79 | }
80 |
81 | /**
82 | * 获取合并区域
83 | * @param row
84 | * @param col
85 | * @return
86 | */
87 | public Integer[] getRowAndColSpan(int row, int col) {
88 | return mergedCache.get(row + "_" + col);
89 | }
90 |
91 | }
92 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/org/jeecgframework/poi/excel/export/styler/ExcelExportStylerDefaultImpl.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.jeecgframework.poi.excel.export.styler;
17 |
18 | import org.apache.poi.ss.usermodel.CellStyle;
19 | import org.apache.poi.ss.usermodel.Font;
20 | import org.apache.poi.ss.usermodel.Workbook;
21 |
22 | /**
23 | * 样式的默认实现
24 | * @author JueYue
25 | * @date 2015年1月9日 下午5:36:08
26 | */
27 | public class ExcelExportStylerDefaultImpl extends AbstractExcelExportStyler implements
28 | IExcelExportStyler {
29 |
30 | public ExcelExportStylerDefaultImpl(Workbook workbook) {
31 | super.createStyles(workbook);
32 | }
33 |
34 | @Override
35 | public CellStyle getTitleStyle(short color) {
36 | CellStyle titleStyle = workbook.createCellStyle();
37 | titleStyle.setAlignment(CellStyle.ALIGN_CENTER);
38 | titleStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
39 | titleStyle.setWrapText(true);
40 | return titleStyle;
41 | }
42 |
43 | @Override
44 | public CellStyle stringSeptailStyle(Workbook workbook, boolean isWarp) {
45 | CellStyle style = workbook.createCellStyle();
46 | style.setAlignment(CellStyle.ALIGN_CENTER);
47 | style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
48 | style.setDataFormat(STRING_FORMAT);
49 | if (isWarp) {
50 | style.setWrapText(true);
51 | }
52 | return style;
53 | }
54 |
55 | @Override
56 | public CellStyle getHeaderStyle(short color) {
57 | CellStyle titleStyle = workbook.createCellStyle();
58 | Font font = workbook.createFont();
59 | font.setFontHeightInPoints((short) 12);
60 | titleStyle.setFont(font);
61 | titleStyle.setAlignment(CellStyle.ALIGN_CENTER);
62 | titleStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
63 | return titleStyle;
64 | }
65 |
66 | @Override
67 | public CellStyle stringNoneStyle(Workbook workbook, boolean isWarp) {
68 | CellStyle style = workbook.createCellStyle();
69 | style.setAlignment(CellStyle.ALIGN_CENTER);
70 | style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
71 | style.setDataFormat(STRING_FORMAT);
72 | if (isWarp) {
73 | style.setWrapText(true);
74 | }
75 | return style;
76 | }
77 |
78 | }
79 |
--------------------------------------------------------------------------------
/easypoi-web/src/main/java/org/jeecgframework/poi/excel/view/JeecgTemplateWordView.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.jeecgframework.poi.excel.view;
17 |
18 | import java.util.Map;
19 |
20 | import javax.servlet.ServletOutputStream;
21 | import javax.servlet.http.HttpServletRequest;
22 | import javax.servlet.http.HttpServletResponse;
23 |
24 | import org.apache.poi.xwpf.usermodel.XWPFDocument;
25 | import org.jeecgframework.poi.excel.entity.vo.TemplateWordConstants;
26 | import org.jeecgframework.poi.word.WordExportUtil;
27 | import org.springframework.stereotype.Controller;
28 | import org.springframework.web.servlet.view.AbstractView;
29 |
30 | /**
31 | * Word模板视图
32 | *
33 | * @author JueYue
34 | * @date 2014年6月30日 下午9:15:49
35 | */
36 | @SuppressWarnings("unchecked")
37 | @Controller(TemplateWordConstants.JEECG_TEMPLATE_WORD_VIEW)
38 | public class JeecgTemplateWordView extends AbstractView {
39 |
40 | private static final String CONTENT_TYPE = "application/msword";
41 |
42 | public JeecgTemplateWordView() {
43 | setContentType(CONTENT_TYPE);
44 | }
45 |
46 | public boolean isIE(HttpServletRequest request) {
47 | return (request.getHeader("USER-AGENT").toLowerCase().indexOf("msie") > 0 || request
48 | .getHeader("USER-AGENT").toLowerCase().indexOf("rv:11.0") > 0) ? true : false;
49 | }
50 |
51 | @Override
52 | protected void renderMergedOutputModel(Map model, HttpServletRequest request,
53 | HttpServletResponse response) throws Exception {
54 | String codedFileName = "临时文件.docx";
55 | if (model.containsKey(TemplateWordConstants.FILE_NAME)) {
56 | codedFileName = (String) model.get(TemplateWordConstants.FILE_NAME) + ".docx";
57 | }
58 | if (isIE(request)) {
59 | codedFileName = java.net.URLEncoder.encode(codedFileName, "UTF8");
60 | } else {
61 | codedFileName = new String(codedFileName.getBytes("UTF-8"), "ISO-8859-1");
62 | }
63 | response.setHeader("content-disposition", "attachment;filename=" + codedFileName);
64 | XWPFDocument document = WordExportUtil.exportWord07(
65 | (String) model.get(TemplateWordConstants.URL),
66 | (Map) model.get(TemplateWordConstants.MAP_DATA));
67 | ServletOutputStream out = response.getOutputStream();
68 | document.write(out);
69 | out.flush();
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/org/jeecgframework/poi/excel/entity/params/ExcelImportEntity.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.jeecgframework.poi.excel.entity.params;
17 |
18 | import java.util.List;
19 |
20 | /**
21 | * excel 导入工具类,对cell类型做映射
22 | * @author JueYue
23 | * @version 1.0 2013年8月24日
24 | */
25 | public class ExcelImportEntity extends ExcelBaseEntity {
26 | /**
27 | * 对应 Collection NAME
28 | */
29 | private String collectionName;
30 | /**
31 | * 保存图片的地址
32 | */
33 | private String saveUrl;
34 | /**
35 | * 保存图片的类型,1是文件,2是数据库
36 | */
37 | private int saveType;
38 | /**
39 | * 对应exportType
40 | */
41 | private String classType;
42 | /**
43 | * 校驗參數
44 | */
45 | private ExcelVerifyEntity verify;
46 | /**
47 | * 后缀
48 | */
49 | private String suffix;
50 |
51 | private List list;
52 |
53 | public String getClassType() {
54 | return classType;
55 | }
56 |
57 | public String getCollectionName() {
58 | return collectionName;
59 | }
60 |
61 | public List getList() {
62 | return list;
63 | }
64 |
65 | public int getSaveType() {
66 | return saveType;
67 | }
68 |
69 | public String getSaveUrl() {
70 | return saveUrl;
71 | }
72 |
73 | public ExcelVerifyEntity getVerify() {
74 | return verify;
75 | }
76 |
77 | public void setClassType(String classType) {
78 | this.classType = classType;
79 | }
80 |
81 | public void setCollectionName(String collectionName) {
82 | this.collectionName = collectionName;
83 | }
84 |
85 | public void setList(List list) {
86 | this.list = list;
87 | }
88 |
89 | public void setSaveType(int saveType) {
90 | this.saveType = saveType;
91 | }
92 |
93 | public void setSaveUrl(String saveUrl) {
94 | this.saveUrl = saveUrl;
95 | }
96 |
97 | public void setVerify(ExcelVerifyEntity verify) {
98 | this.verify = verify;
99 | }
100 |
101 | public String getSuffix() {
102 | return suffix;
103 | }
104 |
105 | public void setSuffix(String suffix) {
106 | this.suffix = suffix;
107 | }
108 |
109 | }
110 |
--------------------------------------------------------------------------------
/easypoi-web/src/main/java/org/jeecgframework/poi/excel/view/JeecgMapExcelView.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.jeecgframework.poi.excel.view;
17 |
18 | import java.util.Collection;
19 | import java.util.List;
20 | import java.util.Map;
21 |
22 | import javax.servlet.ServletOutputStream;
23 | import javax.servlet.http.HttpServletRequest;
24 | import javax.servlet.http.HttpServletResponse;
25 |
26 | import org.apache.poi.hssf.usermodel.HSSFWorkbook;
27 | import org.apache.poi.ss.usermodel.Workbook;
28 | import org.jeecgframework.poi.excel.ExcelExportUtil;
29 | import org.jeecgframework.poi.excel.entity.ExportParams;
30 | import org.jeecgframework.poi.excel.entity.params.ExcelExportEntity;
31 | import org.jeecgframework.poi.excel.entity.vo.MapExcelConstants;
32 | import org.springframework.stereotype.Controller;
33 |
34 | /**
35 | * Map 对象接口
36 | *
37 | * @author JueYue
38 | * @date 2014年11月25日 下午3:26:32
39 | */
40 | @SuppressWarnings("unchecked")
41 | @Controller(MapExcelConstants.JEECG_MAP_EXCEL_VIEW)
42 | public class JeecgMapExcelView extends MiniAbstractExcelView {
43 |
44 | public JeecgMapExcelView() {
45 | super();
46 | }
47 |
48 | @Override
49 | protected void renderMergedOutputModel(Map model, HttpServletRequest request,
50 | HttpServletResponse response) throws Exception {
51 | String codedFileName = "临时文件";
52 | Workbook workbook = ExcelExportUtil.exportExcel(
53 | (ExportParams) model.get(MapExcelConstants.PARAMS),
54 | (List) model.get(MapExcelConstants.ENTITY_LIST),
55 | (Collection extends Map, ?>>) model.get(MapExcelConstants.MAP_LIST));
56 | if (model.containsKey(MapExcelConstants.FILE_NAME)) {
57 | codedFileName = (String) model.get(MapExcelConstants.FILE_NAME);
58 | }
59 | if (workbook instanceof HSSFWorkbook) {
60 | codedFileName += HSSF;
61 | } else {
62 | codedFileName += XSSF;
63 | }
64 | if (isIE(request)) {
65 | codedFileName = java.net.URLEncoder.encode(codedFileName, "UTF8");
66 | } else {
67 | codedFileName = new String(codedFileName.getBytes("UTF-8"), "ISO-8859-1");
68 | }
69 | response.setHeader("content-disposition", "attachment;filename=" + codedFileName);
70 | ServletOutputStream out = response.getOutputStream();
71 | workbook.write(out);
72 | out.flush();
73 | }
74 |
75 | }
76 |
--------------------------------------------------------------------------------
/easypoi-web/src/main/java/org/jeecgframework/poi/excel/view/JeecgTemplateExcelView.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.jeecgframework.poi.excel.view;
17 |
18 | import java.util.List;
19 | import java.util.Map;
20 |
21 | import javax.servlet.ServletOutputStream;
22 | import javax.servlet.http.HttpServletRequest;
23 | import javax.servlet.http.HttpServletResponse;
24 |
25 | import org.apache.poi.hssf.usermodel.HSSFWorkbook;
26 | import org.apache.poi.ss.usermodel.Workbook;
27 | import org.jeecgframework.poi.excel.ExcelExportUtil;
28 | import org.jeecgframework.poi.excel.entity.TemplateExportParams;
29 | import org.jeecgframework.poi.excel.entity.vo.NormalExcelConstants;
30 | import org.jeecgframework.poi.excel.entity.vo.TemplateExcelConstants;
31 | import org.springframework.stereotype.Controller;
32 |
33 | /**
34 | * Excel模板视图
35 | *
36 | * @author JueYue
37 | * @date 2014年6月30日 下午9:15:49
38 | */
39 | @SuppressWarnings("unchecked")
40 | @Controller(TemplateExcelConstants.JEECG_TEMPLATE_EXCEL_VIEW)
41 | public class JeecgTemplateExcelView extends MiniAbstractExcelView {
42 |
43 | public JeecgTemplateExcelView() {
44 | super();
45 | }
46 |
47 | @Override
48 | protected void renderMergedOutputModel(Map model, HttpServletRequest request,
49 | HttpServletResponse response) throws Exception {
50 | String codedFileName = "临时文件";
51 | Workbook workbook = ExcelExportUtil.exportExcel(
52 | (TemplateExportParams) model.get(TemplateExcelConstants.PARAMS),
53 | (Class>) model.get(TemplateExcelConstants.CLASS),
54 | (List>) model.get(TemplateExcelConstants.LIST_DATA),
55 | (Map) model.get(TemplateExcelConstants.MAP_DATA));
56 | if (model.containsKey(NormalExcelConstants.FILE_NAME)) {
57 | codedFileName = (String) model.get(NormalExcelConstants.FILE_NAME);
58 | }
59 | if (workbook instanceof HSSFWorkbook) {
60 | codedFileName += HSSF;
61 | } else {
62 | codedFileName += XSSF;
63 | }
64 | if (isIE(request)) {
65 | codedFileName = java.net.URLEncoder.encode(codedFileName, "UTF8");
66 | } else {
67 | codedFileName = new String(codedFileName.getBytes("UTF-8"), "ISO-8859-1");
68 | }
69 | response.setHeader("content-disposition", "attachment;filename=" + codedFileName);
70 | ServletOutputStream out = response.getOutputStream();
71 | workbook.write(out);
72 | out.flush();
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/org/jeecgframework/poi/word/parse/excel/ExcelMapParse.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.jeecgframework.poi.word.parse.excel;
17 |
18 | import java.util.List;
19 |
20 | import org.apache.poi.xwpf.usermodel.XWPFTable;
21 | import org.apache.poi.xwpf.usermodel.XWPFTableCell;
22 | import org.apache.poi.xwpf.usermodel.XWPFTableRow;
23 | import org.jeecgframework.poi.util.PoiPublicUtil;
24 |
25 | /**
26 | * 处理和生成Map 类型的数据变成表格
27 | * @author JueYue
28 | * @date 2014年8月9日 下午10:28:46
29 | */
30 | public final class ExcelMapParse {
31 |
32 | /**
33 | * 解析参数行,获取参数列表
34 | *
35 | * @Author JueYue
36 | * @date 2013-11-18
37 | * @param currentRow
38 | * @return
39 | */
40 | private static String[] parseCurrentRowGetParams(XWPFTableRow currentRow) {
41 | List cells = currentRow.getTableCells();
42 | String[] params = new String[cells.size()];
43 | String text;
44 | for (int i = 0; i < cells.size(); i++) {
45 | text = cells.get(i).getText();
46 | params[i] = text == null ? "" : text.trim().replace("{{", "").replace("}}", "");
47 | }
48 | return params;
49 | }
50 |
51 | /**
52 | * 解析下一行,并且生成更多的行
53 | *
54 | * @Author JueYue
55 | * @date 2013-11-18
56 | * @param table
57 | * @param listobj2
58 | */
59 | public static void parseNextRowAndAddRow(XWPFTable table, int index, List