請教各位高手一個問題!! |
尚未結案
|
joyillen
一般會員 發表:3 回覆:2 積分:1 註冊:2003-10-14 發送簡訊給我 |
各位高手,小弟最近在寫一支用word呈現的報表,程式碼如下
我最主要是在word上劃一個table並將資料帶入 table指定位置中。
目前這個方法是沒問題的!只是我發現用這種方式把資料呈現在word上速度很慢。
不知道各位高手有沒有其他的辦法,可以將文字填入至指定的table中呢?
可否請各位高手告訴我呢?
感激不盡。....
procedure TForm10.Button3Click(Sender: TObject);
var Template,NewTemplate,ItemIndex,_WordDocumentType,_Visible:OleVariant;
_DefaultTableBehavior,_AutoFitBehavior:OleVariant;
i:integer;
_NumberRows:OleVariant;
Linecount:OleVariant;
_Unit,_Extend:OleVariant;
RespStr:String;
begin
NewTemplate:=false;
template:= EmptyParam;
_WordDocumentType:=wdTypeDocument;
_Visible:=true;
WordApplication1.Documents.Add(template, NewTemplate, _WordDocumentType,_Visible);
ItemIndex:=1;
WordDocument1.ConnectTo(WordApplication1.Documents.Item(ItemIndex));
WordApplication1.Visible:= True; WordDocument1.Characters.Last.Select;
_DefaultTableBehavior:=wdWord9TableBehavior;
_AutoFitBehavior:=wdAutoFitFixed; //標題
WordApplication1.Selection.Range.InsertAfter(' 客戶關係報表' #13);
Linecount:=3;
_Unit:=wdLine;
_Extend:=wdMove; //wdExtend
Wordapplication1.Selection.MoveDown(_Unit,LineCount,_Extend);
//end //表頭
ADOQuery1.Active:=false;
ADOQuery1.active:=true;
ADOQuery1.First;
i:=0;
while not ADOQuery1.Eof do
begin
WordDocument1.Tables.Add(Wordapplication1.Selection.Range, 3,1,_DefaultTableBehavior, _AutoFitBehavior);
Wordapplication1.Selection.MoveDown(_Unit,LineCount,_Extend);//跳行
WordDocument1.Tables.Add(Wordapplication1.Selection.Range, 7,3,_DefaultTableBehavior, _AutoFitBehavior);
Linecount:=10;
Wordapplication1.Selection.MoveDown(_Unit,LineCount,_Extend);//跳行
WordDocument1.Tables.Add(Wordapplication1.Selection.Range, 2,1,_DefaultTableBehavior, _AutoFitBehavior);
WordDocument1.Tables.Item (WordDocument1.Tables.Count). Cell(4,1).Range.Text:=' 姓名';
WordDocument1.Tables.Item (WordDocument1.Tables.Count). Cell(4,2).Range.Text:=' 電話';
WordDocument1.Tables.Item (WordDocument1.Tables.Count). Cell(4,3).Range.Text:=' 地址';
end; end;
|
hahalin
版主 發表:295 回覆:1698 積分:823 註冊:2002-04-14 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |