博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

FastReport.net实现每行打印相应笔数据

Posted on 2011-12-20 08:56  gczhao  阅读(1579)  评论(0编辑  收藏  举报

本文转自:http://www.cnblogs.com/msdn/archive/2009/06/26/1511764.html

 

公司在FastReport的.net版出来不久就让我们学习,因为公司的软件要求使用这个工具,其中有一些程式要求在数据区按每行N笔数据显示,自己不会啊,就问那些高手,得到的结论是FastReport本事实现不了,当时也就这么认为了,因为人家高手嘛。所以,凡遇到有相关类似要求的程式,只能在cs代码中作为一个字段来处理了哦,拼接字符串,中间在回车换行呗。

      今天好不容易空闲下来,心里面想想看能不能实现,所以就开始做了,呵呵,终于被我实现了哦,代码或许简单了哦,但自己也算是无中生有,比较开心的说。

  1、首先从工具栏中拉一个Table控件,把需要显示的数据放在相应的单元格中,设定Table1控件属性LayOut为Wrapped。

2、生成事件

 

 

 

Code
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Forms;
using System.Drawing;
using System.Data;
using FastReport;
using FastReport.Data;
using FastReport.Dialog;
using FastReport.Barcode;
using FastReport.Table;
using FastReport.Utils;

namespace FastReport
{
  
public class ReportScript
  
{
    
private void Table1_BeforePrint(object sender, EventArgs e)
    
{
       
      
// get the data source by its name
      DataSourceBase columnData = Report.GetDataSource("Employees");
      
// init the data source
      columnData.Init();
         
      
while (columnData.HasMoreRows)
      
{
      
        
if(( columnData.CurrentRowNo)%2==0)
        
{
          Table1.PageBreak();
        }
  
        
// print the table body  
        Table1.PrintColumn(0);
        Table1.PrintRows();
       
       
        
// go next data source row
        columnData.Next();
      }

      
    }
 
 
  }

}