Skip to content

Commit 79c8a22

Browse files
committed
fix: handle escape option correctly for CSV export
1 parent 4c5144a commit 79c8a22

3 files changed

Lines changed: 4 additions & 3 deletions

File tree

docs/assets/guide/en/plugin/table-export.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export type ExportVTableToExcelOptions = {
4141

4242
export type ExportVTableToCsvOptions = {
4343
formatExportOutput?: (cellInfo: CellInfo) => string | undefined;
44-
escape?: boolean;
44+
escape?: boolean; // Whether to escape special symbols in strings to avoid interfering with CSV parsing, default true
4545
exportAllData?: boolean;
4646
downloadFile?: boolean;
4747
fileName?: string;

docs/assets/guide/zh/plugin/table-export.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export type ExportVTableToExcelOptions = {
4141

4242
export type ExportVTableToCsvOptions = {
4343
formatExportOutput?: (cellInfo: CellInfo) => string | undefined;
44-
escape?: boolean;
44+
escape?: boolean; // 是否需要将字符串中的特殊符号进行转义,以避免干扰CSV解析,默认为true
4545
exportAllData?: boolean;
4646
downloadFile?: boolean;
4747
fileName?: string;

packages/vtable-plugins/src/table-export/csv/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ function getCopyCellValue(
8181
}
8282

8383
let value = cellValue;
84-
if (option?.escape) {
84+
if (option?.escape !== false) {
85+
//escape默认逻辑改为true,进行转义
8586
value = escapeForCSV(value);
8687
} else if (typeof value === 'string') {
8788
value = '"' + value + '"';

0 commit comments

Comments
 (0)