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

StringGrid的資料如何透過rvCustomConnection列印?

尚未結案
morepatric
一般會員


發表:9
回覆:17
積分:5
註冊:2003-07-21

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-07-03 19:14:30 IP:61.59.xxx.xxx 未訂閱
EX: StringGrid.Rows[0].CommaText := '1,2,3'; StringGrid.Rows[1].CommaText := '4,5,6'; StringGrid.Rows[2].CommaText := '7,8,9'; 如何利用rvCustomConnection列印成 1 2 3 4 5 6 7 8 9 用一DBBand,而能夠重覆列印三列的資料。
hahalin
版主


發表:295
回覆:1698
積分:823
註冊:2002-04-14

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-07-03 19:48:56 IP:218.170.xxx.xxx 未訂閱
stringgrid-->clientdataset clientdataset-->rvCustomConnection
morepatric
一般會員


發表:9
回覆:17
積分:5
註冊:2003-07-21

發送簡訊給我
#3 引用回覆 回覆 發表時間:2004-07-17 18:03:01 IP:61.59.xxx.xxx 未訂閱
試了還是有點問題, 使用clientdataset一定得用LoadFromFile嗎? 還是可以用別的方式直接將StringGrid中的資料Append至clientdataset?
jumo
一般會員


發表:33
回覆:65
積分:24
註冊:2002-04-17

發送簡訊給我
#4 引用回覆 回覆 發表時間:2004-07-18 19:39:06 IP:211.20.xxx.xxx 未訂閱
var cdsTemp: TClientDataSet;
begin
  cdsTemp := TClientDataSet.Create(self);
  cdsTemp.FieldDefs.Add('Field1', ftInteger, 0, False);
  cdsTemp.FieldDefs.Add('Field2', ftInteger, 0, False);
  cdsTemp.FieldDefs.Add('Field3', ftInteger, 0, False);
  cdsTemp.CreateDataSet;      cdsTemp.Append;
  cdsTemp['Field1'] := 1;
  cdsTemp['Field2'] := 2;
  cdsTemp['Field3'] := 3;
  ......
  cdsTemp.Post;
end;
webber
初階會員


發表:54
回覆:76
積分:26
註冊:2004-04-20

