From f54a1641df5bbabc6f57b63d719d5dfcb3ac6a74 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Mon, 9 Oct 2023 23:18:59 +0000 Subject: [PATCH] fpspreadsheet: Fix writing formulas with "forbidden characters" in the sheet name ('<', '>', '='). git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8946 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/fpspreadsheet/source/common/fpsutils.pas | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/components/fpspreadsheet/source/common/fpsutils.pas b/components/fpspreadsheet/source/common/fpsutils.pas index 0e6adeb54..e69ab134a 100644 --- a/components/fpspreadsheet/source/common/fpsutils.pas +++ b/components/fpspreadsheet/source/common/fpsutils.pas @@ -1269,17 +1269,20 @@ end; {@@ ---------------------------------------------------------------------------- Determines whether a worksheet name must to be quoted. This is needed when the name begins with a numeral or a period, or when the name contains a space - character. + character. Also required if the name contains '<' or '>'. @param ASheet Name of the worksheet to be analyzed @returns @TRUE when the sheet name must be quoted, @FALSE otherwise -------------------------------------------------------------------------------} function SheetNameNeedsQuotes(ASheet: String): Boolean; +var + i: Integer; begin if ASheet <> '' then begin Result := true; if (ASheet[1] in ['0'..'9', '.']) then exit; - if (pos(' ', ASheet) > 0) then exit; + for i := 1 to Length(ASheet) do + if (ASheet[i] in [' ', '<', '>', '=']) then exit; end; Result := false; end;