Skip to content

Commit 79402f1

Browse files
committed
调整读取数据遇到 null 单元格时行为
1. 如果是 KEY 行问题则依然抛出错误 2. 如果不是则用空值代替
1 parent 7de8909 commit 79402f1

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,11 @@ protected TableModel onReader(XSSFSheet sheet) throws CodeGenException {
7474
for (int colNo = this.startColNo; colNo < row.getLastCellNum(); colNo++) {
7575
XSSFCell cell = row.getCell(colNo);
7676
if (cell == null) {
77-
throw new CodeGenException(String.format("error: sheet(%s), row(%d), col(%d)",
78-
sheet.getSheetName(), rowNo, colNo));
77+
if (rowNo == this.startRowNo) {
78+
throw new CodeGenException(String.format("error: sheet(%s), row(%d), col(%d)",
79+
sheet.getSheetName(), rowNo, colNo));
80+
}
81+
cell = row.createCell(colNo, CellType.STRING);
7982
}
8083
if (cell.getCellType() != CellType.BLANK
8184
&& cell.getCellType() != CellType.ERROR) {

0 commit comments

Comments
 (0)