From 00c3bdb6396aa320cb6afd2a66ae0d90f9fbcfb3 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Thu, 15 Apr 2021 13:40:42 +0000 Subject: [PATCH] fpspreadsheet: Fix ignored-formula feature. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7997 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../other/ignore_formulas/demo_ignore_formula.lpr | 2 +- .../fpspreadsheet/source/common/fpspreadsheet.pas | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/components/fpspreadsheet/examples/other/ignore_formulas/demo_ignore_formula.lpr b/components/fpspreadsheet/examples/other/ignore_formulas/demo_ignore_formula.lpr index e4429c249..306312ea8 100644 --- a/components/fpspreadsheet/examples/other/ignore_formulas/demo_ignore_formula.lpr +++ b/components/fpspreadsheet/examples/other/ignore_formulas/demo_ignore_formula.lpr @@ -6,7 +6,7 @@ confirmation must be given to save the file because it has been changed by LOCalc. - This method does not work with Excel because it writes an additonal + This method does not work with Excel because it writes an additional folder and xml files for external links. } program demo_ignore_formula; diff --git a/components/fpspreadsheet/source/common/fpspreadsheet.pas b/components/fpspreadsheet/source/common/fpspreadsheet.pas index 9fced0771..88a2205a5 100644 --- a/components/fpspreadsheet/source/common/fpspreadsheet.pas +++ b/components/fpspreadsheet/source/common/fpspreadsheet.pas @@ -4783,12 +4783,14 @@ begin exit; end; - if not (boIgnoreFormulas in Workbook.Options) then - begin - // Remove '='; is not stored internally - if (AFormula[1] = '=') then - AFormula := Copy(AFormula, 2, Length(AFormula)); + // Remove '='; is not stored internally + if (AFormula[1] = '=') then + Delete(AFormula, 1, 1); + if (boIgnoreFormulas in Workbook.Options) then + formula := FFormulas.AddFormula(ACell^.Row, ACell^.Col, AFormula) + else + begin parser := TsSpreadsheetParser.Create(self); try if ALocalized then