Skip to content

Commit 3c3ffb1

Browse files
committed
fix-bug
1 parent 96a4fcb commit 3c3ffb1

File tree

14 files changed

+144
-85
lines changed

14 files changed

+144
-85
lines changed

README.md

Lines changed: 41 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
![Apache License, Version 2.0, January 2004](https://img.shields.io/github/license/apache/maven.svg?label=License)
44
![Jenkins Status](https://img.shields.io/jenkins/s/https/builds.apache.org/job/maven-box/job/maven/job/master.svg?style=flat-square)
5-
5+
![language](https://img.shields.io/badge/language-java-orange.svg)
6+
![last_release](https://img.shields.io/badge/release-1.0.3-green)
67
## ExcelReads是什么?
78
* 这是一个通用的简单的Excel读取器
89
* 支持自定义JavaBean实体读取和HashMap自动读取
@@ -18,14 +19,22 @@
1819
<dependency>
1920
<groupId>com.github.matrixseven</groupId>
2021
<artifactId>ExcelReads</artifactId>
21-
<version>1.0.2</version>
22+
<version>1.0.3</version>
2223
</dependency>
2324

25+
26+
2427
```
2528

2629
## [更新日志详见:UpdateLogs.md](UPDATELOG.MD)
2730
###最近三次更新:
2831

32+
33+
#### 更新2019/12/2 
34+
* 替换导出方式
35+
* 增加 Create/CreateLoop[Map|Obj]
36+
* 更新顶层接口
37+
2938
#### 更新2019/4/26 (诈尸更新)
3039
* 更加完善的类型推导,书写更方便(Great!!!)
3140
* 修复增加过滤列无法读取数据bug
@@ -37,12 +46,6 @@
3746
* 增加AnyCol来对应FilterCol方法,只保留AnyCol类列
3847
* 增加SetCellStyle,突破CellStyle绑定wk约束,链式设置列单元格风格(非常狗血)
3948

40-
#### 更新2017/01/09
41-
* 增加SetPath方法,随时切换保存路径
42-
* 增加ConvertName方法,方便自定义Excel列名称
43-
* 增加Flush方法,不在建议使用~~Save(@Deprecated)~~方法进行保存输出
44-
* 增加SetOutputStream方法,可以放入自定义流,用于支持网页Response输出
45-
* 处理一些小bug,完善异常提示信息
4649

4750
### 其他
4851
* 自定义读取支持出简单的规范化数据格式,即典型的表头格式
@@ -64,22 +67,31 @@
6467

6568
* 喜大若奔(。・・)ノ Filter/Sort等lambda操作不用在声明类型(~~还是要写一个泛型~~)
6669
```java
67-
//读取到Map类型
68-
//使用 .CreateMap(key_v) 生成Map<Key,Map>类型数据
69-
List<Map<String, String>> list = ExcelFactory.getBeans(filePath, WrapperFactory
70-
.MakeMap(it -> it.vocSize(1999).title(2).content(3)))
71-
.Filter(it -> !it.get("服务IP").contains("12"))
72-
.Process(it -> it.put("add", "这个是我增加的"))
73-
.FilterCol(df -> df.add("连接类型"))
74-
.CreateMap();
75-
76-
//读取到自定义JavaBean类型
77-
List<A> create = ExcelFactory.getBeans(filePath2, WrapperFactory.<A>MakeObj(it -> it.vocSize(1999)
78-
.title(0).content(1), A.class))
79-
.Filter(it -> it.getA().equals(""))
80-
.FilterCol(it -> it.add("1"))
81-
.Sort(Comparator.comparing(A::getA))
82-
.Create();
70+
//CreateMapLoop 多sheet|isLoopSheet
71+
Map<String, Map<String, String>> maps = ExcelFactory.getMaps(filePath, it -> it.vocSize(1999)
72+
.title(2)
73+
.content(3)
74+
.isLoopSheet(true))
75+
.Filter(it -> it.get("在线人数").equals("43"))
76+
.CreateMapLoop();
77+
//CreateMap 单个
78+
List<Map<String, String>> maps2 = ExcelFactory.getMaps(filePath, it -> it.vocSize(1999)
79+
.title(2)
80+
.content(3))
81+
.Filter(it -> it.get("在线人数").equals("43"))
82+
.CreateMap();
83+
//Create Obj
84+
List<B> create = ExcelFactory.<B>getBeans(B.class, filePath, it -> it.title(2)
85+
.content(3)).Create();
86+
System.out.println(create);
87+
//CreateObjLoop
88+
String filePath2 = System.getProperty("user.dir").concat("/seven.xlsx");
89+
Map<String, List<A>> stringListMap = ExcelFactory.<A>getBeans(A.class, filePath2,
90+
it -> it.withConvert("姓名", ConvertTest.class)
91+
.isLoopSheet(true)
92+
.withConvert("姓名", f -> f.toString().concat("111111111")))
93+
.Process(a -> a.setA(a.getA() + "fuck"))
94+
.CreateObjLoop();
8395
```
8496
## 数据库导出自定义Bean类型写法(xxx.Class类型)
8597
```java
@@ -117,4 +129,8 @@ ExcelFactory.saveExcel(ps.executeQuery()).SetPath("seven.xlsx")
117129
* 邮件(hacker.kill07@gmail.com)
118130
* QQ: 985390927
119131
* weibo: [@Alden_情绪控](http://weibo.com/Sweets07)
120-
* Blog: [http://blog.52python.cn](http://blog.52python.cn)
132+
* Blog: [http://blog.52python.cn](http://blog.52python.cn)
133+
134+
## Acknowledgement
135+
特别感谢 [JetBrains](https://www.jetbrains.com/?from=matrixSeven) 为开源项目提供免费的 [IntelliJ IDEA](https://www.jetbrains.com/idea/?from=matrixSeven) 等 IDE 的授权
136+
[<img src="jetbrains-variant-3.png" width="200"/>](https://www.jetbrains.com/?from=matrixSeven)

UPDATELOG.MD

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
## 更新纪录
22

3+
#### 更新2017/01/09
4+
* 增加SetPath方法,随时切换保存路径
5+
* 增加ConvertName方法,方便自定义Excel列名称
6+
* 增加Flush方法,不在建议使用~~Save(@Deprecated)~~方法进行保存输出
7+
* 增加SetOutputStream方法,可以放入自定义流,用于支持网页Response输出
8+
* 处理一些小bug,完善异常提示信息
9+
310
### 更新2017/01/06
411
* 整合注解,导出和读取使用同一个ExcelAnno注解
512
* 统一编码为UTF-8

jetbrains-variant-3.png

178 KB
Loading

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<groupId>com.github.matrixseven</groupId>
55
<artifactId>ExcelReads</artifactId>
66
<packaging>jar</packaging>
7-
<version>1.0.2</version>
7+
<version>1.0.3</version>
88
<name>ExcelReads</name>
99
<description>A ExcelReads Utils By Seven</description>
1010
<url>https://github.com/MatrixSeven/ExcelReads</url>

src/main/java/seven/config/Config.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ public class Config {
2424
private Integer endSheet = null;
2525
private Integer sheetIndex = -1;
2626
private String sheetName = null;
27-
private Map<String, Class<? extends ConvertInterface>> convertMap = new HashMap<>();
28-
private Map<String, ConvertInterface> convertMapImpl = new HashMap<>();
27+
private Map<String, Class<? extends ConvertInterface<?>>> convertMap = new HashMap<>();
28+
private Map<String, ConvertInterface<?>> convertMapImpl = new HashMap<>();
2929

3030
public Config() {
3131
}
@@ -86,7 +86,7 @@ public Config setErrorLog(Boolean errorLog) {
8686
}
8787

8888
@Deprecated
89-
public Config withConvert(String name, Class<? extends ConvertInterface> clazz) {
89+
public Config withConvert(String name, Class<? extends ConvertInterface<?>> clazz) {
9090
this.convertMap.put(name, clazz);
9191
return this;
9292
}
@@ -97,7 +97,7 @@ public Config withConvert(String name, Class<? extends ConvertInterface> clazz)
9797
* @return
9898
*/
9999
@Deprecated
100-
public Config withConvert(String name, ConvertInterface convert) {
100+
public Config withConvert(String name, ConvertInterface<?> convert) {
101101
this.convertMapImpl.put(name, convert);
102102
return this;
103103
}
@@ -161,11 +161,11 @@ public Integer getContentRowEnd() {
161161
return contentRowEnd;
162162
}
163163

164-
public Map<String, Class<? extends ConvertInterface>> getConvertMap() {
164+
public Map<String, Class<? extends ConvertInterface<?>>> getConvertMap() {
165165
return convertMap;
166166
}
167167

168-
public Map<String, ConvertInterface> getConvertMapImpl() {
168+
public Map<String, ConvertInterface<?>> getConvertMapImpl() {
169169
return convertMapImpl;
170170
}
171171

src/main/java/seven/wapperInt/ReaderMap.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@
1717
//=======================================================
1818

1919
import seven.ExcelSuperInterface;
20-
import seven.config.Config;
2120

2221
import java.util.List;
2322
import java.util.Map;
24-
import java.util.function.Consumer;
2523

2624
/**
2725
* @author Seven
@@ -33,5 +31,5 @@ public interface ReaderMap extends ExcelSuperInterface<ReaderMap,Map> {
3331

3432
List<Map<String, String>> CreateMap() throws Exception;
3533

36-
Map<String, Map<String, String>> CreateMapLoop() throws Exception;
34+
Map<String, List<Map<String, String>>> CreateMapLoop() throws Exception;
3735
}

src/main/java/seven/wapperInt/ReaderObj.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ public interface ReaderObj<T> extends ExcelSuperInterface<ReaderObj<T>,T> {
3232

3333
List<T> Create() throws Exception;
3434

35-
Map<String,List<T>> CreateObjLoop() throws Exception;
35+
Map<String, List<T>> CreateObjLoop() throws Exception;
3636

3737
}

src/main/java/seven/wapperInt/wapperRef/WrapperMap.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,10 @@
2121
import org.slf4j.LoggerFactory;
2222
import seven.callBack.DataFilterInterface;
2323
import seven.callBack.DataFilterProcessInterface;
24-
import seven.callBack.imp.DefaultDataFilter;
25-
import seven.callBack.imp.DefaultDataProFilter;
2624
import seven.wapperInt.ReaderMap;
2725
import seven.wapperInt.Wrapper;
2826

2927
import java.io.File;
30-
import java.util.ArrayList;
3128
import java.util.Comparator;
3229
import java.util.List;
3330
import java.util.Map;
@@ -93,7 +90,7 @@ public List<Map<String, String>> CreateMap() throws Exception {
9390
}
9491

9592
@Override
96-
public Map<String, Map<String, String>> CreateMapLoop() throws Exception {
93+
public Map<String, List<Map<String, String>>> CreateMapLoop() throws Exception {
9794
if (!config.getIsLoopSheet()) {
9895
throw new RuntimeException("未开启LoopSheet选项,请使用CreateMap");
9996
}

src/main/java/seven/wapperInt/wapperRef/WrapperObj.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
import org.slf4j.LoggerFactory;
2222
import seven.callBack.DataFilterInterface;
2323
import seven.callBack.DataFilterProcessInterface;
24-
import seven.callBack.imp.DefaultDataFilter;
25-
import seven.callBack.imp.DefaultDataProFilter;
2624
import seven.wapperInt.ReaderObj;
2725
import seven.wapperInt.Wrapper;
2826

src/main/java/seven/wapperInt/wapperRef/sysWppers/ResWrapperMap.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import seven.util.ExcelTool;
99
import seven.util.RegHelper;
1010
import seven.wapperInt.wapperRef.WrapperMap;
11-
import seven.wapperInt.wapperRef.WrapperObj;
1211

1312
import java.util.*;
1413
import java.util.function.Consumer;
@@ -45,7 +44,7 @@ public ResWrapperMap(Consumer<seven.config.Config> consumer) {
4544
@Override
4645
protected <T> T refResWrapper(String fs, boolean isMap) throws Exception {
4746
config.check();
48-
HashMap<String, Map> maps = null;
47+
HashMap<String, List<Map>> maps = null;
4948
List<Map> list = null;
5049
//TODO fix
5150
if (isMap) {

0 commit comments

Comments
 (0)