H
hefeng
Unregistered / Unconfirmed
GUEST, unregistred user!
function TDMGrade.LyqPrintStringGrid(frmMain: TForm;
sgdSchedule: TStringGrid; aTitle: String; bPreview: Boolean): Boolean;
var
i,j: Integer;
qrpPrint: TQuickRep;
aCell: TQRLabel;
aBand: TQRCustomBand;
localLeft: Integer;
aFieldTitle:TQRLabel;
begin
qrpPrint:=TQuickRep.Create(frmMain);
qrpPrint.PrintIfEmpty := True;
qrpPrint.Font.Name:='宋体';
qrpPrint.Font.Size:=12;
qrpPrint.Bands.HasColumnHeader:=True;
qrpPrint.Bands.HasTitle := True;
qrpPrint.Bands.HasDetail := True;
qrpPrint.Zoom:=60;
aBand := qrpPrint.Bands.DetailBand;
for i:=0 to sgdSchedule.RowCount-1 do
begin
aBand.HasChild := True;
aBand.Height:=sgdSchedule.RowHeights+1;
localLeft:=0;
for j:=0 to sgdSchedule.ColCount-1 do
begin
aCell:=TQRLabel.Create(aBand);
aCell.Parent:=aBand;
aCell.Caption:= sgdSchedule.Cells[j,i];
aCell.Height:=aBand.Height;
aCell.Alignment:=taLeftJustify;
aCell.AutoSize:=False;
aCell.Left:=localLeft;
aCell.Width:=sgdSchedule.ColWidths[j];
if j=0 then
begin
aCell.Frame.DrawLeft:=True;
LocalLeft:=LocalLeft+Round(1/qrpPrint.Zoom/100);
end
else aCell.Frame.DrawLeft:=False;
aCell.Frame.DrawBottom:=True;
aCell.Frame.DrawRight:=True;
LocalLeft:=LocalLeft+aCell.Width;
if j=0 then LocalLeft:=LocalLeft+1;
end;
aBand := aBand.ChildBand;
end;
aFieldTitle:=TQRLabel.Create(frmMain);
aFieldTitle.Parent:=qrpPrint.Bands.TitleBand;
aFieldTitle.Caption:=aTitle;
aFieldTitle.Frame.DrawBottom:=True;
aFieldTitle.AutoSize:=False;
aFieldTitle.AlignToBand:=False;
aFieldTitle.Left:= 1;
aFieldTitle.Height:= qrpPrint.Bands.TitleBand.Height;
aFieldTitle.Width := LocalLeft-1;
aFieldTitle.Alignment:=taCenter;
aFieldTitle.Top := 0;
aFieldTitle.Font.Name := '宋体';
aFieldTitle.Font.Size := 24;
if bPreView then
qrpPrint.Preview
else qrpPrint.Print;
end;
这是一个直接打印 StringGrid 的函数! 在StringGrid的内容较少时可以,但当 StringGrid 中的内容
超过一页就不能换页了,我不知道怎么做了,那位大侠帮改一下!!
或者有好的给一个!!!!
谢谢!!! mr-he@163.com
sgdSchedule: TStringGrid; aTitle: String; bPreview: Boolean): Boolean;
var
i,j: Integer;
qrpPrint: TQuickRep;
aCell: TQRLabel;
aBand: TQRCustomBand;
localLeft: Integer;
aFieldTitle:TQRLabel;
begin
qrpPrint:=TQuickRep.Create(frmMain);
qrpPrint.PrintIfEmpty := True;
qrpPrint.Font.Name:='宋体';
qrpPrint.Font.Size:=12;
qrpPrint.Bands.HasColumnHeader:=True;
qrpPrint.Bands.HasTitle := True;
qrpPrint.Bands.HasDetail := True;
qrpPrint.Zoom:=60;
aBand := qrpPrint.Bands.DetailBand;
for i:=0 to sgdSchedule.RowCount-1 do
begin
aBand.HasChild := True;
aBand.Height:=sgdSchedule.RowHeights+1;
localLeft:=0;
for j:=0 to sgdSchedule.ColCount-1 do
begin
aCell:=TQRLabel.Create(aBand);
aCell.Parent:=aBand;
aCell.Caption:= sgdSchedule.Cells[j,i];
aCell.Height:=aBand.Height;
aCell.Alignment:=taLeftJustify;
aCell.AutoSize:=False;
aCell.Left:=localLeft;
aCell.Width:=sgdSchedule.ColWidths[j];
if j=0 then
begin
aCell.Frame.DrawLeft:=True;
LocalLeft:=LocalLeft+Round(1/qrpPrint.Zoom/100);
end
else aCell.Frame.DrawLeft:=False;
aCell.Frame.DrawBottom:=True;
aCell.Frame.DrawRight:=True;
LocalLeft:=LocalLeft+aCell.Width;
if j=0 then LocalLeft:=LocalLeft+1;
end;
aBand := aBand.ChildBand;
end;
aFieldTitle:=TQRLabel.Create(frmMain);
aFieldTitle.Parent:=qrpPrint.Bands.TitleBand;
aFieldTitle.Caption:=aTitle;
aFieldTitle.Frame.DrawBottom:=True;
aFieldTitle.AutoSize:=False;
aFieldTitle.AlignToBand:=False;
aFieldTitle.Left:= 1;
aFieldTitle.Height:= qrpPrint.Bands.TitleBand.Height;
aFieldTitle.Width := LocalLeft-1;
aFieldTitle.Alignment:=taCenter;
aFieldTitle.Top := 0;
aFieldTitle.Font.Name := '宋体';
aFieldTitle.Font.Size := 24;
if bPreView then
qrpPrint.Preview
else qrpPrint.Print;
end;
这是一个直接打印 StringGrid 的函数! 在StringGrid的内容较少时可以,但当 StringGrid 中的内容
超过一页就不能换页了,我不知道怎么做了,那位大侠帮改一下!!
或者有好的给一个!!!!
谢谢!!! mr-he@163.com