fpspreadsheet: Fix formula MATCH for match_type 1.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9388 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz 2024-07-17 14:33:12 +00:00
parent d7fad0c7b8
commit fe27d6ec34

View File

@ -2738,7 +2738,8 @@ procedure fpsMATCH(var Result: TsExpressionResult;
value. The array can be sorted in any order.) value. The array can be sorted in any order.)
match_type = -1: The MATCH function will find the smallest value that is match_type = -1: The MATCH function will find the smallest value that is
greater than or equal to value. You should be sure to sort your array in greater than or equal to value. You should be sure to sort your array in
descending order. } descending order.
Return value is the 1-based index in the array. }
var var
match_type: Integer; match_type: Integer;
searchString: String; searchString: String;
@ -2843,37 +2844,17 @@ begin
if IsCol then if IsCol then
begin begin
if match_type = -1 then for r := r2 downto r1 do
begin if Matches(sheet.FindCell(r, c1)) then begin
for r := r2 downto r1 do Result := IntegerResult(r - integer(r1) + 1);
if Matches(sheet.FindCell(r, c1)) then begin exit;
Result := IntegerResult(r - integer(r1) + 1); end;
exit;
end;
end else
begin
for r := r1 to r2 do
if Matches(sheet.FindCell(r, c1)) then begin
Result := IntegerResult(r - integer(r1) + 1);
exit;
end;
end;
end else end else
begin begin
if match_type = -1 then for c := c2 downto c1 do
begin if Matches(sheet.FindCell(r1, c)) then begin
for c := c2 downto c1 do Result := IntegerResult(c - Integer(c1) + 1);
if Matches(sheet.FindCell(r1, c)) then begin exit;
Result := IntegerResult(c - Integer(c1) + 1);
exit;
end;
end else
begin
for c := c1 to c2 do
if Matches(sheet.FindCell(r1, c)) then begin
Result := IntegerResult(c - Integer(c1) + 1);
exit;
end;
end; end;
end; end;