李
李璋琦
Unregistered / Unconfirmed
GUEST, unregistred user!
我写了下面代码,想生成一个表表,开始是标题,之后是表格最后是正文:
try
Template := EmptyParam;
NewTemplate := True;
ItemIndex := 1;
try
Wordapplication.Connect;
except
MessageDlg('Word may not be installed', mtError, [mbOk], 0);
Abort;
end;
Wordapplication.Visible := True;
WordApplication.Caption := 'Delphi automation';
{Create new document}
Template := EmptyParam;
NewTemplate := False;
WordApplication.Documents.Add(Template, NewTemplate);
WordDocument.ConnectTo(WordApplication.Documents.Item(ItemIndex));
WordDocument.Range.InsertAfter('报表'+#13);
WordDocument.Range.InsertAfter(#13);
WordDocument.Tables.Add(WordDocument.Content,11,2);
WordDocument.Tables.item(1).cell(1,1).Range.Text :='12345';
WordDocument.Range.InsertAfter('正文一:');
但’报表‘二字被后来插入的表格覆盖,’正文一‘却可以正常插入。如何解决?
try
Template := EmptyParam;
NewTemplate := True;
ItemIndex := 1;
try
Wordapplication.Connect;
except
MessageDlg('Word may not be installed', mtError, [mbOk], 0);
Abort;
end;
Wordapplication.Visible := True;
WordApplication.Caption := 'Delphi automation';
{Create new document}
Template := EmptyParam;
NewTemplate := False;
WordApplication.Documents.Add(Template, NewTemplate);
WordDocument.ConnectTo(WordApplication.Documents.Item(ItemIndex));
WordDocument.Range.InsertAfter('报表'+#13);
WordDocument.Range.InsertAfter(#13);
WordDocument.Tables.Add(WordDocument.Content,11,2);
WordDocument.Tables.item(1).cell(1,1).Range.Text :='12345';
WordDocument.Range.InsertAfter('正文一:');
但’报表‘二字被后来插入的表格覆盖,’正文一‘却可以正常插入。如何解决?