Z
zzz999
Unregistered / Unconfirmed
GUEST, unregistred user!
我创建分组的动态报表的得代码如下。编译和运行无错,但是没有出现分组的情况,显示的结果和不分组差不多(只是不出现组标头)。
frReport1.Pages.Clear;
frReport1.Pages.Add;
// create page
Page := frReport1.Pages[0];
frdbdataset1.DataSet:=dm.dts_salary;
b := TfrBandView.Create;
// create Title band
b.SetBounds(0, 20, 0, 79);
// position and size in pixels
b.BandType := btReportTitle;
// (only Top and Height are significant
Page.Objects.Add(b);
// for the band)
v := TfrMemoView.Create;
// create memo
v.SetBounds(20, 60, 300, 23);
v.BandAlign := baWidth;
v.Prop['Alignment'] := frtaCenter;
// another way to access properties
v.Prop['Font.size'] := 14;
v.Prop['Font.name'] := '隶书';
v.Memo.Add('公司'+inttostr(u_main.pub_year)+'年'+inttostr
(u_main.pub_month)+'月'+'工资表');
Page.Objects.Add(v);
do
cMode := dmDesigning;
b := TfrBandView.Create;
b.SetBounds(0, 100,700, 22);
b.BandType := btgroupheader;//标题表头
b.Prop['formnewpage'] := True;//要不要该行代码,效果一样
b.name:='groupheader1';
b.Prop['condition'] :='[dm.dts_salary."name"]';
//b.GroupCondition:='[]';
page.Objects.Add(b);
v:=TfrMemoView.Create;
// create memo
v.SetBounds(25, 101, 65, 15);
v.Memo.Text:='姓名';
//v.Parent.Name:='groupheader1';
v.Prop['Font.size'] := 10;
v.Prop['Font.name'] := '宋体';
Page.Objects.Add(v);
b := TfrBandView.Create;
b.SetBounds(0, 125, 700, 20);
b.BandType := btMasterData;
//主项数据
b.Dataset := 'frDBDataSet1';
page.Objects.Add(b);
i:=1;
while a_field_no<>''do
begin
v := TfrMemoView.Create;
// create memo
v.SetBounds(25+65*(i-1), 126, 65, 15);
v.Memo.Add('[dm.dts_salary.'+'"'+a_field_no+'"'+']');
v.Prop['Font.size'] := 10;
v.Prop['Font.name'] := '宋体';
Page.Objects.Add(v);
i:=i+1;
end;
frReport1.ShowReport;
frReport1.Pages.Clear;
frReport1.Pages.Add;
// create page
Page := frReport1.Pages[0];
frdbdataset1.DataSet:=dm.dts_salary;
b := TfrBandView.Create;
// create Title band
b.SetBounds(0, 20, 0, 79);
// position and size in pixels
b.BandType := btReportTitle;
// (only Top and Height are significant
Page.Objects.Add(b);
// for the band)
v := TfrMemoView.Create;
// create memo
v.SetBounds(20, 60, 300, 23);
v.BandAlign := baWidth;
v.Prop['Alignment'] := frtaCenter;
// another way to access properties
v.Prop['Font.size'] := 14;
v.Prop['Font.name'] := '隶书';
v.Memo.Add('公司'+inttostr(u_main.pub_year)+'年'+inttostr
(u_main.pub_month)+'月'+'工资表');
Page.Objects.Add(v);
do
cMode := dmDesigning;
b := TfrBandView.Create;
b.SetBounds(0, 100,700, 22);
b.BandType := btgroupheader;//标题表头
b.Prop['formnewpage'] := True;//要不要该行代码,效果一样
b.name:='groupheader1';
b.Prop['condition'] :='[dm.dts_salary."name"]';
//b.GroupCondition:='[]';
page.Objects.Add(b);
v:=TfrMemoView.Create;
// create memo
v.SetBounds(25, 101, 65, 15);
v.Memo.Text:='姓名';
//v.Parent.Name:='groupheader1';
v.Prop['Font.size'] := 10;
v.Prop['Font.name'] := '宋体';
Page.Objects.Add(v);
b := TfrBandView.Create;
b.SetBounds(0, 125, 700, 20);
b.BandType := btMasterData;
//主项数据
b.Dataset := 'frDBDataSet1';
page.Objects.Add(b);
i:=1;
while a_field_no<>''do
begin
v := TfrMemoView.Create;
// create memo
v.SetBounds(25+65*(i-1), 126, 65, 15);
v.Memo.Add('[dm.dts_salary.'+'"'+a_field_no+'"'+']');
v.Prop['Font.size'] := 10;
v.Prop['Font.name'] := '宋体';
Page.Objects.Add(v);
i:=i+1;
end;
frReport1.ShowReport;