diff --git a/src/helpers/cells/cell_helpers.ts b/src/helpers/cells/cell_helpers.ts index e96313a4c..fdc022ff6 100644 --- a/src/helpers/cells/cell_helpers.ts +++ b/src/helpers/cells/cell_helpers.ts @@ -10,6 +10,9 @@ import { formatNumber, formatStandardNumber } from "../numbers"; export function formatValue(value: CellValue, format?: string): string { switch (typeof value) { case "string": + if (value.includes('\\"')) { + return value.replace(/\\"/g, '"'); + } return value; case "boolean": return value ? "TRUE" : "FALSE"; diff --git a/tests/plugins/cell.test.ts b/tests/plugins/cell.test.ts index c8f66416f..286079009 100644 --- a/tests/plugins/cell.test.ts +++ b/tests/plugins/cell.test.ts @@ -62,6 +62,12 @@ describe("getCellText", () => { }); expect(result).toBeCancelledBecause(CommandResult.TargetOutOfSheet); }); + + test("escape character is not display when formatting string", () => { + const model = new Model(); + setCellContent(model, "A1", '="hello \\"world\\""'); + expect(getCell(model, "A1")?.formattedValue).toBe('hello "world"'); + }); }); describe("link cell", () => {