diff --git a/lib/parser.js b/lib/parser.js index a5fd9c9..af55f6e 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -135,7 +135,10 @@ function parseSheet(sheet, setting) { let row = sheet.data[i_row]; let parsed_row = parseRow(row, i_row, setting.head); - + if (!parsed_row) { + console.log("err null row:", i_row + 1) + continue; + } if (setting.type === SheetType.MASTER) { let id_cell = _.find(setting.head, item => { @@ -167,6 +170,7 @@ function parseRow(row, rowIndex, head) { let result = {}; let id; + let isAllNull = true; for (let index = 0; index < head.length; index++) { let cell = row[index]; @@ -182,6 +186,8 @@ function parseRow(row, rowIndex, head) { continue; } + isAllNull = false + switch (type) { case DataType.ID: id = cell + ''; @@ -241,7 +247,10 @@ function parseRow(row, rowIndex, head) { } } - return result; + if (isAllNull) + return null; + else + return result; } /** @@ -368,4 +377,4 @@ module.exports = { return parsed_workbook; } -}; \ No newline at end of file +};