全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:942
推到 Plurk!
推到 Facebook!

請教各位高手一個問題!!

尚未結案
joyillen
一般會員


發表:3
回覆:2
積分:1
註冊:2003-10-14

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-11-03 13:40:10 IP:61.16.xxx.xxx 未訂閱
各位高手,小弟最近在寫一支用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

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-11-03 22:17:07 IP:211.76.xxx.xxx 未訂閱
你可以試試觀察一下crystal report轉出word檔怎麼運作的 我發現他是動態建立文字方塊後再填的
系統時間:2024-05-16 12:19:50
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!