fix(export): preserve CSV null semantics

This commit is contained in:
二丫讲梵 authored and GitHub committed 2026-07-14 01:24:10 +08:00
1 parent 65e1100db8
commit 8e87ab2e39
6 files changed
+142 -34

No files matched your search

+1 -1
View File
@@ -6,7 +6,7 @@ export type ExportCellValue = string | number | boolean | null;
export function formatCsv(columns: string[], rows: ExportCellValue[][]): string {
const esc = (v: string) => `"${v.replace(/"/g, '""')}"`;
const header = columns.map(esc).join(",");
const body = rows.map((row) => row.map((c) => esc(c === null ? "NULL" : String(c))).join(",")).join("\n");
const body = rows.map((row) => row.map((c) => (c === null ? "" : esc(String(c)))).join(",")).join("\n");
return `${header}\n${body}`;
}