如果想简单点以下这两个控件包中就有,
http://www.nease.net/~tomcar/file/QRD121.zip
http://www.net-wing.net/kangwei/newvcl/fastreport/fastreport230full.zip
如果想麻烦点就用Delphi5的Server组控件吧!是走的OLE;
如下让记录一条条写进去;
procedure TForm1.Button1Click(Sender: TObject);
var
Template,NewTemplate,ItemIndex:OleVariant;
begin
WordApplication1.Connect;
WordApplication1.Visible:=True;
WordApplication1.Caption:='Word Test'
end;
procedure TForm1.WordApplication1Quit(Sender: TObject);
begin
CheckBox1.Checked:=False;
end;
procedure TForm1.WordApplication1Startup(Sender: TObject);
begin
CheckBox1.Checked:=True;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
WordApplication1.Quit;
WordApplication1.Disconnect;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
WordDocument1.Connect;
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
WordDocument1.Range.InsertAfter(Edit1.text)
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
WordFont1.ConnectTo(WordDocument1.Sentences.Get_Last.Font);
WordFont1.Name := ComboBox1.Text;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
ComboBox1.Items := Screen.Fonts;
end;
procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
WordDocument1.Range.InsertAfter(#13)
end;
procedure TForm1.SpeedButton2Click(Sender: TObject);
begin
WordDocument1.Range.InsertAfter(',')
end;
procedure TForm1.SpeedButton3Click(Sender: TObject);
begin
WordDocument1.Range.InsertAfter('。')
end;
procedure TForm1.Button6Click(Sender: TObject);
begin
WordDocument1.Range.InsertAutoText;
end;
或直接走OLE:
procedure TForm1.Button1Click(Sender: TObject);
begin
V:=CreateOleObject('Word.Document');
// V.Visible:=True;
X:=V.Range(0,0);
X.InsertBefore('Hello from Delphi');
X.Font.Name:='Arial';
X.Font.Size:=18;
X.InsertParagraphAfter;
X:=V.Range(4,4);
X.InsertBefore('ttttttttttttttt');
X.Font.Name:='Arial';
X.Font.Size:=18;
X.InsertParagraphAfter;
V.PrintPreview;
V.SaveAs('c:/Hold11.doc');
V.Quit;
end;
也是一条条写进去。
要不就直接组织Word的二进制文件,这可要知道它的文件格式。