1,用第三放控件,如用ehlib控件包中的dbgrideh来显示,结合printdbgrideh来打印。
2,把adoquery或query同报表控件(quickreport,fastreport等)相连,进行打印。
3,用代码
procedure TForm1.Button5Click(Sender: TObject);
const
XSpace=40;
YSpace=40;
var
x,y,i : integer;
begin
table1.First ;
y:=5;
printer.begin
Doc ;
with table1do
begin
x:=0;
for i:=0 to fieldcount-1do
begin
printer.Canvas.TextOut(x,y,fields.DisplayName);
x:=printer.Canvas.PenPos.x+xspace;
end;
y:=printer.Canvas.PenPos.y + YSpace;
printer.Canvas.MoveTo(0,y);
printer.Canvas.LineTo(x,y);
y:=printer.Canvas.PenPos.y+YSpace;
while not eofdo
begin
x:=0 ;
for i:=0 to fieldcount-1do
begin
printer.Canvas.TextOut(x,y,fields.DisplayText);
x:=printer.Canvas.PenPos.x+xSpace;
end;
next ;
//记录下移一条
y:=printer.Canvas.PenPos.y+ySpace;
end;
end;
printer.Canvas.MoveTo (0,y);
printer.Canvas.LineTo(x,y);
printer.EndDoc ;
end;