Skip to content
This repository was archived by the owner on Apr 11, 2025. It is now read-only.

Commit 241312f

Browse files
authored
Merge pull request #18 from biezhi/dev
release 1.0.1
2 parents a55963a + 5dcc26a commit 241312f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1203
-260
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Easier to read and generate an excel file, supports `XLSX`、`XLS`、`CSV`.
3434
<dependency>
3535
<groupId>io.github.biezhi</groupId>
3636
<artifactId>excel-plus</artifactId>
37-
<version>1.0.0.Alpha</version>
37+
<version>1.0.1</version>
3838
</dependency>
3939
```
4040

@@ -44,7 +44,7 @@ snapshot version
4444
<dependency>
4545
<groupId>io.github.biezhi</groupId>
4646
<artifactId>excel-plus</artifactId>
47-
<version>1.0.0-SNAPSHOT</version>
47+
<version>1.0.2-SNAPSHOT</version>
4848
</dependency>
4949
```
5050

docs/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
<dependency>
4444
<groupId>io.github.biezhi</groupId>
4545
<artifactId>excel-plus</artifactId>
46-
<version>1.0.0.Alpha</version>
46+
<version>1.0.1</version>
4747
</dependency>
4848
```
4949

@@ -53,7 +53,7 @@
5353
<dependency>
5454
<groupId>io.github.biezhi</groupId>
5555
<artifactId>excel-plus</artifactId>
56-
<version>1.0.0-SNAPSHOT</version>
56+
<version>1.0.2-SNAPSHOT</version>
5757
</dependency>
5858
```
5959

pom.xml

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>io.github.biezhi</groupId>
88
<artifactId>excel-plus</artifactId>
9-
<version>1.0.0-SNAPSHOT</version>
9+
<version>1.0.1</version>
1010
<name>excel-plus</name>
1111
<url>https://biezhi.github.io/excel-plus</url>
1212
<description>excel read and write framework</description>
@@ -31,7 +31,6 @@
3131

3232
<properties>
3333
<poi.version>4.0.1</poi.version>
34-
<xerces.version>2.11.0</xerces.version>
3534
</properties>
3635

