[转载]动态创建fastReport报表

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        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);   
    
         DocMode    :=    dmDesigning;   
         b    :=    TfrBandView.Create;   
         b.SetBounds(0,    100,    800,    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[i]<>''    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[i]+'"'+']');   
           v.Prop['Font.size']    :=    10;   
           v.Prop['Font.name']    :=    '宋体';   
           Page.Objects.Add(v);   
           i:=i+1;   
       end;   
       frReport1.ShowReport

原文地址:https://www.cnblogs.com/eastson/p/1656749.html