fastReport在已有的Band上动态增加Memo;列数太多,一页打印不开,自动打印到下一页 ( 积分: 200 )

  • 主题发起人 主题发起人 Shd
  • 开始时间 开始时间
S

Shd

Unregistered / Unconfirmed
GUEST, unregistred user!
在使用FastRepor过程中碰到如下难题,请各位指教。
1.在已有的报表Band上再动态增加Memo,也就是说列数不定的报表如何做出来。
2.当列数过多,一页打不开时,如何打到另一页,而不是超出纸张范围的就不打了。
 
在使用FastRepor过程中碰到如下难题,请各位指教。
1.在已有的报表Band上再动态增加Memo,也就是说列数不定的报表如何做出来。
2.当列数过多,一页打不开时,如何打到另一页,而不是超出纸张范围的就不打了。
 
第一个问题已经解决,请各位回答第二个问题。
为了方便后来人,我先把第一个问题的答案写出来。
其实很简单,在ProgrammerManual-en.pdf里就有方法,只要注意几个问题:
1.由parent创建。
2.设置left、top、height、width属性,因为你creat出来默认的这四个属性是0
下面是我的代码先打开一个基本报表,再动态添加列。
var
ss: TfrxMemoView;
begin
frxReport1.Clear;
frxReport1.LoadFromFile('NewA4.fr3');
ss := TfrxMemoView.Create(frxReport1.FindObject('PageHeader1'));
SS.Name := 'memo123';
//SS.Parent := frxReport1.FindObject('PageHeader1');
ss.Text := 'dssdsds';
SS.Width := 60;
SS.Height := 16;
ss.Top := frxReport1.FindObject('Memo2').Top;
ss.Left := frxReport1.FindObject('Memo2').Left+frxReport1.FindObject('Memo2').Width+10;
end;
 
这是ProgrammerManual-en.pdf里的原文,还是要看帮助啊!!
Creating a report form from code
As a rule, you will create most reports using the designer. Nevertheless, in some
cases (for example, when the report’s form is unknown) it is necessary to create a report
manually, from code.
To create a report manually, one should perform the following steps in order:
- clear the report component
- add data sources
- add report’s page
- add bands on a page
- set bands’ properties, and then
connect them to the data
- add objects on each band
- set objects’ properties, and then
connect them to the data
Let us examine creation of a simple report of the «list»
type. Assume that we have
the following components: frxReport1: TfrxReport and frxDBDataSet1: TfrxDBDataSet
(the last one is connected to data from the DBDEMOS, the «Customer.db»
table). Our
report will contain one page with the «Report Title»
and «Master Data»
bands. On the
«Report Title»
band there will be an object with the "Hello FastReport!"
text, and the
«Master Data»
one will contain an object with a link to the "CustNo"
field.
var
Page: TfrxReportPage;
Band: TfrxBand;
DataBand: TfrxMasterData;
Memo: TfrxMemoView;
{ clear a report }
frxReport1.Clear;
{ add a dataset to the list of ones accessible for a report }
frxReport1.DataSets.Add(frxDBDataSet1);
{ add a page }
Page := TfrxReportPage.Create(frxReport1);
{ create a unique name }
Page.CreateUniqueName;
{ set sizes of fields, paper and orientation by default }
Page.SetDefaults;
{ modify paper’s orientation }
Page.Orientation := poLandscape;
{ add a report title band}
Band := TfrxReportTitle.Create(Page);
Band.CreateUniqueName;
{ it is sufficient to set the «Top»
coordinate and height for a band }
{ both coordinates are in pixels }
Band.Top := 0;
Band.Height := 20;
{ add an object to the report title band }
Memo := TfrxMemoView.Create(Band);
Memo.CreateUniqueName;
Memo.Text := 'Hello FastReport!';
Memo.Height := 20;
{ this object will be stretched according to band’s width }
Memo.Align := baWidth;
{ add the masterdata band }
DataBand := TfrxMasterData.Create(Page);
DataBand.CreateUniqueName;
DataBand.DataSet := frxDBDataSet1;
{ the Top coordinate should be greater than the previously added band’s
top + height}
DataBand.Top := 100;
DataBand.Height := 20;
{ add an object on master data }
Memo := TfrxMemoView.Create(DataBand);
Memo.CreateUniqueName;
{ connect to data }
Memo.DataSet := frxDBDataSet1;
Memo.DataField := 'CustNo';
Memo.SetBounds(0, 0, 100, 20);
{ adjust the text to the right object’s margin }
Memo.HAlign := haRight;
{ show the report }
frxReport1.ShowReport;
 
后退
顶部