diff --git a/components/fpspreadsheet/source/common/fpsfunc.pas b/components/fpspreadsheet/source/common/fpsfunc.pas index d6cc85943..81269663c 100644 --- a/components/fpspreadsheet/source/common/fpsfunc.pas +++ b/components/fpspreadsheet/source/common/fpsfunc.pas @@ -2840,6 +2840,11 @@ begin rtCell: begin cell := ArgToCell(Args[0]); + if cell = nil then + begin + Result := ErrorResult(errWrongType); + exit; + end; case cell^.ContentType of cctUTF8String: searchString := cell^.UTF8StringValue; cctNumber: numSearchValue := cell^.NumberValue; diff --git a/components/fpspreadsheet/source/common/fpsutils.pas b/components/fpspreadsheet/source/common/fpsutils.pas index 23e478258..0b29871ab 100644 --- a/components/fpspreadsheet/source/common/fpsutils.pas +++ b/components/fpspreadsheet/source/common/fpsutils.pas @@ -1296,14 +1296,16 @@ end; @returns @TRUE when the sheet name must be quoted, @FALSE otherwise -------------------------------------------------------------------------------} function SheetNameNeedsQuotes(ASheet: String): Boolean; +const + FORMULA_CHARS = ['+', '-', '*', '/', '^']; var i: Integer; begin if ASheet <> '' then begin Result := true; - if (ASheet[1] in ['0'..'9', '.']) then exit; + if (ASheet[1] in (['0'..'9', '.'] + FORMULA_CHARS)) then exit; for i := 1 to Length(ASheet) do - if (ASheet[i] in [' ', '<', '>', '=']) then exit; + if (ASheet[i] in ([' ', '<', '>', '='] + FORMULA_CHARS)) then exit; end; Result := false; end;