StringGrid的資料如何透過rvCustomConnection列印? |
尚未結案
|
morepatric
一般會員 發表:9 回覆:17 積分:5 註冊:2003-07-21 發送簡訊給我 |
|
hahalin
版主 發表:295 回覆:1698 積分:823 註冊:2002-04-14 發送簡訊給我 |
|
morepatric
一般會員 發表:9 回覆:17 積分:5 註冊:2003-07-21 發送簡訊給我 |
|
jumo
一般會員 發表:33 回覆:65 積分:24 註冊:2002-04-17 發送簡訊給我 |
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 發送簡訊給我 |
總算能用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 發送簡訊給我 |
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 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |