Skip to content

Commit c82386f

Browse files
committed
升级第三方库版本
1 parent 3054860 commit c82386f

File tree

4 files changed

+34
-16
lines changed

4 files changed

+34
-16
lines changed

pom.xml

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,34 @@
1414
<dependency>
1515
<groupId>commons-cli</groupId>
1616
<artifactId>commons-cli</artifactId>
17-
<version>1.4</version>
17+
<version>1.8.0</version>
1818
</dependency>
1919
<dependency>
2020
<groupId>org.apache.commons</groupId>
2121
<artifactId>commons-text</artifactId>
22-
<version>1.10.0</version>
22+
<version>1.12.0</version>
2323
</dependency>
2424
<dependency>
2525
<groupId>org.apache.poi</groupId>
2626
<artifactId>poi-excelant</artifactId>
27-
<version>3.11</version>
27+
<version>5.3.0</version>
2828
</dependency>
2929
<dependency>
3030
<groupId>org.yaml</groupId>
3131
<artifactId>snakeyaml</artifactId>
32-
<version>1.32</version>
32+
<version>2.0</version>
3333
</dependency>
3434
<!-- https://mvnrepository.com/artifact/org.json/json -->
3535
<dependency>
3636
<groupId>org.json</groupId>
3737
<artifactId>json</artifactId>
38-
<version>20200518</version>
38+
<version>20231013</version>
39+
</dependency>
40+
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
41+
<dependency>
42+
<groupId>org.apache.logging.log4j</groupId>
43+
<artifactId>log4j-core</artifactId>
44+
<version>2.24.2</version>
3945
</dependency>
4046
</dependencies>
4147
<build>
@@ -74,4 +80,11 @@
7480
</plugin>
7581
</plugins>
7682
</build>
83+
<repositories>
84+
<repository>
85+
<id>maven_central</id>
86+
<name>Maven Central</name>
87+
<url>https://repo.maven.apache.org/maven2/</url>
88+
</repository>
89+
</repositories>
7790
</project>

src/main/java/com/yanglb/codegen/core/reader/BaseReader.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import java.util.List;
3232
import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator;
3333
import org.apache.poi.ss.usermodel.Cell;
34+
import org.apache.poi.ss.usermodel.CellType;
3435
import org.apache.poi.xssf.usermodel.XSSFCell;
3536
import org.apache.poi.xssf.usermodel.XSSFSheet;
3637
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
@@ -185,23 +186,23 @@ private boolean isReadable(String sheetName) {
185186
*/
186187
public String getCellStringValue(XSSFCell cell) {
187188
String result = null;
188-
int type = cell.getCellType();
189-
if(type == Cell.CELL_TYPE_FORMULA) type = cell.getCachedFormulaResultType();
190-
if(type == Cell.CELL_TYPE_BLANK) return null;
191-
if(type == Cell.CELL_TYPE_ERROR) {
189+
CellType type = cell.getCellType();
190+
if(type == CellType.FORMULA) type = cell.getCachedFormulaResultType();
191+
if(type == CellType.BLANK) return null;
192+
if(type == CellType.ERROR) {
192193
return "#VALUE!";
193194
}
194195

195196
switch(type) {
196-
case Cell.CELL_TYPE_BOOLEAN:
197+
case BOOLEAN:
197198
result = String.valueOf(cell.getBooleanCellValue());
198199
break;
199200

200-
case Cell.CELL_TYPE_STRING:
201+
case STRING:
201202
result = cell.getStringCellValue();
202203
break;
203204

204-
case Cell.CELL_TYPE_NUMERIC:
205+
case NUMERIC:
205206
{
206207
if(cell.getCellStyle().getDataFormat() == DataFormatType.FORMAT_DATE) {
207208
Date date = cell.getDateCellValue();

src/main/java/com/yanglb/codegen/core/reader/impl/HashMapReaderImpl.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import com.yanglb.codegen.utils.StringUtil;
2020
import java.util.HashMap;
2121
import java.util.List;
22+
23+
import org.apache.poi.ss.usermodel.CellType;
2224
import org.apache.poi.xssf.usermodel.XSSFCell;
2325
import org.apache.poi.xssf.usermodel.XSSFRow;
2426
import org.apache.poi.xssf.usermodel.XSSFSheet;
@@ -43,7 +45,7 @@ protected HashMap<String, String> onReader(XSSFSheet sheet) {
4345
XSSFRow xssfRow = sheet.getRow(row);
4446
String key = this.getCellStringValue(xssfRow.getCell(this.startColNo));
4547
// key不为空时添加到Map中
46-
if(xssfRow.getCell(this.startColNo).getCellType() == XSSFCell.CELL_TYPE_BLANK
48+
if(xssfRow.getCell(this.startColNo).getCellType() == CellType.BLANK
4749
|| StringUtil.isNullOrEmpty(key)) {
4850
continue;
4951
}

src/main/java/com/yanglb/codegen/core/reader/impl/TableReaderImpl.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
import java.util.HashMap;
2525
import java.util.List;
2626
import java.util.Map;
27+
28+
import org.apache.poi.ss.usermodel.CellType;
2729
import org.apache.poi.xssf.usermodel.XSSFCell;
2830
import org.apache.poi.xssf.usermodel.XSSFRow;
2931
import org.apache.poi.xssf.usermodel.XSSFSheet;
@@ -78,16 +80,16 @@ protected TableModel onReader(XSSFSheet sheet) throws CodeGenException {
7880
throw new CodeGenException(String.format("error: sheet(%s), row(%d), col(%d)",
7981
sheet.getSheetName(), rowNo, colNo));
8082
}
81-
if(cell.getCellType() != XSSFCell.CELL_TYPE_BLANK
82-
&& cell.getCellType() != XSSFCell.CELL_TYPE_ERROR) {
83+
if(cell.getCellType() != CellType.BLANK
84+
&& cell.getCellType() != CellType.ERROR) {
8385
allBlank = false;
8486
}
8587
String value = this.getCellStringValue(cell);
8688

8789
// 第一行为KEY
8890
if(rowNo == this.startRowNo) {
8991
if(StringUtil.isNullOrEmpty(value)
90-
|| cell.getCellType() ==XSSFCell.CELL_TYPE_BLANK
92+
|| cell.getCellType() ==CellType.BLANK
9193
|| "-".equals(value)) {
9294
// 空白/忽略的列无视
9395
continue;

0 commit comments

Comments
 (0)