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

Commit 474bdba

Browse files
authored
Merge branch 'master' into master
2 parents c2bbd14 + 37dc6f1 commit 474bdba

File tree

5 files changed

+14
-9
lines changed

5 files changed

+14
-9
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ Easier to read and generate an excel file, supports 2003 and 2007.
2121

2222
# Usage
2323

24-
Add maven dependency
24+
As maven dependency
2525

2626
```xml
2727
<dependency>
2828
<groupId>io.github.biezhi</groupId>
2929
<artifactId>excel-plus</artifactId>
30-
<version>0.0.2</version>
30+
<version>0.0.3</version>
3131
</dependency>
3232
```
3333

docs/README.md

Lines changed: 5 additions & 1 deletion
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>0.0.2</version>
46+
<version>0.0.3</version>
4747
</dependency>
4848
```
4949

@@ -236,6 +236,10 @@ excelPlus.export(Exporter.create(cardSecrets).byTemplate("tpl.xls")).writeAsFile
236236

237237
# 版本更新
238238

239+
<b>v0.0.3</b>
240+
241+
1. 修复自定义 `SheetName` 读取失败
242+
239243
<b>v0.0.2</b>
240244

241245
1. 添加验证行记录各项指标

pom.xml

Lines changed: 1 addition & 1 deletion
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>0.0.2</version>
9+
<version>0.0.3</version>
1010
<name>excel-plus</name>
1111
<url>https://biezhi.github.io/excel-plus</url>
1212
<description>excel read and write framework</description>

src/main/java/io/github/biezhi/excel/plus/utils/ExcelUtils.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import org.apache.poi.ss.usermodel.Cell;
1111
import org.apache.poi.ss.usermodel.CellType;
1212

13+
import java.lang.annotation.Annotation;
1314
import java.lang.reflect.Field;
1415
import java.math.BigDecimal;
1516
import java.time.LocalDate;
@@ -29,8 +30,8 @@ public class ExcelUtils {
2930

3031
private static final Map<String, List<Field>> FIELD_CACHE = new HashMap<>(8);
3132

32-
public static String getSheetName(Object item) {
33-
ExcelSheet excelSheet = item.getClass().getAnnotation(ExcelSheet.class);
33+
public static String getSheetName(Class<?> type) {
34+
ExcelSheet excelSheet = type.getAnnotation(ExcelSheet.class);
3435
if (null == excelSheet) {
3536
return Constant.DEFAULT_SHEET_NAME;
3637
}

src/main/java/io/github/biezhi/excel/plus/writer/ExcelWriter.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ default <T> void export(Exporter<T> exporter, OutputStream outputStream) throws
4848
Workbook workbook;
4949
CellStyle headerStyle;
5050
CellStyle columnStyle = null;
51-
CellStyle titleStyle = null;
51+
CellStyle titleStyle;
5252

5353
T data0 = data.iterator().next();
5454
// Set Excel header
@@ -66,8 +66,8 @@ default <T> void export(Exporter<T> exporter, OutputStream outputStream) throws
6666
sheet = workbook.getSheetAt(0);
6767

6868
} else {
69-
workbook = exporter.createWorkbook();
70-
sheet = workbook.createSheet(ExcelUtils.getSheetName(data0));
69+
workbook = exporter.getExcelType().equals(ExcelType.XLSX) ? new XSSFWorkbook() : new HSSFWorkbook();
70+
sheet = workbook.createSheet(ExcelUtils.getSheetName(data0.getClass()));
7171

7272
if (null != exporter.getTitleStyle()) {
7373
titleStyle = exporter.getTitleStyle().apply(workbook);

0 commit comments

Comments
 (0)