打印工资条

打印字段太多,用换行来处理;

1.窗体上方一个QuickRep1 ,一个TitleBand1,一个DetailBand1

2.代码

var
  iLeft,i,tleft,n : integer;
  QRShape1,QRShape2 : TQRShape;
  is_next : boolean;
begin
  if not Assigned(dbGrid1.DataSource) then Exit;
  if not Assigned(dbGrid1.DataSource.DataSet) then Exit;

//---------------------------------------------------------
  QRShape1 := TQRShape.Create(DetailBand1);//创建一个矩形 ,一个矩形方一个的工资
  with QRShape1 do
  begin
     Parent := DetailBand1;
     Left := 0;
     top := 0;
     Width := DetailBand1.Width;
     height := 50;
  end;
  DetailBand1.Height := 70;
//-----------------------
  iLeft := 6;
  tleft := 0;
  n := 0;
  is_next := false;

  for I := 0 to dbgrid1.Columns.Count-1 do
  begin
    if dbgrid1.Columns.Items[I].Visible then
    begin
      tLeft := iLeft + dbgrid1.Columns.Items[I].Width;
      if tLeft > DetailBand1.ClientWidth then
         is_next := true;
      if is_next then
      begin
          QRShape1.Height := 50 + QRShape1.Height;
          DetailBand1.Height := 50 + DetailBand1.Height;
          n := n + 40;
          iLeft := 6;
          tleft := 0;

          QRShape2 := TQRShape.Create(DetailBand1);//要换行时创建线条,作为分隔线;
          with QRShape2 do
          begin
            Parent := DetailBand1;
            Left := 0;
            top := n + 11;
            Width := DetailBand1.Width;
            height := 1;
          end;

          is_next := false;   //
      end;
        //---------------
        with TQRLabel.Create(DetailBand1) do
        begin
          Parent := DetailBand1;
          Left := iLeft;
          Width := dbgrid1.Columns.Items[I].Width;
          Caption := dbgrid1.Columns.Items[I].Title.Caption;
          Alignment := dbgrid1.Columns.Items[I].Title.Alignment;
          Top := Height + 2 + n;
        end;
        //TQRDBText--------------------
        with TQRDBText.Create(DetailBand1) do
        begin
          Parent := DetailBand1;
          Left := ileft;
          Width := dbgrid1.Columns.Items[I].Width;
          ileft := ileft + Width;
          DataSet := dbgrid1.DataSource.DataSet;
          DataField := dbgrid1.Columns.Items[i].FieldName;
          Alignment := dbgrid1.Columns.Items[I].Title.Alignment;
          Top := Height + 20 + n;
        end;
    end
    else continue;
  end;

     { QRCompositeReport2.Prepare;
      QRCompositeReport2.Preview; }

  QuickRep1.Preview;

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值