用Ehlib二次开发报表打印程序,实现财务凭证的打印(三)
2006-02-04 13:38:10 来源:WEB开发网 闂傚倸鍊搁崐鎼佸磹閹间礁纾归柟闂寸绾惧綊鏌熼梻瀵割槮缁炬儳缍婇弻鐔兼⒒鐎靛壊妲紒鐐劤缂嶅﹪寮婚悢鍏尖拻閻庨潧澹婂Σ顔剧磼閻愵剙鍔ょ紓宥咃躬瀵鎮㈤崗灏栨嫽闁诲酣娼ф竟濠偽i鍓х<闁诡垎鍐f寖闂佺娅曢幑鍥灳閺冨牆绀冩い蹇庣娴滈箖鏌ㄥ┑鍡欏嚬缂併劎绮妵鍕箳鐎n亞浠鹃梺闈涙搐鐎氫即鐛崶顒夋晬婵絾瀵ч幑鍥蓟閻斿摜鐟归柛顭戝枛椤牆顪冮妶搴′簼缂侇喗鎸搁悾鐑藉础閻愬秵妫冮崺鈧い鎺戝瀹撲礁鈹戦悩鎻掝伀缁惧彞绮欓弻娑氫沪閹规劕顥濋梺閫炲苯澧伴柟铏崌閿濈偛鈹戠€n€晠鏌嶆潪鎷屽厡闁汇倕鎳愮槐鎾存媴閸撴彃鍓卞銈嗗灦閻熲晛鐣烽妷褉鍋撻敐搴℃灍闁绘挻娲橀妵鍕箛闂堟稐绨肩紓浣藉煐濮樸劎妲愰幘璇茬闁冲搫鍊婚ˇ鏉库攽椤旂》宸ユい顓炲槻閻g兘骞掗幋鏃€鐎婚梺瑙勬儗閸樺€熲叺婵犵數濮烽弫鍛婃叏椤撱垹纾婚柟鍓х帛閳锋垶銇勯幒鍡椾壕缂備礁顦遍弫濠氱嵁閸℃稒鍊烽柛婵嗗椤旀劕鈹戦悜鍥╃У闁告挻鐟︽穱濠囨嚃閳哄啰锛滈梺褰掑亰閸欏骸鈻撳⿰鍫熺厸閻忕偟纭堕崑鎾诲箛娴e憡鍊梺纭呭亹鐞涖儵鍩€椤掑啫鐨洪柡浣圭墪閳规垿鎮欓弶鎴犱桓闂佸湱枪閹芥粎鍒掗弮鍫熷仺缂佸顕抽敃鍌涚厱闁哄洢鍔岄悘鐘绘煕閹般劌浜惧┑锛勫亼閸婃牠宕濋敃鈧…鍧楀焵椤掍胶绠剧€光偓婵犱線鍋楀┑顔硷龚濞咃絿妲愰幒鎳崇喓鎷犻懠鑸垫毐闂傚倷鑳舵灙婵炲鍏樺顐ゆ嫚瀹割喖娈ㄦ繝鐢靛У绾板秹寮查幓鎺濈唵閻犺櫣灏ㄥ銉р偓瑙勬尭濡繂顫忛搹鍦<婵☆垰鎼~宥囩磽娴i鍔嶉柟绋垮暱閻g兘骞嬮敃鈧粻濠氭偣閸パ冪骇鐎规挸绉撮—鍐Χ閸℃ê闉嶇紓浣割儐閸ㄥ墎绮嬪澶嬪€锋い鎺嶇瀵灝鈹戦埥鍡楃仯闁告鍕洸濡わ絽鍟崐鍨叏濡厧浜鹃悗姘炬嫹

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而已!
- ››开发Android 日历教程
- ››开发学院总结 Win 8实用技巧大全
- ››开发学院原创教程:把win8的IE10放桌面上方法(非...
- ››开发者眼中的Windows Phone和Android
- ››开发学院教你用SQL 语句最快速清空MySQL 数据表的...
- ››开发一个自己的HTML在线编辑器(一)
- ››开发一个自己的HTML在线编辑器(二)
- ››开发者在App Store上赚的钱比在Android Market上多...
- ››开发者应深入学习的10个Android开源应用项目
- ››开发移动 Web Ajax 应用
- ››开发者眼中的iPhone与Android
- ››开发者或想使用的10个Android2.2新特性
更多精彩
赞助商链接