From a799681194c7758df48ef4699f35de8c440e79ed Mon Sep 17 00:00:00 2001 From: Geequlim Date: Tue, 26 Jan 2021 16:13:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E7=BB=93=E6=9E=84=E4=BD=93?= =?UTF-8?q?=20null=20=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/excel-exporter/TableParser.ts | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/excel-exporter/TableParser.ts b/src/excel-exporter/TableParser.ts index 424fbda..d9060dc 100644 --- a/src/excel-exporter/TableParser.ts +++ b/src/excel-exporter/TableParser.ts @@ -164,10 +164,10 @@ export class Field { let obj = {}; let isAllNullish = true; for (const c of this.children) { - let value = c.parse_row(row); + let value = c.check_is_null(row) ? null : c.parse_row(row); if (c.is_array) { let arr: any[] = obj[c.name] || []; - if (this.constant_array_length || value != null) { + if (this.constant_array_length || value) { arr.push(value); } obj[c.name] = arr; @@ -194,6 +194,22 @@ export class Field { return null; } } + + protected check_is_null(row: RawTableCell[]): boolean { + if (this.children) { + let isAllNullish = true; + for (const c of this.children) { + isAllNullish = isAllNullish && c.check_is_null(row); + if (!isAllNullish) { + return false; + } + } + return isAllNullish; + } else { + let cell = row[this.columns.start]; + return !cell || cell.t === 'z'; + } + } } const TypeCompatibility = {