write(Collection data);
27 |
28 | /**
29 | * 关闭流,完成业务
30 | *
31 | * @return
32 | */
33 | public T close();
34 | }
35 |
--------------------------------------------------------------------------------
/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.m2e.core.maven2Nature
21 | org.springsource.ide.eclipse.gradle.core.nature
22 | org.eclipse.jdt.core.javanature
23 |
24 |
25 |
--------------------------------------------------------------------------------
/easypoi-base/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5 | org.eclipse.jdt.core.compiler.compliance=1.6
6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate
8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
11 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
12 | org.eclipse.jdt.core.compiler.source=1.6
13 |
--------------------------------------------------------------------------------
/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.springsource.ide.eclipse.gradle.core.nature
21 | org.eclipse.jdt.core.javanature
22 | org.eclipse.m2e.core.maven2Nature
23 |
24 |
25 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/graph/entity/ExcelTitleCell.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package cn.afterturn.easypoi.excel.graph.entity;
5 |
6 | /**
7 | * @author xfowrld
8 | * @since 2015-12-30
9 | * @version 1.0
10 | *
11 | */
12 | public class ExcelTitleCell
13 | {
14 | private Integer row;
15 | private Integer col;
16 |
17 | public ExcelTitleCell(){
18 |
19 | }
20 |
21 | public ExcelTitleCell(Integer row,Integer col){
22 | this.row=row;
23 | this.col=col;
24 | }
25 |
26 | public Integer getRow()
27 | {
28 | return row;
29 | }
30 | public void setRow(Integer row)
31 | {
32 | this.row = row;
33 | }
34 | public Integer getCol()
35 | {
36 | return col;
37 | }
38 | public void setCol(Integer col)
39 | {
40 | this.col = col;
41 | }
42 |
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/cn/afterturn/easypoi/handler/inter/IExcelDictHandler.java:
--------------------------------------------------------------------------------
1 | package cn.afterturn.easypoi.handler.inter;
2 |
3 | /**
4 | * @author jueyue on 18-2-2.
5 | * @version 3.0.4
6 | */
7 | public interface IExcelDictHandler {
8 |
9 | /**
10 | * 从值翻译到名称
11 | *
12 | * @param dict 字典Key
13 | * @param obj 对象
14 | * @param name 属性名称
15 | * @param value 属性值
16 | * @return
17 | */
18 | public String toName(String dict, Object obj, String name, Object value);
19 |
20 | /**
21 | * 从名称翻译到值
22 | *
23 | * @param dict 字典Key
24 | * @param obj 对象
25 | * @param name 属性名称
26 | * @param value 属性值
27 | * @return
28 | */
29 | public String toValue(String dict, Object obj, String name, Object value);
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/cn/afterturn/easypoi/pdf/package-info.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 | /**
17 | * EasyPOI的PDF模块
18 | * @author JueYue
19 | * 2015年10月6日 下午8:13:19
20 | */
21 | package cn.afterturn.easypoi.pdf;
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/cn/afterturn/easypoi/word/package-info.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 | /**
17 | * Word 模块,因为2003不好用,所以都是基于2007来处理的数据
18 | * @author JueYue
19 | * 2014年6月20日 上午12:08:09
20 | */
21 | package cn.afterturn.easypoi.word;
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/package-info.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 | /**
17 | * Excel模块,支持2003,2007的导入导出,模板的导出,流的导出(大数据量)
18 | * @author JueYue
19 | * 2014年6月20日 上午12:08:09
20 | */
21 | package cn.afterturn.easypoi.excel;
--------------------------------------------------------------------------------
/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.springsource.ide.eclipse.gradle.core.nature
26 | org.eclipse.jdt.core.javanature
27 | org.springframework.ide.eclipse.core.springnature
28 | org.eclipse.m2e.core.maven2Nature
29 |
30 |
31 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/cn/afterturn/easypoi/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 cn.afterturn.easypoi.excel.entity.enmus;
17 |
18 | /**
19 | * Excel Type
20 | * @author JueYue
21 | * 2014年12月29日 下午9:08:21
22 | */
23 | public enum ExcelType {
24 |
25 | HSSF , XSSF;
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/cn/afterturn/easypoi/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 cn.afterturn.easypoi.excel.entity.enmus;
17 |
18 | /**
19 | * Cell 值得类型
20 | * @author JueYue
21 | * 2014年12月29日 下午10:20:49
22 | */
23 | public enum CellValueType {
24 |
25 | InlineStr, String, Number, Boolean, Date, TElement, Null, Formula, None;
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/cn/afterturn/easypoi/cache/manager/IFileLoader.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 cn.afterturn.easypoi.cache.manager;
17 |
18 | /**
19 | * 缓存读取
20 | * @author JueYue
21 | * 默认实现是FileLoader
22 | * 2015年10月17日 下午7:12:01
23 | */
24 | public interface IFileLoader {
25 | /**
26 | * 可以自定义KEY的作用
27 | * @param key
28 | * @return
29 | */
30 | public byte[] getFile(String key);
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/cn/afterturn/easypoi/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-base/src/main/java/cn/afterturn/easypoi/excel/html/entity/ExcelCssConstant.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2017 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 cn.afterturn.easypoi.excel.html.entity;
17 |
18 | /**
19 | * Excel 自定义处理的自定义Html标签
20 | * @author JueYue
21 | * 2017年3月26日
22 | */
23 | public interface ExcelCssConstant {
24 |
25 | public final String SHEET_NAME = "sheetName";
26 | public final String FREEZE_ROW = "freezeRow";
27 | public final String FREEZE_COL = "freezeCol";
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/cn/afterturn/easypoi/handler/inter/IReadHandler.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 cn.afterturn.easypoi.handler.inter;
17 |
18 | /**
19 | * 接口自定义处理类
20 | * @author JueYue
21 | * 2015年1月16日 下午8:06:26
22 | * @param
23 | */
24 | public interface IReadHandler {
25 | /**
26 | * 处理解析对象
27 | * @param t
28 | */
29 | public void handler(T t);
30 |
31 |
32 | /**
33 | * 处理完成之后的业务
34 | */
35 | public void doAfterAll();
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/cn/afterturn/easypoi/handler/inter/IExcelModel.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 cn.afterturn.easypoi.handler.inter;
17 |
18 | /**
19 | * Excel标记类
20 | * @author JueYue
21 | * 2015年10月31日 下午9:31:47
22 | */
23 | public interface IExcelModel {
24 |
25 | /**
26 | * 获取错误数据
27 | * @return
28 | */
29 | public String getErrorMsg();
30 |
31 | /**
32 | * 设置错误信息
33 | * @param errorMsg
34 | */
35 | public void setErrorMsg(String errorMsg);
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/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 |
28 |
--------------------------------------------------------------------------------
/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 |
28 |
--------------------------------------------------------------------------------
/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 |
28 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/cn/afterturn/easypoi/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 cn.afterturn.easypoi.excel.imports.sax.parse;
17 |
18 | import java.util.List;
19 |
20 | import cn.afterturn.easypoi.excel.entity.sax.SaxReadCellEntity;
21 |
22 | /**
23 | * @author jueyue
24 | * @since 3.1
25 | * @date 2017-11-9 13:04:06
26 | */
27 | public interface ISaxRowRead {
28 | /**
29 | * 解析数据
30 | * @param index
31 | * @param cellList
32 | */
33 | void parse(int index, List cellList);
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/easypoi-annotation/src/main/java/cn/afterturn/easypoi/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 cn.afterturn.easypoi.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 | * 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/cn/afterturn/easypoi/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 cn.afterturn.easypoi.entity.vo;
17 |
18 | /**
19 | * 基础POI常量
20 | * @author JueYue
21 | * 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/cn/afterturn/easypoi/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 cn.afterturn.easypoi.handler.inter;
17 |
18 | import cn.afterturn.easypoi.excel.entity.result.ExcelVerifyHandlerResult;
19 |
20 | /**
21 | * 导入校验接口
22 | *
23 | * @author JueYue
24 | * 2014年6月23日 下午11:08:21
25 | */
26 | public interface IExcelVerifyHandler {
27 |
28 | /**
29 | * 导入校验方法
30 | *
31 | * @param obj
32 | * 当前对象
33 | * @return
34 | */
35 | public ExcelVerifyHandlerResult verifyHandler(T obj);
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/easypoi-web/src/main/java/cn/afterturn/easypoi/entity/vo/PDFTemplateConstants.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 cn.afterturn.easypoi.entity.vo;
17 |
18 | public interface PDFTemplateConstants extends BasePOIConstants {
19 |
20 | /**
21 | * PDF
22 | */
23 | public final static String EASYPOI_PDF_TEMPLATE_VIEW = "easypoiPdfTemplateView";
24 | /**
25 | * Entity List
26 | */
27 | public final static String ENTITY_LIST = "EntityList";
28 | /**
29 | * 数据列表
30 | */
31 | public final static String DATA_LIST = "dataList";
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/cn/afterturn/easypoi/util/WebFilenameUtils.java:
--------------------------------------------------------------------------------
1 | package cn.afterturn.easypoi.util;
2 |
3 | import org.apache.commons.lang3.StringUtils;
4 | import org.slf4j.Logger;
5 | import org.slf4j.LoggerFactory;
6 |
7 | import java.io.UnsupportedEncodingException;
8 |
9 | /**根据RFC 5987规范生成disposition值, 解决浏览器兼容以及中文乱码问题
10 | * @author halfdo
11 | * @date 6/25/2019
12 | */
13 | public class WebFilenameUtils {
14 |
15 | private static final Logger LOGGER = LoggerFactory.getLogger(WebFilenameUtils.class);
16 |
17 | private static final String DISPOSITION_FORMAT = "attachment; filename=\"%s\"; filename*=utf-8''%s";
18 |
19 | /**
20 | * 未编码文件名转Content-Disposition值
21 | *
22 | * @param filename 未编码的文件名(包含文件后缀)
23 | * @return Content-Disposition值
24 | */
25 | public static String disposition(String filename) {
26 | String codedFilename = filename;
27 | try {
28 | if (StringUtils.isNotBlank(filename)) {
29 | codedFilename = java.net.URLEncoder.encode(filename, "UTF-8");
30 | }
31 | } catch (UnsupportedEncodingException e) {
32 | LOGGER.error("不支持的编码:", e);
33 | }
34 | return String.format(DISPOSITION_FORMAT, codedFilename, codedFilename);
35 |
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/easypoi-annotation/src/main/java/cn/afterturn/easypoi/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 cn.afterturn.easypoi.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 | }
38 |
--------------------------------------------------------------------------------
/easypoi-web/src/main/java/cn/afterturn/easypoi/entity/vo/BigExcelConstants.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 cn.afterturn.easypoi.entity.vo;
17 |
18 | /**
19 | * 正常导出Excel
20 | * @author JueYue on 14-3-8.
21 | * 静态常量
22 | */
23 | public interface BigExcelConstants extends BasePOIConstants {
24 | /**
25 | * 单Sheet导出
26 | */
27 | public final static String EASYPOI_BIG_EXCEL_VIEW = "easypoiBigExcelView";
28 | /**
29 | * 查询参数
30 | */
31 | public final static String DATA_PARAMS = "dataParams";
32 | /**
33 | * 查询函数
34 | */
35 | public final static String DATA_INTER = "dataInter";
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/easypoi-web/src/main/java/cn/afterturn/easypoi/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 cn.afterturn.easypoi.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 EASYPOI_EXCEL_VIEW = "easypoiExcelView";
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/cn/afterturn/easypoi/excel/html/css/ICssConvertToHtml.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 cn.afterturn.easypoi.excel.html.css;
17 |
18 | import org.apache.poi.ss.usermodel.Cell;
19 | import org.apache.poi.ss.usermodel.CellStyle;
20 |
21 | import cn.afterturn.easypoi.excel.html.entity.style.CellStyleEntity;
22 |
23 | /**
24 | * CSS Cell Style 转换类
25 | * @author JueYue
26 | * 2016年3月20日 下午4:53:04
27 | */
28 | public interface ICssConvertToHtml {
29 | /**
30 | * 把Excel单元格样式转换成HTML样式
31 | * @param cell
32 | *
33 | */
34 | public String convertToHtml(Cell cell, CellStyle cellStyle, CellStyleEntity style);
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/easypoi-web/src/main/java/cn/afterturn/easypoi/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 cn.afterturn.easypoi.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 EASYPOI_MAP_EXCEL_VIEW = "easypoiMapExcelView";
28 | /**
29 | * Entity List
30 | */
31 | public final static String ENTITY_LIST = "EntityList";
32 | /**
33 | * 数据列表
34 | */
35 | public final static String MAP_LIST = "mapList";
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/cn/afterturn/easypoi/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 cn.afterturn.easypoi.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-base/src/main/java/cn/afterturn/easypoi/excel/html/css/ICssConvertToExcel.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 cn.afterturn.easypoi.excel.html.css;
17 |
18 | import org.apache.poi.ss.usermodel.Cell;
19 | import org.apache.poi.ss.usermodel.CellStyle;
20 |
21 | import cn.afterturn.easypoi.excel.html.entity.style.CellStyleEntity;
22 |
23 | /**
24 | * CSS Cell Style 转换类
25 | * @author JueYue
26 | * 2016年3月20日 下午4:53:04
27 | */
28 | public interface ICssConvertToExcel {
29 | /**
30 | * 把HTML样式转换成Cell样式
31 | * @param cell
32 | * @param style
33 | */
34 | public void convertToExcel(Cell cell, CellStyle cellStyle, CellStyleEntity style);
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/easypoi-web/src/main/java/cn/afterturn/easypoi/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 cn.afterturn.easypoi.entity.vo;
17 |
18 | /**
19 | * Word 导出模板常量
20 | * @author JueYue
21 | * 2014年7月24日 下午11:26:46
22 | */
23 | public interface TemplateWordConstants extends BasePOIConstants {
24 | /**
25 | * 模板导出
26 | */
27 | public final static String EASYPOI_TEMPLATE_WORD_VIEW = "easypoiTemplateWordView";
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/cn/afterturn/easypoi/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 cn.afterturn.easypoi.entity.vo;
17 |
18 | /**
19 | * 模板Excel导出常量
20 | * @author JueYue
21 | * 2014年6月30日 下午9:26:52
22 | */
23 | public interface TemplateExcelConstants extends BasePOIConstants {
24 | /**
25 | * 模板导出
26 | */
27 | public final static String EASYPOI_TEMPLATE_EXCEL_VIEW = "easypoiTemplateExcelView";
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/cn/afterturn/easypoi/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 cn.afterturn.easypoi.exception.excel.enums;
17 |
18 | /**
19 | * 导出异常类型枚举
20 | * @author JueYue
21 | * 2014年6月19日 下午10:59:51
22 | */
23 | public enum ExcelImportEnum {
24 | PARAMETER_ERROR("参数错误"),
25 | IS_NOT_A_VALID_TEMPLATE("不是合法的Excel模板"),
26 | GET_VALUE_ERROR("Excel 值获取失败"),
27 | VERIFY_ERROR("值校验失败");
28 |
29 | private String msg;
30 |
31 | ExcelImportEnum(String msg) {
32 | this.msg = msg;
33 | }
34 |
35 | public String getMsg() {
36 | return msg;
37 | }
38 |
39 | public void setMsg(String msg) {
40 | this.msg = msg;
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/cn/afterturn/easypoi/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 cn.afterturn.easypoi.exception.word.enmus;
17 |
18 | /**
19 | * 导出异常枚举
20 | *
21 | * @author JueYue
22 | * 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/cn/afterturn/easypoi/excel/entity/sax/SaxConstant.java:
--------------------------------------------------------------------------------
1 | package cn.afterturn.easypoi.excel.entity.sax;
2 |
3 | /**
4 | * @author by jueyue on 19-6-20.
5 | */
6 | public interface SaxConstant {
7 |
8 | /**
9 | * Row 表达式
10 | */
11 | public static String ROW = "row";
12 | /**
13 | * cell 的位置
14 | */
15 | public static String ROW_COL = "r";
16 | /**
17 | * cell 表达式
18 | */
19 | public static String COL = "c";
20 | /**
21 | * tElement 表达式
22 | */
23 | public static String T_ELEMENT = "t";
24 | /**
25 | * cell 类型
26 | */
27 | public static String TYPE = "t";
28 | /**
29 | * style 缩写
30 | */
31 | public static String STYLE = "s";
32 | /**
33 | * String 缩写
34 | */
35 | public static String STRING = "s";
36 | /**
37 | * date 缩写
38 | */
39 | public static String DATE = "d";
40 | /**
41 | * number 缩写
42 | */
43 | public static String NUMBER = "n";
44 | /**
45 | * 计算表达式
46 | */
47 | public static String FORMULA = "str";
48 | /**
49 | * Boolean 缩写
50 | */
51 | public static String BOOLEAN = "b";
52 | /**
53 | * 类型值为“inlineStr”,表示这个单元格的字符串并没有用共享字符串池子的值
54 | */
55 | public static String INLINE_STR = "inlineStr";
56 |
57 |
58 | /**
59 | * value 缩写
60 | */
61 | public static String VALUE = "v";
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/cn/afterturn/easypoi/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 cn.afterturn.easypoi.exception.word;
17 |
18 | import cn.afterturn.easypoi.exception.word.enmus.WordExportEnum;
19 |
20 | /**
21 | * word导出异常
22 | *
23 | * @author JueYue
24 | * 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-base/src/main/java/cn/afterturn/easypoi/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 cn.afterturn.easypoi.exception.excel.enums;
17 |
18 | /**
19 | * 导出异常类型枚举
20 | * @author JueYue
21 | * 2014年6月19日 下午10:59:51
22 | */
23 | public enum ExcelExportEnum {
24 |
25 | PARAMETER_ERROR ("Excel 导出 参数错误") ,
26 | EXPORT_ERROR ("Excel导出错误") ,
27 | HTML_ERROR ("Excel导出Html流错误") ,
28 | TEMPLATE_ERROR ("Excel 模板错误");
29 |
30 | private String msg;
31 |
32 | ExcelExportEnum(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 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | easypoi
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.m2e.core.maven2Nature
21 | org.eclipse.jdt.core.javanature
22 |
23 |
24 |
25 | 1464242916850
26 |
27 | 26
28 |
29 | org.eclipse.ui.ide.orFilterMatcher
30 |
31 |
32 | org.eclipse.ui.ide.multiFilter
33 | 1.0-projectRelativePath-equals-true-false-easypoi-annotation
34 |
35 |
36 | org.eclipse.ui.ide.multiFilter
37 | 1.0-projectRelativePath-equals-true-false-easypoi-base
38 |
39 |
40 | org.eclipse.ui.ide.multiFilter
41 | 1.0-projectRelativePath-equals-true-false-easypoi-web
42 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/entity/result/ExcelVerifyHandlerResult.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 cn.afterturn.easypoi.excel.entity.result;
17 |
18 | import lombok.Data;
19 |
20 | /**
21 | * Excel导入处理返回结果
22 | *
23 | * @author JueYue
24 | * 2014年6月23日 下午11:03:29
25 | */
26 | @Data
27 | public class ExcelVerifyHandlerResult {
28 | /**
29 | * 是否正确
30 | */
31 | private boolean success;
32 | /**
33 | * 错误信息
34 | */
35 | private String msg;
36 |
37 | public ExcelVerifyHandlerResult() {
38 |
39 | }
40 |
41 | public ExcelVerifyHandlerResult(boolean success) {
42 | this.success = success;
43 | }
44 |
45 | public ExcelVerifyHandlerResult(boolean success, String msg) {
46 | this.success = success;
47 | this.msg = msg;
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/graph/entity/ExcelGraphElement.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package cn.afterturn.easypoi.excel.graph.entity;
5 |
6 | import cn.afterturn.easypoi.excel.graph.constant.ExcelGraphElementType;
7 |
8 |
9 | /**
10 | * @author xfworld
11 | * @since 2015-12-30
12 | * @version 1.0
13 | *
14 | */
15 | public class ExcelGraphElement
16 | {
17 | private Integer startRowNum;
18 | private Integer endRowNum;
19 | private Integer startColNum;
20 | private Integer endColNum;
21 | private Integer elementType=ExcelGraphElementType.STRING_TYPE;
22 |
23 |
24 | public Integer getStartRowNum()
25 | {
26 | return startRowNum;
27 | }
28 | public void setStartRowNum(Integer startRowNum)
29 | {
30 | this.startRowNum = startRowNum;
31 | }
32 | public Integer getEndRowNum()
33 | {
34 | return endRowNum;
35 | }
36 | public void setEndRowNum(Integer endRowNum)
37 | {
38 | this.endRowNum = endRowNum;
39 | }
40 | public Integer getStartColNum()
41 | {
42 | return startColNum;
43 | }
44 | public void setStartColNum(Integer startColNum)
45 | {
46 | this.startColNum = startColNum;
47 | }
48 | public Integer getEndColNum()
49 | {
50 | return endColNum;
51 | }
52 | public void setEndColNum(Integer endColNum)
53 | {
54 | this.endColNum = endColNum;
55 | }
56 | public Integer getElementType()
57 | {
58 | return elementType;
59 | }
60 | public void setElementType(Integer elementType)
61 | {
62 | this.elementType = elementType;
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/cn/afterturn/easypoi/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 cn.afterturn.easypoi.excel.entity;
17 |
18 | import cn.afterturn.easypoi.handler.inter.IExcelDataHandler;
19 | import cn.afterturn.easypoi.handler.inter.IExcelDictHandler;
20 | import cn.afterturn.easypoi.handler.inter.IExcelI18nHandler;
21 | import lombok.Data;
22 |
23 | /**
24 | * 基础参数
25 | * @author JueYue
26 | * 2014年6月20日 下午1:56:52
27 | */
28 | @Data
29 | public class ExcelBaseParams {
30 |
31 | /**
32 | * 数据处理接口,以此为主,replace,format都在这后面
33 | */
34 | private IExcelDataHandler dataHandler;
35 |
36 | /**
37 | * 字段处理类
38 | */
39 | private IExcelDictHandler dictHandler;
40 | /**
41 | * 国际化处理类
42 | */
43 | private IExcelI18nHandler i18nHandler;
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/cn/afterturn/easypoi/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 cn.afterturn.easypoi.excel.entity.params;
17 |
18 | import lombok.Data;
19 |
20 | import java.util.Map;
21 |
22 | /**
23 | * Excel 对于的 Collection
24 | *
25 | * @author JueYue
26 | * 2013-9-26
27 | * @version 1.0
28 | */
29 | @Data
30 | public class ExcelCollectionParams {
31 |
32 | /**
33 | * 集合对应的名称
34 | */
35 | private String name;
36 | /**
37 | * Excel 列名称
38 | */
39 | private String excelName;
40 | /**
41 | * 实体对象
42 | */
43 | private Class> type;
44 | /**
45 | * 这个list下面的参数集合实体对象
46 | */
47 | private Map excelParams;
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/cn/afterturn/easypoi/csv/CsvImportUtil.java:
--------------------------------------------------------------------------------
1 | package cn.afterturn.easypoi.csv;
2 |
3 | import cn.afterturn.easypoi.csv.entity.CsvImportParams;
4 | import cn.afterturn.easypoi.csv.imports.CsvImportService;
5 | import cn.afterturn.easypoi.handler.inter.IReadHandler;
6 |
7 | import java.io.InputStream;
8 | import java.util.List;
9 |
10 | /**
11 | * CSV 导入工具类
12 | * 具体和Excel类似,但是比Excel简单
13 | * 需要处理一些字符串的处理
14 | *
15 | * @author by jueyue on 18-10-3.
16 | */
17 | public final class CsvImportUtil {
18 |
19 | /**
20 | * Csv 导入流适合大数据导入
21 | * 导入 数据源IO流,不返回校验结果 导入 字段类型 Integer,Long,Double,Date,String,Boolean
22 | *
23 | * @param inputstream
24 | * @param pojoClass
25 | * @param params
26 | * @return
27 | */
28 | public static List importCsv(InputStream inputstream, Class> pojoClass,
29 | CsvImportParams params) {
30 | return new CsvImportService().readExcel(inputstream, pojoClass, params, null);
31 | }
32 |
33 | /**
34 | * Csv 导入流适合大数据导入
35 | * 导入 数据源IO流,不返回校验结果 导入 字段类型 Integer,Long,Double,Date,String,Boolean
36 | *
37 | * @param inputstream
38 | * @param pojoClass
39 | * @param params
40 | * @return
41 | */
42 | public static void importCsv(InputStream inputstream, Class> pojoClass,
43 | CsvImportParams params, IReadHandler readHandler) {
44 | new CsvImportService().readExcel(inputstream, pojoClass, params, readHandler);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/cn/afterturn/easypoi/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 cn.afterturn.easypoi.excel.entity.sax;
17 |
18 | import cn.afterturn.easypoi.excel.entity.enmus.CellValueType;
19 | import lombok.Data;
20 |
21 | /**
22 | * Cell 对象
23 | * @author JueYue
24 | * 2014年12月29日 下午10:12:57
25 | */
26 | @Data
27 | public class SaxReadCellEntity {
28 | /**
29 | * 值类型
30 | */
31 | private CellValueType cellType;
32 | /**
33 | * 值
34 | */
35 | private Object value;
36 |
37 | public SaxReadCellEntity(CellValueType cellType, Object value) {
38 | this.cellType = cellType;
39 | this.value = value;
40 | }
41 |
42 | @Override
43 | public String toString() {
44 | return "[type=" + cellType.toString() + ",value=" + value + "]";
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/cn/afterturn/easypoi/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 cn.afterturn.easypoi.excel.entity.params;
17 |
18 | import lombok.Data;
19 |
20 | import java.util.List;
21 |
22 | /**
23 | * 合并单元格使用对象
24 | *
25 | * Created by jue on 14-6-11.
26 | */
27 | @Data
28 | public class MergeEntity {
29 | /**
30 | * 合并开始行
31 | */
32 | private int startRow;
33 | /**
34 | * 合并结束行
35 | */
36 | private int endRow;
37 | /**
38 | * 文字
39 | */
40 | private String text;
41 | /**
42 | * 依赖关系文本
43 | */
44 | private List relyList;
45 |
46 | public MergeEntity() {
47 |
48 | }
49 |
50 | public MergeEntity(String text, int startRow, int endRow) {
51 | this.text = text;
52 | this.endRow = endRow;
53 | this.startRow = startRow;
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/cn/afterturn/easypoi/pdf/styler/IPdfExportStyler.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 cn.afterturn.easypoi.pdf.styler;
17 |
18 | import com.itextpdf.text.Document;
19 | import com.itextpdf.text.Font;
20 | import com.itextpdf.text.pdf.PdfPCell;
21 |
22 | import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
23 |
24 | /**
25 | * PDF导出样式设置
26 | * @author JueYue
27 | * 2016年1月7日 下午11:16:51
28 | */
29 | public interface IPdfExportStyler {
30 |
31 | /**
32 | * 获取文档格式
33 | * @return
34 | */
35 | public Document getDocument();
36 |
37 | /**
38 | * 设置Cell的样式
39 | * @param entity
40 | * @param text
41 | */
42 | public void setCellStyler(PdfPCell iCell, ExcelExportEntity entity, String text);
43 |
44 | /**
45 | * 获取字体
46 | * @param entity
47 | * @param text
48 | */
49 | public Font getFont(ExcelExportEntity entity, String text);
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/easypoi-annotation/src/main/java/cn/afterturn/easypoi/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 cn.afterturn.easypoi.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 | *
27 | */
28 | @Retention(RetentionPolicy.RUNTIME)
29 | @Target(ElementType.FIELD)
30 | public @interface ExcelEntity {
31 |
32 | /**
33 | * 定义excel导出ID 来限定导出字段,处理一个类对应多个不同名称的情况
34 | */
35 | public String id() default "";
36 |
37 | /**
38 | * 导出时,对应数据库的字段 主要是用户区分每个字段, 不能有annocation重名的 导出时的列名
39 | * 导出排序跟定义了annotation的字段的顺序有关 可以使用a_id,b_id来确实是否使用
40 | */
41 | public String name() default "";
42 |
43 | /**
44 | * 如果等于true,name必须有值, Excel的表头会变成两行,同时改Excel内部数据不参与总排序,排序用下面这个来代替,内部再排序
45 | * 排序取当中最小值排序
46 | * @return
47 | */
48 | public boolean show() default false;
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/graph/entity/ExcelGraphDefined.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package cn.afterturn.easypoi.excel.graph.entity;
5 |
6 | import java.util.ArrayList;
7 | import java.util.List;
8 |
9 | import cn.afterturn.easypoi.excel.graph.constant.ExcelGraphType;
10 |
11 | /**
12 | * @author xfworld
13 | * @since 2015-12-30
14 | * @version 1.0
15 | *
16 | */
17 | public class ExcelGraphDefined implements ExcelGraph
18 | {
19 | private ExcelGraphElement category;
20 | public List valueList= new ArrayList<>();
21 | public List titleCell= new ArrayList<>();
22 | private Integer graphType=ExcelGraphType.LINE_CHART;
23 | public List title= new ArrayList<>();
24 |
25 | @Override
26 | public ExcelGraphElement getCategory()
27 | {
28 | return category;
29 | }
30 | public void setCategory(ExcelGraphElement category)
31 | {
32 | this.category = category;
33 | }
34 | @Override
35 | public List getValueList()
36 | {
37 | return valueList;
38 | }
39 | public void setValueList(List valueList)
40 | {
41 | this.valueList = valueList;
42 | }
43 |
44 | @Override
45 | public Integer getGraphType()
46 | {
47 | return graphType;
48 | }
49 | public void setGraphType(Integer graphType)
50 | {
51 | this.graphType = graphType;
52 | }
53 | @Override
54 | public List getTitleCell()
55 | {
56 | return titleCell;
57 | }
58 | public void setTitleCell(List titleCell)
59 | {
60 | this.titleCell = titleCell;
61 | }
62 | @Override
63 | public List getTitle()
64 | {
65 | return title;
66 | }
67 | public void setTitle(List title)
68 | {
69 | this.title = title;
70 | }
71 |
72 |
73 |
74 | }
75 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/cn/afterturn/easypoi/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 cn.afterturn.easypoi.excel.entity.enmus;
17 |
18 | import cn.afterturn.easypoi.excel.export.styler.ExcelExportStylerBorderImpl;
19 | import cn.afterturn.easypoi.excel.export.styler.ExcelExportStylerColorImpl;
20 | import cn.afterturn.easypoi.excel.export.styler.ExcelExportStylerDefaultImpl;
21 |
22 | /**
23 | * 插件提供的几个默认样式
24 | * @author JueYue
25 | * 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/cn/afterturn/easypoi/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 cn.afterturn.easypoi.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-web/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 |
5 | cn.afterturn
6 | easypoi
7 | 4.1.3
8 |
9 | easypoi-web
10 |
11 |
12 |
13 | org.springframework
14 | spring-web
15 | compile
16 |
17 |
18 | org.springframework
19 | spring-webmvc
20 | compile
21 |
22 |
23 | org.springframework
24 | spring-context
25 | compile
26 |
27 |
28 | org.springframework
29 | spring-core
30 | compile
31 |
32 |
33 | org.springframework
34 | spring-beans
35 | compile
36 |
37 |
38 |
39 | javax.servlet
40 | servlet-api
41 | provided
42 |
43 |
44 |
45 |
46 | com.itextpdf
47 | itextpdf
48 | true
49 |
50 |
51 |
52 | cn.afterturn
53 | easypoi-base
54 |
55 |
56 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/html/css/impl/BackgroundCssConvertImpl.java:
--------------------------------------------------------------------------------
1 | package cn.afterturn.easypoi.excel.html.css.impl;
2 |
3 | import org.apache.commons.lang3.StringUtils;
4 | import org.apache.poi.hssf.usermodel.HSSFCell;
5 | import org.apache.poi.hssf.usermodel.HSSFWorkbook;
6 | import org.apache.poi.ss.usermodel.Cell;
7 | import org.apache.poi.ss.usermodel.CellStyle;
8 | import org.apache.poi.ss.usermodel.FillPatternType;
9 | import org.apache.poi.xssf.usermodel.XSSFCell;
10 | import org.apache.poi.xssf.usermodel.XSSFCellStyle;
11 |
12 | import cn.afterturn.easypoi.excel.html.css.ICssConvertToExcel;
13 | import cn.afterturn.easypoi.excel.html.css.ICssConvertToHtml;
14 | import cn.afterturn.easypoi.excel.html.entity.style.CellStyleEntity;
15 | import cn.afterturn.easypoi.util.PoiCssUtils;
16 |
17 | public class BackgroundCssConvertImpl implements ICssConvertToExcel, ICssConvertToHtml {
18 |
19 | @Override
20 | public String convertToHtml(Cell cell, CellStyle cellStyle, CellStyleEntity style) {
21 |
22 | return null;
23 | }
24 |
25 | @Override
26 | public void convertToExcel(Cell cell, CellStyle cellStyle, CellStyleEntity style) {
27 | if (StringUtils.isEmpty(style.getBackground())) {
28 | return;
29 | }
30 | cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); // 填充图案
31 | if (cell instanceof XSSFCell) {
32 | ((XSSFCellStyle) cellStyle)
33 | .setFillForegroundColor(PoiCssUtils.parseColor(style.getBackground()));
34 | } else if (cell instanceof HSSFCell) {
35 | cellStyle.setFillForegroundColor(
36 | PoiCssUtils.parseColor((HSSFWorkbook) cell.getRow().getSheet().getWorkbook(),
37 | style.getBackground()).getIndex());
38 | }
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/cn/afterturn/easypoi/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 cn.afterturn.easypoi.cache;
17 |
18 | import java.io.InputStream;
19 |
20 | import org.slf4j.Logger;
21 | import org.slf4j.LoggerFactory;
22 |
23 | import cn.afterturn.easypoi.cache.manager.POICacheManager;
24 | import cn.afterturn.easypoi.word.entity.MyXWPFDocument;
25 |
26 | /**
27 | * word 缓存中心
28 | *
29 | * @author JueYue
30 | * 2014年7月24日 下午10:54:31
31 | */
32 | public class WordCache {
33 |
34 | private static final Logger LOGGER = LoggerFactory.getLogger(WordCache.class);
35 |
36 | public static MyXWPFDocument getXWPFDocument(String url) {
37 | InputStream is = null;
38 | try {
39 | is = POICacheManager.getFile(url);
40 | MyXWPFDocument doc = new MyXWPFDocument(is);
41 | return doc;
42 | } catch (Exception e) {
43 | LOGGER.error(e.getMessage(), e);
44 | } finally {
45 | try {
46 | is.close();
47 | } catch (Exception e) {
48 | LOGGER.error(e.getMessage(), e);
49 | }
50 | }
51 | return null;
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/cn/afterturn/easypoi/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 cn.afterturn.easypoi.excel.entity.result;
17 |
18 | import java.util.List;
19 | import java.util.Map;
20 |
21 | import lombok.Data;
22 | import org.apache.poi.ss.usermodel.Workbook;
23 |
24 | /**
25 | * 导入返回类
26 | *
27 | * @author JueYue
28 | * 2014年6月29日 下午5:12:10
29 | */
30 | @Data
31 | public class ExcelImportResult {
32 |
33 | /**
34 | * 结果集
35 | */
36 | private List list;
37 | /**
38 | * 失败数据
39 | */
40 | private List failList;
41 |
42 | /**
43 | * 是否存在校验失败
44 | */
45 | private boolean verifyFail;
46 |
47 | /**
48 | * 数据源
49 | */
50 | private Workbook workbook;
51 | /**
52 | * 失败的数据源
53 | */
54 | private Workbook failWorkbook;
55 |
56 | private Map map;
57 |
58 | public ExcelImportResult() {
59 |
60 | }
61 |
62 | public ExcelImportResult(List list, boolean verifyFail, Workbook workbook) {
63 | this.list = list;
64 | this.verifyFail = verifyFail;
65 | this.workbook = workbook;
66 | }
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/cn/afterturn/easypoi/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 cn.afterturn.easypoi.excel.entity.params;
17 |
18 | import lombok.Data;
19 |
20 | import java.util.List;
21 |
22 | /**
23 | * excel 导入工具类,对cell类型做映射
24 | * @author JueYue
25 | * @version 1.0 2013年8月24日
26 | */
27 | @Data
28 | public class ExcelImportEntity extends ExcelBaseEntity {
29 |
30 | public final static String IMG_SAVE_PATH = "/excel/upload/img";
31 | /**
32 | * 对应 Collection NAME
33 | */
34 | private String collectionName;
35 | /**
36 | * 保存图片的地址
37 | */
38 | private String saveUrl;
39 | /**
40 | * 保存图片的类型,1是文件,2是数据库
41 | */
42 | private int saveType;
43 | /**
44 | * 对应exportType
45 | */
46 | private String classType;
47 | /**
48 | * 后缀
49 | */
50 | private String suffix;
51 | /**
52 | * 导入校验字段
53 | */
54 | private boolean importField;
55 |
56 | /**
57 | * 枚举导入静态方法
58 | */
59 | private String enumImportMethod;
60 |
61 | private List list;
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/cn/afterturn/easypoi/util/PoiExcelGraphDataUtil.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package cn.afterturn.easypoi.util;
5 |
6 | import java.util.List;
7 |
8 | import org.apache.poi.ss.usermodel.Drawing;
9 | import org.apache.poi.ss.usermodel.Sheet;
10 |
11 | import cn.afterturn.easypoi.excel.graph.entity.ExcelGraph;
12 | import cn.afterturn.easypoi.excel.graph.entity.ExcelGraphElement;
13 |
14 | /**
15 | * @author xfworld
16 | * @since 2016-1-4
17 | * @version 1.0
18 | * 构建特殊数据结构
19 | */
20 | public class PoiExcelGraphDataUtil {
21 |
22 | /**
23 | * 构建获取数据最后行数 并写入到定义对象中
24 | * @param dataSourceSheet
25 | * @param graph
26 | */
27 | public static void buildGraphData(Sheet dataSourceSheet, ExcelGraph graph) {
28 | if (graph != null && graph.getCategory() != null && graph.getValueList() != null
29 | && graph.getValueList().size() > 0) {
30 | graph.getCategory().setEndRowNum(dataSourceSheet.getLastRowNum());
31 | for (ExcelGraphElement e : graph.getValueList()) {
32 | if (e != null) {
33 | e.setEndRowNum(dataSourceSheet.getLastRowNum());
34 | }
35 | }
36 | }
37 | }
38 |
39 | /**
40 | * 构建多个图形对象
41 | * @param dataSourceSheet
42 | * @param graphList
43 | */
44 | public static void buildGraphData(Sheet dataSourceSheet, List graphList) {
45 | if (graphList != null && graphList.size() > 0) {
46 | for (ExcelGraph graph : graphList) {
47 | buildGraphData(dataSourceSheet, graph);
48 | }
49 | }
50 | }
51 |
52 | /**
53 | * 获取画布,没有就创建一个
54 | * @param sheet
55 | * @return
56 | */
57 | public static Drawing getDrawingPatriarch(Sheet sheet){
58 | if(sheet.getDrawingPatriarch() == null){
59 | sheet.createDrawingPatriarch();
60 | }
61 | return sheet.getDrawingPatriarch();
62 | }
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/entity/params/ExcelForEachParams.java:
--------------------------------------------------------------------------------
1 | package cn.afterturn.easypoi.excel.entity.params;
2 |
3 | import lombok.Data;
4 | import org.apache.poi.ss.usermodel.CellStyle;
5 |
6 | import java.io.Serializable;
7 | import java.util.Stack;
8 |
9 | /**
10 | * 模板for each是的参数
11 | *
12 | * @author JueYue
13 | * 2015年4月29日 下午9:22:48
14 | */
15 | @Data
16 | public class ExcelForEachParams implements Serializable {
17 |
18 | /**
19 | *
20 | */
21 | private static final long serialVersionUID = 1L;
22 | /**
23 | * key
24 | */
25 | private String name;
26 | /**
27 | * key
28 | */
29 | private Stack tempName;
30 | /**
31 | * 模板的cellStyle
32 | */
33 | private CellStyle cellStyle;
34 | /**
35 | * 行高
36 | */
37 | private short height;
38 | /**
39 | * 常量值
40 | */
41 | private String constValue;
42 | /**
43 | * 列合并
44 | */
45 | private int colspan = 1;
46 | /**
47 | * 行合并
48 | */
49 | private int rowspan = 1;
50 | /**
51 | * 行合并
52 | */
53 | private boolean collectCell;
54 |
55 | private boolean needSum;
56 |
57 | public ExcelForEachParams() {
58 |
59 | }
60 |
61 | public ExcelForEachParams(String name, CellStyle cellStyle, short height) {
62 | this.name = name;
63 | this.cellStyle = cellStyle;
64 | this.height = height;
65 | }
66 |
67 | public ExcelForEachParams(String name, CellStyle cellStyle, short height, boolean needSum) {
68 | this.name = name;
69 | this.cellStyle = cellStyle;
70 | this.height = height;
71 | this.needSum = needSum;
72 | }
73 |
74 |
75 | }
76 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/cn/afterturn/easypoi/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 cn.afterturn.easypoi.exception.excel;
17 |
18 | import cn.afterturn.easypoi.exception.excel.enums.ExcelExportEnum;
19 |
20 | /**
21 | * 导出异常
22 | *
23 | * @author JueYue
24 | * 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/cn/afterturn/easypoi/excel/html/css/impl/HeightCssConverImpl.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 cn.afterturn.easypoi.excel.html.css.impl;
17 |
18 | import org.apache.commons.lang3.StringUtils;
19 | import org.apache.poi.ss.usermodel.Cell;
20 | import org.apache.poi.ss.usermodel.CellStyle;
21 | import org.apache.poi.ss.usermodel.Row;
22 |
23 | import cn.afterturn.easypoi.excel.html.css.ICssConvertToExcel;
24 | import cn.afterturn.easypoi.excel.html.css.ICssConvertToHtml;
25 | import cn.afterturn.easypoi.excel.html.entity.style.CellStyleEntity;
26 | import cn.afterturn.easypoi.util.PoiCssUtils;
27 |
28 |
29 | /**
30 | * 行高转换实现类
31 | * @author JueYue
32 | * 2016年4月3日 上午10:26:47
33 | */
34 | public class HeightCssConverImpl implements ICssConvertToExcel, ICssConvertToHtml {
35 |
36 | @Override
37 | public String convertToHtml(Cell cell, CellStyle cellStyle, CellStyleEntity style) {
38 |
39 | return null;
40 | }
41 |
42 | @Override
43 | public void convertToExcel(Cell cell, CellStyle cellStyle, CellStyleEntity style) {
44 | if (StringUtils.isNoneBlank(style.getHeight())) {
45 | int height = Math.round(PoiCssUtils.getInt(style.getHeight()) * 255 / 12.75F);
46 | Row row = cell.getRow();
47 | if (height > row.getHeight()) {
48 | row.setHeight((short) height);
49 | }
50 | }
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/cn/afterturn/easypoi/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 cn.afterturn.easypoi.excel.export.styler;
17 |
18 | import org.apache.poi.ss.usermodel.Cell;
19 | import org.apache.poi.ss.usermodel.CellStyle;
20 |
21 | import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
22 | import cn.afterturn.easypoi.excel.entity.params.ExcelForEachParams;
23 | import org.apache.poi.util.Removal;
24 |
25 | /**
26 | * Excel导出样式接口
27 | *
28 | * @author JueYue 2015年1月9日 下午5:32:30
29 | */
30 | public interface IExcelExportStyler {
31 |
32 | /**
33 | * 列表头样式
34 | */
35 | public CellStyle getHeaderStyle(short headerColor);
36 |
37 | /**
38 | * 标题样式
39 | */
40 | public CellStyle getTitleStyle(short color);
41 |
42 | /**
43 | * 获取样式方法
44 | */
45 | @Deprecated
46 | @Removal(
47 | version = "4.2"
48 | )
49 | public CellStyle getStyles(boolean parity, ExcelExportEntity entity);
50 |
51 | /**
52 | * 获取样式方法
53 | *
54 | * @param dataRow 数据行
55 | * @param obj 对象
56 | * @param data 数据
57 | */
58 | public CellStyle getStyles(Cell cell, int dataRow, ExcelExportEntity entity, Object obj, Object data);
59 |
60 | /**
61 | * 模板使用的样式设置
62 | */
63 | public CellStyle getTemplateStyles(boolean isSingle, ExcelForEachParams excelForEachParams);
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/cn/afterturn/easypoi/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 cn.afterturn.easypoi.exception.excel;
17 |
18 | import cn.afterturn.easypoi.exception.excel.enums.ExcelImportEnum;
19 |
20 | /**
21 | * 导入异常
22 | * @author JueYue
23 | * 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 ExcelImportException(String message, Throwable cause) {
54 | super(message, cause);
55 | }
56 |
57 | public ExcelImportEnum getType() {
58 | return type;
59 | }
60 |
61 | public void setType(ExcelImportEnum type) {
62 | this.type = type;
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/cn/afterturn/easypoi/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 cn.afterturn.easypoi.excel.entity.params;
17 |
18 | import java.lang.reflect.Method;
19 | import java.util.List;
20 |
21 | import cn.afterturn.easypoi.excel.entity.vo.BaseEntityTypeConstants;
22 | import lombok.Data;
23 |
24 | /**
25 | * Excel 导入导出基础对象类
26 | * @author JueYue
27 | * 2014年6月20日 下午2:26:09
28 | */
29 | @Data
30 | public class ExcelBaseEntity {
31 | /**
32 | * 对应name
33 | */
34 | protected String name;
35 | /**
36 | * 对应groupName
37 | */
38 | protected String groupName;
39 | /**
40 | * 对应type
41 | */
42 | private int type = BaseEntityTypeConstants.STRING_TYPE;
43 | /**
44 | * 数据库格式
45 | */
46 | private String databaseFormat;
47 | /**
48 | * 导出日期格式
49 | */
50 | private String format;
51 | /**
52 | * 导出日期格式
53 | */
54 | private String[] replace;
55 | /**
56 | * 字典名称
57 | */
58 | private String dict;
59 | /**
60 | * set/get方法
61 | */
62 | private Method method;
63 | /**
64 | * 这个是不是超链接,如果是需要实现接口返回对象
65 | */
66 | private boolean hyperlink;
67 | /**
68 | * 固定的列
69 | */
70 | private Integer fixedIndex;
71 | /**
72 | * 时区
73 | */
74 | private String timezone;
75 |
76 | private List methods;
77 |
78 | }
79 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/cn/afterturn/easypoi/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 cn.afterturn.easypoi.handler.impl;
17 |
18 | import java.util.Map;
19 |
20 | import org.apache.poi.ss.usermodel.CreationHelper;
21 | import org.apache.poi.ss.usermodel.Hyperlink;
22 |
23 | import cn.afterturn.easypoi.handler.inter.IExcelDataHandler;
24 |
25 | /**
26 | * 数据处理默认实现,返回空
27 | *
28 | * @author JueYue
29 | * 2014年6月20日 上午12:11:52
30 | */
31 | public abstract class ExcelDataHandlerDefaultImpl implements IExcelDataHandler {
32 | /**
33 | * 需要处理的字段
34 | */
35 | private String[] needHandlerFields;
36 |
37 | @Override
38 | public Object exportHandler(T obj, String name, Object value) {
39 | return value;
40 | }
41 |
42 | @Override
43 | public String[] getNeedHandlerFields() {
44 | return needHandlerFields;
45 | }
46 |
47 | @Override
48 | public Object importHandler(T obj, String name, Object value) {
49 | return value;
50 | }
51 |
52 | @Override
53 | public void setNeedHandlerFields(String[] needHandlerFields) {
54 | this.needHandlerFields = needHandlerFields;
55 | }
56 |
57 | @Override
58 | public void setMapValue(Map map, String originKey, Object value) {
59 | map.put(originKey, value);
60 | }
61 |
62 | @Override
63 | public Hyperlink getHyperlink(CreationHelper creationHelper, T obj, String name, Object value) {
64 | return null;
65 | }
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/html/css/impl/AlignCssConvertImpl.java:
--------------------------------------------------------------------------------
1 | package cn.afterturn.easypoi.excel.html.css.impl;
2 |
3 | import org.apache.poi.ss.usermodel.Cell;
4 | import org.apache.poi.ss.usermodel.CellStyle;
5 |
6 | import cn.afterturn.easypoi.excel.html.css.ICssConvertToExcel;
7 | import cn.afterturn.easypoi.excel.html.css.ICssConvertToHtml;
8 | import cn.afterturn.easypoi.excel.html.entity.HtmlCssConstant;
9 | import cn.afterturn.easypoi.excel.html.entity.style.CellStyleEntity;
10 | import org.apache.poi.ss.usermodel.HorizontalAlignment;
11 | import org.apache.poi.ss.usermodel.VerticalAlignment;
12 |
13 | public class AlignCssConvertImpl implements ICssConvertToExcel, ICssConvertToHtml {
14 |
15 | @Override
16 | public String convertToHtml(Cell cell, CellStyle cellStyle, CellStyleEntity style) {
17 |
18 | return null;
19 | }
20 |
21 | @Override
22 | public void convertToExcel(Cell cell, CellStyle cellStyle, CellStyleEntity style) {
23 | // align
24 | if (HtmlCssConstant.RIGHT.equals(style.getAlign())) {
25 | cellStyle.setAlignment(HorizontalAlignment.RIGHT);
26 | } else if (HtmlCssConstant.CENTER.equals(style.getAlign())) {
27 | cellStyle.setAlignment(HorizontalAlignment.CENTER);
28 | } else if (HtmlCssConstant.LEFT.equals(style.getAlign())) {
29 | cellStyle.setAlignment(HorizontalAlignment.LEFT);
30 | } else if (HtmlCssConstant.JUSTIFY.equals(style.getAlign())) {
31 | cellStyle.setAlignment(HorizontalAlignment.JUSTIFY);
32 | }
33 | // vertical align
34 | if (HtmlCssConstant.TOP.equals(style.getVetical())) {
35 | cellStyle.setVerticalAlignment(VerticalAlignment.TOP);
36 | } else if (HtmlCssConstant.CENTER.equals(style.getVetical())) {
37 | cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
38 | } else if (HtmlCssConstant.BOTTOM.equals(style.getVetical())) {
39 | cellStyle.setVerticalAlignment(VerticalAlignment.BOTTOM);
40 | } else if (HtmlCssConstant.JUSTIFY.equals(style.getVetical())) {
41 | cellStyle.setVerticalAlignment(VerticalAlignment.JUSTIFY);
42 | }
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/easypoi-web/src/main/java/cn/afterturn/easypoi/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 cn.afterturn.easypoi.view;
17 |
18 | import cn.afterturn.easypoi.util.WebFilenameUtils;
19 | import org.apache.poi.hssf.usermodel.HSSFWorkbook;
20 | import org.apache.poi.ss.usermodel.Workbook;
21 |
22 | import javax.servlet.ServletOutputStream;
23 | import javax.servlet.http.HttpServletRequest;
24 | import javax.servlet.http.HttpServletResponse;
25 |
26 | /**
27 | * 基础抽象Excel View
28 | * @author JueYue
29 | * 2015年2月28日 下午1:41:05
30 | */
31 | public abstract class MiniAbstractExcelView extends PoiBaseView {
32 |
33 | private static final String CONTENT_TYPE = "text/html;application/vnd.ms-excel";
34 |
35 | protected static final String HSSF = ".xls";
36 | protected static final String XSSF = ".xlsx";
37 |
38 | public MiniAbstractExcelView() {
39 | setContentType(CONTENT_TYPE);
40 | }
41 |
42 |
43 | public void out(Workbook workbook, String codedFileName, HttpServletRequest request,
44 | HttpServletResponse response) throws Exception {
45 | if (workbook instanceof HSSFWorkbook) {
46 | codedFileName += HSSF;
47 | } else {
48 | codedFileName += XSSF;
49 | }
50 | // 用工具类生成符合RFC 5987标准的文件名header, 去掉UA判断
51 | response.setHeader("content-disposition", WebFilenameUtils.disposition(codedFileName));
52 | ServletOutputStream out = response.getOutputStream();
53 | workbook.write(out);
54 | out.flush();
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/easypoi-base/src/main/java/cn/afterturn/easypoi/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 cn.afterturn.easypoi.word;
17 |
18 | import java.util.List;
19 | import java.util.Map;
20 |
21 | import org.apache.poi.xwpf.usermodel.XWPFDocument;
22 |
23 | import cn.afterturn.easypoi.word.parse.ParseWord07;
24 |
25 | /**
26 | * Word使用模板导出工具类
27 | *
28 | * @author JueYue
29 | * 2013-11-16
30 | * @version 1.0
31 | */
32 | public class WordExportUtil {
33 |
34 | private WordExportUtil() {
35 |
36 | }
37 |
38 | /**
39 | * 解析Word2007版本
40 | *
41 | * @param url
42 | * 模板地址
43 | * @param map
44 | * 解析数据源
45 | * @return
46 | */
47 | public static XWPFDocument exportWord07(String url, Map map) throws Exception {
48 | return new ParseWord07().parseWord(url, map);
49 | }
50 |
51 | /**
52 | * 解析Word2007版本
53 | *
54 | * @param document
55 | * 模板
56 | * @param map
57 | * 解析数据源
58 | */
59 | public static void exportWord07(XWPFDocument document, Map map) throws Exception {
60 | new ParseWord07().parseWord(document, map);
61 | }
62 |
63 | /**
64 | * 一个模板生成多页
65 | * @param url
66 | * @param list
67 | * @return
68 | * @throws Exception
69 | */
70 | public static XWPFDocument exportWord07(String url, List