在打印或打印预览前如何获取报表页数

来源:互联网 发布:小手点击水波纹效果js 编辑:程序博客网 时间:2024/05/17 21:34
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
我们有时需要在打印前获取报表的打印页数, 比如我们需要在页眉或页脚中打印“共 xx 页 第 xx 页”,那如何实现呢? QuickRep生成Report之前,我们是无法得知报表页数的,而QuickReport是在打印或打印预览时才生成报表,换言之我们只有在 打印或打印预览前先将报表生成一次才能获取打印页数.生成报表的方法是 Prepare。参考以下的例子: 
... 
var nPageCount:integer; 
begin 
  {...} 
   QuickRep1.Prepare; 
   nPageCount:=QuickRep1.QRPrinter.PageCount; 
   QuickRep1.QRPrinter.Free; 
   QuickRep1.QRPrinter:=nil; 
   {在此修改QuickRep1,实现在页眉或页脚中打印“共 xx 页 第 xx 页” ... } 
   QuickRep1.PreView; 
   {...} 
End; 

<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>