fix(export): preserve safely scaled numeric XLSX cells

Closes #5416
This commit is contained in:
t8y2 committed 2026-08-12 00:16:19 +00:00
1 parent 521fa2eb83
commit 5981c20675
4 files changed
+130 -7

No files matched your search

+2 -1
View File
@@ -125,7 +125,8 @@ function estimateColumnWidths(columns: readonly string[], rows: readonly (readon
function safeExcelNumber(value: string): string | undefined {
const trimmed = value.trim();
if (!trimmed || !Number.isFinite(Number(trimmed))) return undefined;
const significantDigits = (trimmed.split(/[eE]/, 1)[0].match(/\d/g) || []).join("").replace(/^0+/, "").length;
const [integerPart, fractionPart = ""] = trimmed.split(/[eE]/, 1)[0].split(".", 2);
const significantDigits = `${integerPart}${fractionPart.replace(/0+$/, "")}`.replace(/\D/g, "").replace(/^0+/, "").length;
return significantDigits <= 15 ? trimmed : undefined;
}