3736
<dependencies>
@@ -50,11 +49,6 @@
5049
<artifactId>poi-ooxml</artifactId>
5150
<version>${poi.version}</version>
5251
</dependency>
53-
<dependency>
54-
<groupId>xerces</groupId>
55-
<artifactId>xercesImpl</artifactId>
56-
<version>${xerces.version}</version>
57-
</dependency>
5852
<dependency>
5953
<groupId>javax.servlet</groupId>
6054
<artifactId>javax.servlet-api</artifactId>
@@ -74,9 +68,9 @@
7468
<scope>test</scope>
7569
</dependency>
7670
<dependency>
77-
<groupId>org.junit.jupiter</groupId>
78-
<artifactId>junit-jupiter-api</artifactId>
79-
<version>RELEASE</version>
71+
<groupId>junit</groupId>
72+
<artifactId>junit</artifactId>
73+
<version>4.12</version>
8074
<scope>test</scope>
8175
</dependency>
8276
</dependencies>
@@ -100,6 +94,16 @@
10094
<format>html</format>
10195
<format>xml</format>
10296
</formats>
97+
<instrumentation>
98+
<ignores>
99+
<ignore>io.github.biezhi.excel.plus.annotation.*</ignore>
100+
<ignore>io.github.biezhi.excel.plus.exception.*</ignore>
101+
</ignores>
102+
<excludes>
103+
<exclude>io/github/biezhi/excel/plus/annotation/*.class</exclude>
104+
<exclude>io/github/biezhi/excel/plus/exception/*.class</exclude>
105+
</excludes>
106+
</instrumentation>
103107
<check />
104108
</configuration>
105109
</plugin>

src/main/java/io/github/biezhi/excel/plus/Constant.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626
*/
2727
public interface Constant {
2828

29-
String TIP_MSG = "Please see https://biezhi.github.io/excel-plus/";
30-
3129
/**
3230
* The default worksheet name.
3331
*/

src/main/java/io/github/biezhi/excel/plus/ExcelPlus.java

Lines changed: 0 additions & 55 deletions
This file was deleted.

src/main/java/io/github/biezhi/excel/plus/Reader.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public Reader<T> sheet(String sheetName) {
158158
* @return Stream
159159
* @throws ReaderException Thrown when an exception occurs during reading
160160
*/
161-
public Stream<T> asStream() throws ReaderException {
161+
public Stream<T> asStream() {
162162
if (modelType == null) {
163163
throw new IllegalArgumentException("modelType can be not null");
164164
}
@@ -194,7 +194,7 @@ public File fromFile() {
194194
}
195195

196196
public Class<T> modelType() {
197-
return (Class<T>) modelType;
197+
return modelType;
198198
}
199199

200200
public int sheetIndex() {

src/main/java/io/github/biezhi/excel/plus/Writer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ public int startRow() {
286286
return this.startRow;
287287
}
288288

289-
public String sheet() {
289+
public String sheetName() {
290290
return this.sheetName;
291291
}
292292

src/main/java/io/github/biezhi/excel/plus/conveter/BooleanConverter.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
*/
1616
package io.github.biezhi.excel.plus.conveter;
1717

18-
import io.github.biezhi.excel.plus.exception.ConverterException;
19-
2018
/**
2119
* Boolean to string converter
2220
*
@@ -26,12 +24,8 @@
2624
public class BooleanConverter implements Converter<String, Boolean> {
2725

2826
@Override
29-
public Boolean stringToR(String value) throws ConverterException {
30-
try {
31-
return Boolean.valueOf(value);
32-
} catch (Exception e){
33-
throw new ConverterException("convert [" + value + "] to Boolean error", e);
34-
}
27+
public Boolean stringToR(String value) {
28+
return Boolean.parseBoolean(value);
3529
}
3630

3731
}

src/main/java/io/github/biezhi/excel/plus/conveter/ConverterCache.java

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
/**
2-
* Copyright (c) 2018, biezhi (biezhi.me@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.
2+
* Copyright (c) 2018, biezhi (biezhi.me@gmail.com)
3+
* <p>
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+
* <p>
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
* <p>
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.
1515
*/
1616
package io.github.biezhi.excel.plus.conveter;
1717

@@ -20,6 +20,7 @@
2020

2121
import java.lang.reflect.Field;
2222
import java.math.BigDecimal;
23+
import java.math.BigInteger;
2324
import java.time.LocalDate;
2425
import java.time.LocalDateTime;
2526
import java.util.Date;
@@ -49,7 +50,9 @@ public class ConverterCache {
4950
}
5051

5152
public static void addConvert(Converter converter) {
52-
CONVERTER_MAP.put(converter.getClass(), converter);
53+
if (null != converter) {
54+
CONVERTER_MAP.put(converter.getClass(), converter);
55+
}
5356
}
5457

5558
public static Converter getConvert(
@@ -58,8 +61,17 @@ public static Converter getConvert(
5861
}
5962

6063
public static Converter computeConvert(Field field) throws Exception {
64+
if (null == field) {
65+
return null;
66+
}
67+
6168
Class fieldType = field.getType();
6269

70+
ExcelColumn column = field.getAnnotation(ExcelColumn.class);
71+
if (null != column && !NullConverter.class.equals(column.converter())) {
72+
return column.converter().newInstance();
73+
}
74+
6375
if (fieldType.equals(String.class)) {
6476
return ConverterCache.getConvert(StringConverter.class);
6577
} else if (fieldType.equals(int.class) || fieldType.equals(Integer.class)) {
@@ -76,6 +88,8 @@ public static Converter computeConvert(Field field) throws Exception {
7688
return ConverterCache.getConvert(ByteConverter.class);
7789
} else if (fieldType.equals(boolean.class) || fieldType.equals(Boolean.class)) {
7890
return ConverterCache.getConvert(BooleanConverter.class);
91+
} else if (fieldType.equals(BigInteger.class)) {
92+
return ConverterCache.getConvert(BigIntConverter.class);
7993
} else if (fieldType.equals(BigDecimal.class)) {
8094
return ConverterCache.getConvert(DecimalConverter.class);
8195
} else if (fieldType.equals(Date.class)) {
@@ -87,12 +101,8 @@ public static Converter computeConvert(Field field) throws Exception {
87101
} else if (fieldType.equals(LocalDateTime.class)) {
88102
String pattern = field.getAnnotation(ExcelColumn.class).datePattern();
89103
return new LocalDateTimeConverter(pattern);
90-
} else {
91-
Class<? extends Converter> customConverter = field.getAnnotation(ExcelColumn.class).converter();
92-
if(!NullConverter.class.equals(customConverter)){
93-
return customConverter.newInstance();
94-
}
95104
}
96105
return null;
97106
}
107+
98108
}

src/main/java/io/github/biezhi/excel/plus/conveter/DateConverter.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ public DateConverter(String pattern) {
3838
@Override
3939
public Date stringToR(String value) throws ConverterException {
4040
try {
41+
if(null == value){
42+
return null;
43+
}
4144
return df.get().parse(value);
4245
} catch (Exception e) {
4346
throw new ConverterException("convert [" + value + "] to Date error", e);
@@ -47,6 +50,9 @@ public Date stringToR(String value) throws ConverterException {
4750
@Override
4851
public String toString(Date date) throws ConverterException {
4952
try {
53+
if(null == date){
54+
return null;
55+
}
5056
return df.get().format(date);
5157
} catch (Exception e) {
5258
throw new ConverterException("convert [" + date + "] to String error", e);

src/main/java/io/github/biezhi/excel/plus/conveter/IntConverter.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public Integer stringToR(String value) throws ConverterException {
3333
if (StringUtil.isEmpty(value)) {
3434
return null;
3535
}
36+
3637
return Integer.parseInt(value);
3738
} catch (Exception e) {
3839
throw new ConverterException("convert [" + value + "] to Integer error", e);

0 commit comments

Comments
 (0)