在 Fast Report 6 的运行时垂直连接 table 个包含相同文本的单元格

Joining table cells containing the same text vertically during Runtime in Fast Report 6

我需要使用循环使用 TfrxTableObject.JoinSelection 加入选择,但这样做时我错过了 gap/shift/difference。 到目前为止,我设法加入了前 2 个细胞,但之后上述差距改变了一切。 注意:我知道这很容易,但我似乎被卡住了。

输入:

Title
A
A
(null)
B
B
B
(null)
C
C
C
C

输出:

Title
A
(null)
B
(null)
C

没有差距。

    var
     tb : frxtableobject1;
     i, total : integer;
     s, ls : string;
    begin
     tb := frxReport1.FindObject('tb') as tfrxtableobject;
     i := 0;
     total := 0;
     ls := '';
     repeat
      if i < 11 then s := tb.Cells[0,i].Text;
    
      if (s = ls) and (i < 12) then
      begin
       inc(total);
      end
      else
      begin
       if total > 0 then
         if ls <> '' then
          tb.JoinSelection(0,i-1-total,0,i-1);
       total := 0;
      end;
      ls := s;
      inc(i);
     until i > 12;
    end;