發送簡訊給我
#5 引用回覆 回覆 發表時間:2004-08-19 18:17:51 IP:220.130.xxx.xxx 未訂閱
總算能用rave 列印String Grid了 不過是用一怪招:P 這一個怪招,我是先post在 new group: nevrona.public.rave.developer.delphi.rave 請各位前輩多多指教,小弟破英文請忍耐一下, 用Rave太累,懶得用中文post ----------------------------------------------------------- Finally i found a tricky way to use a StringGrid as the datasource of Rave report >< At first i added RvCustomConnection1:TRvCustomConnection Then I implemented its method: GetCols, GetRow, EOF, First, Next(sample code is showed in the end of this article) After that i added a Table1:TTable and RvTableConnection1: RvTableConnection in delphi visual designer. Then add the fields i need to use in rave designer, e.g. week1, week2, week3, etc. Then invoke the rave designer by double-click RvProject1:TRvProject Then add a direct data view - dataview1 and set its connectionName as RvTableConnection1 So dataview1 have this fields week1, week2, week3, etc Then I changed the connectionName of dataview1 to RvCustomConnection1. Now i can Execute the program and have the correct report.... T_T But does anybody know the "regular" way to use RvCustomConnection1 o_O webber > > ////////////////////////////// my code > > > > unit Unit1; > > > > interface > > > > uses > > Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, > Forms, > > Dialogs, Grids, BaseGrid, AdvGrid, RpCon, RpRave, RpDefine, RpBase, > > RpSystem,RvDataField, StdCtrls; > > > > type > > TForm1 = class(TForm) > > AdvStringGrid1: TAdvStringGrid; > > RvSystem1: TRvSystem; > > RvProject1: TRvProject; > > RvCustomConnection1: TRvCustomConnection; > > Button1: TButton; > > procedure RvCustomConnection1GetCols(Connection: TRvCustomConnection); > > procedure RvCustomConnection1GetRow(Connection: TRvCustomConnection); > > procedure RvCustomConnection1EOF(Connection: TRvCustomConnection; > > var Eof: Boolean); > > procedure RvCustomConnection1First(Connection: TRvCustomConnection); > > procedure RvCustomConnection1Next(Connection: TRvCustomConnection); > > procedure Button1Click(Sender: TObject); > > private > > { Private declarations } > > giCount:Integer; > > public > > { Public declarations } > > end; > > > > var > > Form1: TForm1; > > > > implementation > > > > {$R *.dfm} > > > > procedure TForm1.RvCustomConnection1GetCols( > > Connection: TRvCustomConnection); > > begin > > Connection.WriteField('weeka',dtString,10,'weekc',''); > > Connection.WriteField('weekb',dtString,10,'weekb',''); > > Connection.WriteField('weekc',dtString,10,'weekc',''); > > Connection.WriteField('weekd',dtString,10,'weekd',''); > > // > > end; > > > > procedure TForm1.RvCustomConnection1GetRow( > > Connection: TRvCustomConnection); > > > > begin > > > > > > Connection.WriteStrData('week1','1-' inttostr(giCount)); > > Connection.WriteStrData('week2','2-' inttostr(giCount),); > > Connection.WriteStrData('week3', '3-' inttostr(giCount)); > > Connection.WriteStrData('week4', '4-' inttostr(giCount)); > > > > end; > > > > procedure TForm1.RvCustomConnection1EOF(Connection: TRvCustomConnection; > > var Eof: Boolean); > > begin > > //EOF:=(Connection.DataIndex>Connection.DataRows); > > EOF:=giCount>10; > > // > > end; > > > > procedure TForm1.RvCustomConnection1First(Connection: > TRvCustomConnection); > > begin > > giCount:=0; > > Connection.DataIndex:=0; > > Connection.DataRows:=10; > > // > > end; > > > > procedure TForm1.RvCustomConnection1Next(Connection: TRvCustomConnection); > > begin > > giCount:=giCount 1; > > // > > end; > > > > procedure TForm1.Button1Click(Sender: TObject); > > begin > > RvProject1.Execute; > > // > > end; > > > > end. > > > > >
webber
初階會員


發表:54
回覆:76
積分:26
註冊:2004-04-20

發送簡訊給我
#6 引用回覆 回覆 發表時間:2004-08-24 11:52:55 IP:61.223.xxx.xxx 未訂閱
1. 新增一個TRvCustomConnection 元件 並實作GetCols, GetRow, EOF, First, Next等event 上一篇有sample code 2. 新增TTable 和 RvTableConnection 將RvTableConnection設定資料來源為該TTable 3. 在TTable 新增需要在RaveReport的欄位 4. 新增TRvProject,並開啟Rave Designer 新增一個connectionName為RvTableConnection的Direct DataView, 並設計報表 5.設計完報表後將dataview的connectionName 改為之前新增的RvCustomConnection 步驟2-4的作用是讓rave designer知道有那些欄位要用來設計 也許是我那裡疏忽了,所以才要繞一圈來使用RvCustomConnection 請各位多多指教
morepatric
一般會員


發表:9
回覆:17
積分:5
註冊:2003-07-21

發送簡訊給我
#7 引用回覆 回覆 發表時間:2004-09-18 19:15:27 IP:61.59.xxx.xxx 未訂閱
感謝webber! 雖然你沒有直接解決了我的問題,不過我還是間接的找到解決方法了。 一、在RaveDesign中的Report1的parameters中新增欄位名稱,如C1 二、在GetRow中再加入 RvProject1.SetParam('C1', StringGrid1.Cells[0,iRow]);
系統時間:2024-05-17 10:49:53
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!