From 76db16c526057138e470244ccef1cd67e853ccc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A1=E8=89=B2?= Date: Mon, 25 Sep 2023 17:06:05 +0800 Subject: [PATCH] fix(abc:st): correct width misalignment in export excel (#1655) --- packages/abc/st/st-export.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/packages/abc/st/st-export.ts b/packages/abc/st/st-export.ts index 3b30295fd2..d70a8a2a1d 100644 --- a/packages/abc/st/st-export.ts +++ b/packages/abc/st/st-export.ts @@ -51,20 +51,17 @@ export class STExport { const sheet: { [key: string]: NzSafeAny } = (sheets[opt.sheetname || 'Sheet1'] = {}); const dataLen = opt.data!.length; let validColCount = 0; - let loseCount = 0; - const columns = opt.columens! as _STColumn[]; + const columns = (opt.columens! as _STColumn[]).filter( + col => !(col.exported === false || !col.index || !(!col.buttons || col.buttons.length === 0)) + ); if (columns.findIndex(w => w._width != null) !== -1) { // wpx: width in screen pixels https://github.com/SheetJS/sheetjs#column-properties sheet['!cols'] = columns.map(col => ({ wpx: col._width })); } for (let colIdx = 0; colIdx < columns.length; colIdx++) { const col = columns[colIdx]; - if (col.exported === false || !col.index || !(!col.buttons || col.buttons.length === 0)) { - ++loseCount; - continue; - } ++validColCount; - const columnName = this.xlsxSrv.numberToSchema(colIdx + 1 - loseCount); + const columnName = this.xlsxSrv.numberToSchema(colIdx + 1); sheet[`${columnName}1`] = { t: 's', v: typeof col.title === 'object' ? col.title.text : col.title