//如你用的是QuickReport,那么
//用TQRExpr(比如是QRExpr2),然后在相应的OnPrint事件中写:
procedure TQR_Plan_list.QRExpr2Print(sender: TObject; var Value: String);
var
  s: widestring;
  s1: string;
  i,j: integer;
begin
  s := value;  //下面判断s是否大于60个字节 
  if length(s)>30 then     
  begin
    for i := 30 to 60 do
    begin
      s1 := copy(s,1,i);      if (58-length(s1))<=0 then
      begin
        j := i;
        break;
      end;
    end;
    
    //换行
    s := copy(s,1,j)+#13+Trim(copy(s,j+1,120));    value := s;
  end;
end;
//注意,该处理中s最多只有两行。

解决方案 »

  1.   

    var
        iPos :integer;  
        sTmp :string;   
        iMaxLen,iStrWidth :integer; 
    begin
        if ((value='0') or (value='.00') or (value='.0') or (value='00')) then
        begin
            value:='';
            exit;
        end;    dc := GetDC(0 ) ;
        iCount := length(value);
        sStrPrint := value;
        iStrWidth := (Sender as TQRExpr).Width ;
        sTmp := value;
        try
            try
                ZeroMemory(@size,0);   
                if GetTextExtentPoint(dc,pchar(sStrPrint),icount,size) then   
                begin
                    iMaxLen := Round(( iCount * iStrWidth ) / size.cx );  //最多能显示的字符数
                    if icount > iMaxLen then
                    begin
                        iPos := Pos('.',value);
                        if iPos > 0 then   //有小数点
                           begin
                               if iPos > iMaxLen+1 then //modify by czf 0725  //当整数部分字符数大于最大字符数时,整数部分也要分割
                                  begin
                                      value := copy(value,1,iMaxLen)+#13+copy(value,iMaxLen+1,length(value)-iMaxLen);
                                  end
                               else
                                  begin
                                      value := copy(value,1,ipos-1)+#13+copy(value,ipos,length(value)-ipos+1);
                                  end;
                           end
                        else               //无小数点
                           begin
                               value := copy(value,1,iMaxLen)+#13+copy(value,iMaxLen+1,length(value)-iMaxLen);
                           end;
                    end;
                end;
            except
            end;    
        finally
            ReleaseDC(0,dc);
        end;
    length()得出的好象是字符数,不是字节数。可以试试这个,刚做出来的。