急用!在线等!

解决方案 »

  1.   

    用DBGRIDEH吧。
    那个还可以的。
      

  2.   

    procedure TForm26.Button1Click(Sender: TObject);
    var
       str:string;
       fdname:array[1..12] of ShortString;
       i:integer;
       strspace:pchar;
    begin
       //try
       Assignprn(prnfile);
       Rewrite(prnfile);
       for i:=0 to 2 do writeln(prnfile); //空打三行
       strspace:=' ';       //将标题前赋空格
       for i:=0 to 100 do write(prnfile,strpas(strspace));
       form13.Label1.Font.Size :=20;
       Printer.Canvas.Font :=form13.Label1.Font;// Memo1.Font;将lable1字体的大小赋给画布
       str:=form13.Label1.Caption;
       writeln(prnfile,str);
       writeln(prnfile);
       for i:=0 to form13.table1.FieldCount-4 do begin
       form13.DBGrid1.Columns.Items[i].Title.Font.Size:=14;
       Printer.Canvas.Font :=form13.DBGrid1.Columns.Items[i].Title.Font;// Memo1.Font;
       end;
       write(prnfile,'| ');
       for i:=0 to form13.table1.FieldCount-4 do
         begin
         write(prnfile,form13.table1.fields[i].fieldname);
         if i=0 then write(prnfile,' | ')
         else if i=1 then write(prnfile,' |')
         else write(prnfile,'|');
         end;
       writeln(prnfile);
       form13.DBGrid1.Font.Size:=14;
       Printer.Canvas.Font :=form13.DBGrid1.Font;
       with form13.table1 Do
       begin
       first;
        while Not EOF Do
         begin
          fdname[1]:=FieldByName('日期').AsString;
          fdname[2]:=FieldByName('时间').AsString;
          fdname[3]:=FieldByName('媒水温度').AsString;
          fdname[4]:=FieldByName('出水温度').AsString;
          fdname[5]:=FieldByName('回水温度').AsString;
          fdname[6]:=FieldByName('燃烧机').AsString;
          fdname[7]:=FieldByName('循环泵').AsString;
          fdname[8]:=FieldByName('补水阀').AsString;
          fdname[9]:=FieldByName('排烟温度').AsString;
        // fdname[10]:=FieldByName('卫热温度').AsString;
        //  fdname[11]:=FieldByName('卫热循环泵').AsString;
        //  fdname[12]:=FieldByName('给水泵').AsString;
        // Writeln(prnfile,fdname[1],fdname[2],fdname[3],fdname[4],fdname[5],fdname[6],fdname[7],fdname[8],fdname[9]);
          for i:=1 to 9 do prnstr(trim(fdname[i]),i);
          writeln(prnfile);
          next;
        end;
       end;
       System.CloseFile(prnfile);
      // except
      // On eprinter Do
      //   MessageDlg('没接打印机或打印机没有开,请连好打印机后再试', mtError,[mbOk], 0);
    end;procedure prnstr(str:String;j:integer);
    var
      //prnfile:Textfile;
      i,n,n0,m,num:integer;
      space:string;//pchar;
    begin
       space:='/';
       num:=length(str);
       n0:=(8-num) div 2;
       n:=2*n0+1;
       if (j>5) and (j<9)then n:=n-2;
       for i:=1 to n do write(prnfile,space);//strpas(space));
       write(prnfile,str);
       m:=8-num-n0;
       m:=2*m+1;
       if num<3 then m:=m-1;
       for i:=1 to m do write(prnfile,space);//strpas(space));
    end;
    end.
    以前写的,
      

  3.   

    建立一个报表,然后把adoquery的结果集和
    报表的数据集进行绑定,
    如果你使用fastreport的话有现成的控件PrintDBGridEh
    直接就可以打印了,不需要编写代码!