DELPHI与WORD怎样连用 急~急~ Delphi / Windows SDK/API http://www.delphi2007.net/DelphiDB/html/delphi_20061224122056134.html
我想用DELPHI做一个简单的数据库,在输入完内容后用WORD打印出,但是不知道用什么控件及代码应怎样写,我是位新手,请高手多多指教。(注:打印出来是带用表格形式的)
http://community.csdn.net/Expert/topic/5238/5238318.xml?temp=3.475368E-03
导出DBGrid为Word表格。 procedure TForm1.Button1Click(Sender: TObject); var WordApp,WordDoc,WordTable:OleVariant; i,j:integer; begin WordApp:=CreateOleObject('Word.Application'); WordApp.Visible:=True; WordDoc:=WordApp.Documents.Add; WordTable:=WordDoc.Tables.Add(WordApp.Selection.Range,DBGrid1.DataSource.DataSet.RecordCount+1,DBGrid1.Columns.Count); for i:=1 to DBGrid1.Columns.Count do WordTable.Cell(1,i).Range.InsertAfter(DBGrid1.Columns[i-1].Title.Caption); i:=2; with DBGrid1.DataSource.DataSet do while not eof do begin for j:=1 to DBGrid1.Columns.Count do WordTable.Cell(i,j).Range.InsertAfter(DBGrid1.Columns[j-1].Field.Value); Next; Inc(i); end; end;
谢谢~! 我试试!
|
请发表评论