我的成品描述内容有些有十行(这里不是记录,是指一字段文本内容),有些才一行, 打印时行高如设高点,因有些才一行那么少,所以浪费纸,也不好看,设小点有些打不下. 如何根据实际大小控制行高.. 我现在在转入EXCEL,因EXCEL里有功能可设自动调行高. 但转入太慢,所以我想用DELPHI或其它报表.

解决方案 »

  1.   

    procedure TFormOrgBudgetReport.DetailBand1BeforePrint(
      Sender: TQRCustomBand; var PrintBand: Boolean);
    var
      lHeight: integer;
      lStr: string;
    begin
      lHeight := 0;
      lStr := TrimRight(str2wstr(QuickRepOrgBudget.DataSet.FieldByName('EmployeeNameAs').AsString));
      if QuickRepOrgBudget.TextWidth(QRExprNameAs.Font, lStr) mod QRExprNameAs.Width > 0 then
      begin
        if QuickRepOrgBudget.TextWidth(QRExprNameAs.Font, lStr) < QRExprNameAs.Width then
          lHeight := 1
        else
          lHeight := QuickRepOrgBudget.TextWidth(QRExprNameAs.Font, lStr) div QRExprNameAs.Width + 1;
      end;
     
      Sender.Height := Sender.Height * lHeight + 5;
    end;//你自己再改改就行啦。lHeight就是行数。