Skip to content

Commit 580b065

Browse files
authored
fix(export): 处理CSV导出中的特殊值,确保null、undefined和NaN正确显示 (#3418)
1 parent d02b314 commit 580b065

File tree

1 file changed

+9
-0
lines changed
  • packages/renderless/src/grid/plugins

1 file changed

+9
-0
lines changed

packages/renderless/src/grid/plugins/export.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,15 @@ const getCsvContent = ($table, opts, oColumns, oData) => {
7373
const { columns, datas } = getCsvData(opts, oData, oColumns, tableEl)
7474
let content = '\uFEFF' // BOM字节序标记
7575
const transfrom = (str) => {
76+
// 处理特殊值
77+
if (str === null || str === undefined) {
78+
return '' + tab
79+
}
80+
81+
if (typeof str === 'number' && isNaN(str)) {
82+
return '-' + tab
83+
}
84+
7685
if (typeof str === 'string' && str.replace(/ /g, '').match(/[\s,"]/)) {
7786
str = '"' + str.replace(/"/g, '""') + '"'
7887
}

0 commit comments

Comments
 (0)