fastreport如何动态创建报表(100)

  • 主题发起人 主题发起人 帅成负担
  • 开始时间 开始时间

帅成负担

Unregistered / Unconfirmed
GUEST, unregistred user!
我目前使用Dephi7+Fastreport是用Fastreport自带的design实现的,觉得这种办法 很不妥,对用户来说有点复杂,而且界面不规范。有撒办法让用户根据我提供的数据库字段来设置格式不同的报表?并且也能保存下来
 
HEHE,DEMO中有自动创建报表的示例
 
demo里面哪个文件目录是呀?我怎么没发现?
 
大侠救命啊
 
procedure TFrmdayreport.createreport(dataset:Tdataset;sumdate:Tdatetime);var v: TfrView; b: TfrBandView; Page: TfrPage; fieldcount:integer; datamemo:string;begin //frReport1.Clear; //frReport1.Pages.Free; //if frReport1.Pages.Count>0 then // showmessage('报表生成前没有清除。') // else // showmessage('报表生成前已清除'); if frReport1.Pages=Nil then begin frReport1.Pages.Create(frReport1); end; frReport1.Pages.Add; // create page Page := frReport1.Pages[0]; page.pgMargins.Top:=36; b := TfrBandView(frCreateObject(gtBand, '')); // create ReportHeader band b.SetBounds(0,36,757,76); b.BandType := btpageheader; Page.Objects.Add(b); v := TfrMemoView.Create; // create memo v.SetBounds(216,48, 304, 32); v.BandAlign := baWidth; v.Prop['Alignment'] := frtaCenter; // another way to access properties v.Prop['Font.Style'] := 2; v.Prop['Font.Name']:='宋体'; v.Prop['Font.Size']:=16; v.Memo.Add('上岛咖啡营业明细日报表'); Page.Objects.Add(v); v := TfrMemoView.Create; // create memo v.SetBounds(452,88,260,20); //v.BandAlign := baWidth; //v.Prop['Alignment'] := frtaRight; // another way to access properties v.Prop['Font.Style'] := 2; v.Prop['Font.Name']:='宋体'; v.Prop['Font.Size']:=10; v.Memo.Add('统计日期:'+datetostr(sumdate)); Page.Objects.Add(v); b := TfrBandView(frCreateObject(gtBand, '')); // create MasterHeader band b.SetBounds(0,112,757,36); b.BandType := btMasterheader; Page.Objects.Add(b); for Fieldcount:=0 to DataSet.FieldCount-1 do //create masterheadermemo begin v := TfrMemoView.Create; v.SetBounds(64+(Fieldcount*96),128, 96, 20); v.Prop['Alignment'] :=frtaMiddle+frtaCenter; v.Prop['Font.Style'] := 2; v.Prop['Font.Name']:='宋体'; v.Prop['Font.Size']:=10; v.Prop['FrameTyp']:=15; v.Memo.Add(DataSet.Fields[Fieldcount].FieldName); Page.Objects.Add(v); end; b := TfrBandView(frCreateObject(gtBand, '')); // create MasterData band b.SetBounds(0,158,757, 20); b.BandType := btMasterData; b.Dataset := 'frDBDataSet1'; // band's dataset Page.Objects.Add(b); for Fieldcount:=0 to DataSet.FieldCount-1 do //create MasterDataMemo begin v := TfrMemoView.Create; v.SetBounds(64+(Fieldcount*96),158,96, 20); v.Prop['Alignment'] :=frtaMiddle+frtaCenter; v.Prop['Font.Style'] := 1; v.Prop['Font.Name']:='宋体'; v.Prop['Font.Size']:=10; v.Prop['FrameTyp']:=15; if DataSet.Fields[Fieldcount].DataType in [ftFloat, ftCurrency, ftBCD] then begin datamemo:='['+dataset.Name+'.'+DataSet.Fields[Fieldcount].FieldName+' #9.2]'; end else datamemo:='['+dataset.Name+'.'+DataSet.Fields[Fieldcount].FieldName+']'; v.Memo.Add(datamemo); Page.Objects.Add(v); end; b := TfrBandView(frCreateObject(gtBand, '')); // create Reportfooter band b.SetBounds(0,256,757,34); b.BandType := btpagefooter; Page.Objects.Add(b); v := TfrMemoView.Create; // create memo v.SetBounds(330,256,96,20); v.BandAlign := baWidth; v.Prop['Alignment'] := frtaCenter; // another way to access properties v.Prop['Font.Style'] := 2; v.Prop['Font.Name']:='宋体'; v.Prop['Font.Size']:=10; v.Memo.Add('[page#]'); Page.Objects.Add(v); frReport1.PrepareReport; //frReport1.ShowReport; frReport1.ShowPreparedReport; //frReport1.EMFPages.Free; //frReport1.Pages.Free; frReport1.Pages.Clear; //frReport1.Preview.Free; // if frReport1.Pages.Count>0 then // showmessage('报表没有清除。') // else // showmessage('报表已清除');
 
能做一个模仿fastreport设计器里面的那个交叉报表的界面,让用户自己随意拉动字段到排和列,如果生成需要的报表吗?
 

Similar threads

D
回复
0
查看
2K
DelphiTeacher的专栏
D
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
后退
顶部