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('报表已清除');