diff --git a/components/fpspreadsheet/source/common/fpsexprparser.pas b/components/fpspreadsheet/source/common/fpsexprparser.pas index 5a55a80ce..9249b1ecf 100644 --- a/components/fpspreadsheet/source/common/fpsexprparser.pas +++ b/components/fpspreadsheet/source/common/fpsexprparser.pas @@ -1127,26 +1127,38 @@ begin end; function TsExpressionScanner.DoIdentifier: TsTokenType; +var + isInSqBr: Boolean; + isQuoted: Boolean; function IsR1C1Char(C: Char): Boolean; inline; begin - Result := (FParser.Dialect = fdExcelR1C1) and (C in ['[', ']', '-']); + if (FParser.Dialect = fdExcelR1C1) then + Result := (C = '[') or (C = ']') or (isInSqBr and (C = '-')) + else + Result := false; end; var C: Char; S: String; - isQuoted: Boolean; ok: Boolean; begin C := CurrentChar; isQuoted := C = ''''; + isInSqBr := C = '['; while ((not IsWordDelim(C)) or IsQuoted or IsR1C1Char(C)) and (C <> cNULL) do begin FToken := FToken + C; C := NextPos; if C = '''' then isQuoted := false; + if (FParser.Dialect = fdExcelR1C1) then begin + if (C = '[') then + isInSqBr := true + else if (C = ']') then + isInSqBr := false; + end; end; if (FParser.Dialect = fdExcelR1C1) then begin diff --git a/components/fpspreadsheet/source/common/fpspreadsheet.pas b/components/fpspreadsheet/source/common/fpspreadsheet.pas index bb9b7310b..bbd5859bd 100644 --- a/components/fpspreadsheet/source/common/fpspreadsheet.pas +++ b/components/fpspreadsheet/source/common/fpspreadsheet.pas @@ -5876,9 +5876,6 @@ begin exit; end; - formula := FFormulas.AddFormula(ACell^.Row, ACell^.Col, AFormula); - // wp: Why is this created when boIgnoreFormulas is active? - if not (boIgnoreFormulas in Workbook.Options) then begin // Remove '='; is not stored internally @@ -5895,6 +5892,8 @@ begin else parser.Expression := AFormula; AFormula := parser.Expression; + + formula := FFormulas.AddFormula(ACell^.Row, ACell^.Col, AFormula); except on E:Exception do begin if FWorkbook.FReadWriteFlag = rwfNormal then @@ -5904,7 +5903,7 @@ begin FName, GetCellString(ACell^.Row, ACell^.Col), E.Message] ); parser.Free; - FFormulas.DeleteFormula(ACell^.Row, ACell^.Col); + //FFormulas.DeleteFormula(ACell^.Row, ACell^.Col); exit; end; end; diff --git a/components/fpspreadsheet/source/common/xlsxml.pas b/components/fpspreadsheet/source/common/xlsxml.pas index f94444a6f..02495a469 100644 --- a/components/fpspreadsheet/source/common/xlsxml.pas +++ b/components/fpspreadsheet/source/common/xlsxml.pas @@ -1087,7 +1087,7 @@ begin s := GetAttrValue(ANode, 'ss:Protected'); if s ='1' then AWorksheet.Options := AWorksheet.Options + [soProtected]; - ; + ANode := ANode.FirstChild; while ANode <> nil do begin nodeName := ANode.NodeName; diff --git a/components/fpspreadsheet/tests/formulatests.pas b/components/fpspreadsheet/tests/formulatests.pas index 39f293b41..020423a43 100644 --- a/components/fpspreadsheet/tests/formulatests.pas +++ b/components/fpspreadsheet/tests/formulatests.pas @@ -89,7 +89,7 @@ type procedure Test_Write_Read_Calc3DFormula_BIFF5; procedure Test_Write_Read_Calc3DFormula_BIFF8; procedure Test_Write_Read_Calc3DFormula_OOXML; - procedure Test_Write_Read_Calc3DFormula_XML; +// procedure Test_Write_Read_Calc3DFormula_XML; procedure Test_Write_Read_Calc3DFormula_ODS; { Overwrite formula with other content } @@ -887,11 +887,11 @@ procedure TSpreadWriteReadFormulaTests.Test_Write_Read_Calc3DFormula_OOXML; begin Test_Write_Read_Calc3DFormulas(sfOOXML); end; - + { procedure TSpreadWriteReadFormulaTests.Test_Write_Read_Calc3DFormula_XML; begin Test_Write_Read_Calc3DFormulas(sfExcelXML); -end; +end; } procedure TSpreadWriteReadFormulaTests.Test_Write_Read_Calc3DFormula_ODS; begin