StringGrid打印报表(FastReport)

时间:2012-11-23 16:07:11
【文件属性】:

文件名称:StringGrid打印报表(FastReport)

文件大小:2KB

文件格式:RAR

更新时间:2012-11-23 16:07:11

StringGrid

StringGrid打印报表(FastReport) {*************StringGrid打印功能***********************************} (*uses unit: FR_Class, FR_View from (fast-Report) *) (*参数说明:printRow:每页打印的行数 *) (* styleType:边框类型 0:无边框,15:所有边框,18:底部画线 *) (* title:标题 *) (* FrmGrid:所在窗体 *) (*date:2005-04-24 *) (*author:kxy *) {******************************************************************} function GridPrint (Grid1:TstringGrid;printRow,StyleType:integer;Title:string;FrmGrid:TForm):boolean;//打印报 表 var fr: TfrReport; ReportTitle,Masterdata,ColumnHeader,PageHeader,pageFooter:Tfrbandview; //栏目 MemoVT,MemoVC:Array of TfrMemoview; //列 TitleV ,dateV,pageV:TfrMemoview ; lineV:TfrlineView; //线 page:Tfrpage; //页 GridRow,GridCol,CurrRow,I,J,col:integer;//总的行数,列数,当前行 PageCount,pageRow:integer; //总共页数; Left,Top,Width,Heigth:integer; TempLeft,TempWidth:integer; printDate :string; begin screen.Cursor := crHourGlass; GridRow := Grid1.RowCount; GridCol := Grid1.ColCount; CurrRow := 0; pageRow := printRow; try fr := TfrReport.Create(FrmGrid); fr.StoreInDFM := True; PageCount := GridRow div printRow ; //计算出页数 for I := 0 to PageCount - 1 do begin left :=0; top :=20; width :=757; heigth :=25; fr.Pages.Add; page := fr.Pages[i]; if I = 0 then //第一页增加标题; begin {标题栏} ReportTitle := Tfrbandview.Create; ReportTitle.BandType := btReportTitle; ReportTitle.SetBounds(left,top,width,40); page.Objects.Add(ReportTitle); TitleV := TfrMemoview.Create; Titlev.SetBounds(0,top,width,30); Titlev.Alignment := (Titlev.Alignment and $FC) + 2;//居中 Titlev.Font.Name := '宋体'; TitleV.Font.Size := 16; TitleV.Memo.Add(title); page.Objects.Add(TitleV); {打印日期} dateV := TfrMemoview.Create; dateV.SetBounds(0,top + 40,width,30); dateV.Alignment := (dateV.Alignment and $FC) + 1 ;//右对齐 dateV.Font.Name := '宋体'; dateV.Font.Size := 9; printDate :='打印日期:' + FormatDateTime('yyyy/mm/dd',Now) +' '; dateV.Memo.Add(printDate); page.Objects.Add(dateV); PageRow := PageRow - 4 ; //少打两行组成一个标题 Top := 60; end ELSE begin pageRow := PrintRow; Top := 20; end; for J:= 0 to PageRow + 1 do //每页的行数 begin {列头} IF J = 0 then //第一行打行列标题栏 begin ColumnHeader := Tfrbandview.Create; ColumnHeader.BandType := btColumnHeader; ColumnHeader.SetBounds(left,top,width,heigth); page.Objects.Add(ColumnHeader); SetLength(MemoVT,GridCol); TempLeft := 20; for col:= 0 to GridCol - 1 do begin MemoVt[col] := TfrMemoview.Create; MemoVt[col].Font.Name := Grid1.Font.Name; MemoVt[col].Font.Size := Grid1.Font.Size; MemoVt[col].Memo.Add(Grid1.Cells[col,0]); MemoVt[col].FrameTyp := StyleType; //显示边框 TempWidth := Grid1.ColWidths[col]; //宽度与Grid中的宽度一致 MemoVt[col].SetBounds(tempLeft,top ,tempWidth,heigth); templeft := tempLeft + tempwidth; page.Objects.Add(MemoVt[col]) end; end Else begin top := top + heigth; Inc(CurrRow); TempLeft := 20; SetLength(MemoVc,GridCol); for col :=0 to GridCol - 1 do begin MemoVc[col] := TfrMemoview.Create; MemoVc[col].Font.Name := Grid1.Font.Name; MemoVc[col].Font.Size := Grid1.Font.Size; MemoVc[col].Memo.Add(Grid1.Cells[col,CurrRow]); MemoVc[col].FrameTyp := StyleType; //显示边框 TempWidth := Grid1.ColWidths[col]; //宽度与Grid中的宽度一致 MemoVc[col].SetBounds(tempLeft,top ,tempWidth,heigth); templeft := tempLeft + tempwidth; page.Objects.Add(MemoVc[col]); end; end; if currRow >= GridRow then break; end; {页码} pageV := TfrMemoview.Create; pageV.Font.Name := '宋体'; pagev.Font.Size := 10; pagev.FrameWidth := 2; //pagev.FrameTyp := 24 ; pagev.Alignment := (pagev.Alignment and $FC) + 2;//居中 pageV.Memo.Add('第'+ inttostr(I + 1) + '页 (共' + inttostr(PageCount) + '页)' ); pagev.SetBounds(0,1025,750,20); page.Objects.Add(pageV); end; fr.ShowReport; screen.Cursor := crDefault; finally fr.Free; end; end;


【文件预览】:
StringGrid打印报表(FastReport) .txt

网友评论

  • 只是个txt文件,安装里面的代码,无法成功