用Ehlib二次开发报表打印程序,实现财务凭证的打印(三) (转)

用Ehlib二次开发报表打印程序,实现财务凭证的打印(三) (转)[@more@]

4、打印表头,我将表头的各个部分划成了几部分,如我的凭证打印的地方,我就划成了五部分,每部分按占百分比多少计算。如编制单位就占页面宽度的40%等

procedure TF_printpreview.printpageheader(pageheader: Tstrings);
var
  Headrect:Trect;
  count:integer;
begin
  pp_pz.Printer.Canvas.Font.Name:='宋体';
  pp_pz.Printer.Canvas.Font.Color:=clblack;
  pp_pz.Printer.Canvas.Font.Size:=9;
  pp_pz.Printer.Canvas.Font.Style:=[];
  gettextinfo;
  Amountprint:=Amountprint+round(0.8*textheight);//当前逻辑尺的位置
  for  count:=0 to pageheader.Count-1 do
  begin
  case count of
  0:
  HeadRect:=Rect(round(pp_pz.Printer.PageSet.LeftMargin),Amountprint,round(pp_pz.Printer.PageSet.LeftMargin+round(0.4*(pp_pz.Printer.PageWidth))),Amountprint+textheight);//编制单位比例
  1:
  HeadRect:=Rect(headrect.Right,Amountprint,headrect.Right+round(0.16*(pp_pz.Printer.PageWidth)),Amountprint+textheight);//凭证日期比例
  2:
  HeadRect:=Rect(headrect.Right,Amountprint,headrect.Right+round(0.14*(pp_pz.Printer.PageWidth)),Amountprint+textheight);//帐套号比例
  3:
  HeadRect:=Rect(headrect.Right,Amountprint,headrect.Right+round(0.2*(pp_pz.Printer.PageWidth)),Amountprint+textheight);//凭证号比例
  4:
  HeadRect:=Rect(headrect.Right,Amountprint,headrect.Right+round(0.1*(pp_pz.Printer.PageWidth)),Amountprint+textheight);//分页数号比例
  end;
  pp_pz.Printer.Canvas.TextOut(Headrect.left,headrect.top,pageheader[count]);
  end;
end;

5、打印表格头

procedure TF_mxzprint.printdetailheader(detailheader: Tstrings);
var
  drect,srect,jrect:Trect;
begin
  pp_pz.Printer.Canvas.Font.Name:='宋体';
  pp_pz.Printer.Canvas.Font.Color:=clblack;
  pp_pz.Printer.Canvas.Font.Size:=9;
  pp_pz.Printer.Canvas.Font.Style:=[];
  gettextinfo;
  Amountprint:=Amountprint+textheight;
  pp_pz.Printer.Canvas.Font.Size:=11;
  drect:=rect(PageRect.Left,Amountprint,PageRect.Left+round(0.3*(PageRect.Right-PageRect.Left)),Amountprint+2*textheight);
  drawtext(pp_pz.Printer.Canvas.handle,pchar('摘  要'),length('摘  要'),drect,DT_center or  DT_WORdbREAK or DT_VCENTER or DT_SINGLELINE);
  addpolyline([drect.left,drect.top,drect.right,drect.top,drect.right,drect.bottom,drect.left,drect.bottom,drect.left,drect.top]);

  drect:=rect(drect.right,drect.Top,drect.right+round(0.4*(PageRect.Right-PageRect.Left)),srect.Bottom);
  drawtext(pp_pz.Printer.Canvas.handle,pchar('科目名称'),length('科目名称'),drect,DT_center or  DT_wordBREAK or DT_VCENTER or DT_SINGLELINE);
  addpolyline([drect.left,drect.top,drect.right,drect.top,drect.right,drect.bottom,drect.left,drect.bottom,drect.left,drect.top]);
  drect:=rect(drect.right,drect.Top,drect.right+round(0.15*(PageRect.Right-PageRect.Left)),srect.Bottom);
  drawtext(pp_pz.Printer.Canvas.handle,pchar('借方金额'),length('借方金额'),drect,DT_center or  DT_WORDBREAK or DT_VCENTER or DT_SINGLELINE);

  addpolyline([drect.left,drect.top,drect.right,drect.top,drect.right,drect.bottom,drect.left,drect.bottom]);
  drect:=rect(drect.right,drect.Top,drect.right+round(0.15*(PageRect.Right-PageRect.Left)),srect.Bottom);
  addpolyline([drect.left,drect.top,drect.right,drect.top,drect.right,drect.bottom,drect.left,drect.bottom,drect.left,drect.top]);
  drawtext(pp_pz.Printer.Canvas.handle,pchar('贷方金额'),length('贷方金额'),drect,DT_center or  DT_WORDBREAK or DT_VCENTER or DT_SINGLELINE);

  addpolyline([drect.left,drect.top,drect.right,drect.top,drect.right,drect.bottom,drect.left,drect.bottom]);
  Amountprint:=amountprint+drect.Bottom-drect.Top;//+textheight;
end;

5、打印表格内容

(与上面相似,代码太多,略。。。)

6、打印汇总栏内容(代码较多,而且也相似,略)

7、执行打印功能

  pp_pz.Printer.BeginDoc;
  依次打印标题、打印、表头等

 PolyPolyline(pp_pz.Printer.Canvas.Handle,PolyPolyPoints.List^,PolyLengths.List^,PolyLengths.Count);  pp_pz.Printer.EndDoc;

 

关键:就两个函数PolyPolyline和DrawText而已!

请注意,我这是连载,我发现我最后一贴看的人比较多,可光看这篇基本上看不出什么来的。管理员没有发表我的第一篇,我现在把第一篇放到了连(二)里面去了,所以大家不要找连载(一)了!由于时间比较忙,所以有一部分朋友要求要源码还没来的及整理,但我一整理出来我就会发过去的,谢谢大家!

好了,如果大家需要源码可以向我索取,Mailto:yczyk@163.com" rel="nofollow">yczyk@163.com

 


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10752043/viewspace-993016/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/10752043/viewspace-993016/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值