Files
WebApp/src/app/features/indicadores/export/cell-sanitizer.ts
T
2026-11-12 22:40:21 -06:00

8 lines
399 B
TypeScript

// A cell that starts with one of these is read as a formula by spreadsheet programs once the text is pasted or converted.
const FORMULA_START = /^[=+\-@\t\r]/;
/** Text that is safe to write into a spreadsheet cell: a leading formula character is neutralised with an apostrophe. */
export function neutralizeFormula(text: string): string {
return FORMULA_START.test(text) ? `'${text}` : text;
}