procedure TForm1.Button1Click(Sender: TObject);
begin
if not assigned(f) then
f := TF1Book.Create(Self);
f.Parent := Self;
showmessage(f.TextRC[1, 1]);
// f.TextRC[1, 1] := 'abc';
end;
找到原因了,是Delphi生成TLB.pas文件时候的bug
生成的函数是
procedure TF1Book.Set_TextRC(nRow: Integer; nCol: Integer; const Param3: WideString);
{ Warning: The property TextRC has a setter and a getter whose
types do not match. Delphi was unable to generate a property of
this sort and so is using a Variant to set the property instead. }
var
InterfaceVariant: OleVariant;
begin
InterfaceVariant := DefaultInterface;
InterfaceVariant.TextRC := Param3;
end;
但是,应该的代码是
procedure TF1Book.Set_TextRC(nRow: Integer; nCol: Integer; const Param3: WideString);
{ Warning: The property TextRC has a setter and a getter whose
types do not match. Delphi was unable to generate a property of
this sort and so is using a Variant to set the property instead. }
var
InterfaceVariant: OleVariant;
begin
InterfaceVariant := DefaultInterface;
InterfaceVariant.TextRC[nRow, nCol] := Param3;
end;