转至繁体中文版     | 网站首页 | 图文教程 | 资源下载 | 站长博客 | 图片素材 | 武汉seo | 武汉网站优化 | 
最新公告:     敏韬网|教学资源学习资料永久免费分享站!  [mintao  2008年9月2日]        
您现在的位置: 学习笔记 >> 图文教程 >> 软件开发 >> Delphi程序 >> 正文
用Ehlib二次开发报表打印程序,实现财务凭证的打印(三)         ★★★★

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

作者:闵涛 文章来源:闵涛的学习笔记 点击数:690 更新时间:2009/4/23 18:38:19

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而已!

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

好了,如果大家需要源码可以向我索取,yczyk@163.com

 


没有相关教程
教程录入:mintao    责任编辑:mintao 
  • 上一篇教程:

  • 下一篇教程:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
      注:本站部分文章源于互联网,版权归原作者所有!如有侵权,请原作者与本站联系,本站将立即删除! 本站文章除特别注明外均可转载,但需注明出处! [MinTao学以致用网]
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)

    同类栏目
    · C语言系列  · VB.NET程序
    · JAVA开发  · Delphi程序
    · 脚本语言
    更多内容
    热门推荐 更多内容
  • 没有教程
  • 赞助链接
    更多内容
    闵涛博文 更多关于武汉SEO的内容
    500 - 内部服务器错误。

    500 - 内部服务器错误。

    您查找的资源存在问题,因而无法显示。

    | 设为首页 |加入收藏 | 联系站长 | 友情链接 | 版权申明 | 广告服务
    MinTao学以致用网

    Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved.
    闵涛 投放广告、内容合作请Q我! E_mail:admin@mintao.net(欢迎提供学习资源)

    站长:MinTao ICP备案号:鄂ICP备11006601号-18

    闵涛站盟:医药大全-武穴网A打造BCD……
    咸宁网络警察报警平台