在quickrep中,我从SQL SERVER的数据库中取字段值打印,比较长的值超过一行如何控制它换行
还有如何控制打印时,控制打印宽度和高度,程序里指定,
和如何在每一页里显示总页数

解决方案 »

  1.   

    1.我給你個函數,控制字體的,如果寬度超出,則字體自動縮小到適應大小。
    procedure GetFontSize(Var FontSize:Integer;Font:TFont;Value:String;DisplayWidth:Integer);
    var
      image1:Timage;
    begin
      image1:=Timage.Create(Nil);
      image1.Canvas.Font:=Font;
      image1.Canvas.Font.Size:=FontSize;
      While image1.Canvas.TextWidth(Value)>=DisplayWidth do begin
          If FontSize<=1 then break;
          FontSize:=FontSize-1;
          image1.Canvas.Font.Size:=FontSize;
      end;
      Font.Size:=FontSize;
      image1.free;
    end;
    然後,在要控制的qrdbtext的onprint事件中:
    procedure TForm1.QRDBText1Print(sender: TObject;
      var Value: String);
    var
      FontSize:integer;
    begin
      FontSize:=10;
      GetFontSize(FontSize,QRDBText1.Font,Value,QRDBText1.Width);
      QRDBText1.Font.Size:=FontSize;
    end;2.还有如何控制打印时,控制打印宽度和高度,程序里指定?
    一樣可以在onprint事件中控制3.
    var
    PageCount:integer;
    begin
    ......
      QuickRep1.prepare;
      PageCount:=QuickRep1.Printer.PageCount
    ......
    end;
      

  2.   

    那就試試這個:
    procedure TForm2.QRDBText1Print(sender: TObject; var Value: String);
    {begin
    autochangerow(39,value);
    end;}
    var
     bExit : boolean;
     iLen : integer;
     strSource, strTemp : string;
    begin
     if Length(Value) <= 32 then
       exit;
     strSource := Value;
     Value := '';
     while true do
     begin
       iLen := 1;
       while iLen < 32 do
       begin
         if ord(strSource[iLen]) > 128 then
           inc(iLen, 2)
         else
           inc(iLen);
       end;
       dec(iLen);
       strTemp := Copy(strSource, 1, iLen);
       if Value = '' then
       Value := strTemp
       else
         Value := Value + #13 + strTemp;
       strSource := Copy(strSource, iLen + 1, Length(strSource) - iLen);
       if Length(strSource) <= 32 then
       begin
         Value := Value + #13 + strSource;
         exit;
       end;
     end;
    end;
    其中32是寬度,可以改
      

  3.   

    不是,记不清了,就是打印text字段哪个控件
      

  4.   

    換行?俺的﹐有點亂function TfrmPrtGroupSQ.PrtString(prtCount: integer;EnterTimes:integer;var s:string): string;
    var
      i, j,k: integer;
      sLine{ 掩揭燴腔埭趼睫揹 }: string;
      sCuted{ 偌嘐隅酗僅煦賃堤懂腔窒煦趼睫揹 }: string;
      iCutLength{ 偌嘐隅酗僅煦賃堤懂腔窒煦趼睫揹腔酗僅 }: integer;
      bIsDBCS{ 岆瘁岆犖趼腔&#63325;圉趼誹 }: boolean;
      SpaceLines:string;
    begin
        SpaceLines:='';
        for k:=1 to Entertimes do
            SpaceLines:=SpaceLines+#13#10;
        sLine :=s;
        s:='';
        iCutLength:=prtCount;
        repeat 
          while (bytetype(sLine,iCutLength)<>mbTrailByte) do Dec(iCutLength);
          s:=s+Copy(sLine, 1, iCutLength)+SpaceLines;
          sLine := Copy(sLine, iCutLength + 1, Length(sLine) - iCutLength);
          iCutLength:=prtCount;
        until Length(trim(sLine)) <= 0;
    end;
      

  5.   

    suton(suton) ,你的换行方法不错,还有谁能告诉我如何控制输出纸张的高度吗
      

  6.   

    lp1983(拼),什么控件?
    比如现在用A4打印,换成A4的一半大小的纸控制打印,如何把一页A4的数据分成完整的俩页?就是一半的数据打印出来,另一半的数据自动转入下一页!
    在线等待。。
      

  7.   

    qucikrep的长度我会控制,可是复合报表QRCompositeReport不知道如何控制,还有TDeviceMode那种控制打印机我这边也没有效果
      

  8.   

    建议改用其他报表控件,如:RMF。
    你可以到它的论坛问问.
    http://www.delphireport.com.cn