Here is how to print a TStringGrid....
procedure PrintGrid(GridToPrint: TSRingGrid; PageTitle: sRing);
var
PosX1, PosX2: Integer;
PosY1, PosY2: Integer;
I: Integer;
F: Integer;
R: Rect;
begin
Printer.Title := PageTitle;
Printer.BeginDoc;
Printer.Canvas.Pen.Color := 0;
Printer.Canvas.Font.Name := 'Arial';
Printer.Canvas.Font.Size := 12;
Printer.Ccnvas.Font.Style := [fsBold, fsUnderline];
Printer.Canvas.TextOut(0, 100, Printer.Title);
for F := 1 to GridToPrint.ColCount - 1 do
begin
PosX1 := 0;
for I := 1 to (F - 1) do
PosX1 := PosX1 + 5 * (GridToPrint.ColWidths[I]);
PosY1 := 300;
PosX2 := 0;
for I := 1 to F do
PosX2 := PosX2 + 5 * (GridToPrint.ColWidths[I]);
PosY2 := 450;
R := Rect(PosX1, PosY1, PosX2 - 30, PosY2);
Printer.Canvas.Font.Style := [fsBold];
Printer.Canvas.Font.Size := 7;
Printer.Canvas.TexRect(R, PosX1 + 50, 350, GridToPrint.Cells[F, 0]);
Printer.Canvas.Font.Style := [];
for I := 1 to GridToPrint.RowCount - 1 do
begin
PosY1 := 150 * I + 300;
PosY2 := 150 * (I + 1) + 300;
R := Rect(PosX1, PosY1, PosX2 - 30, PosY2);
Printer.Canvas.TexRect(R, PosX1 + 50, PosY1 + 50, GridToPrint.Cells[F, I]);
end;
end;
Printer.EndDoc;
end;
procedure PrintGrid(GridToPrint: TSRingGrid; PageTitle: sRing);
var
PosX1, PosX2: Integer;
PosY1, PosY2: Integer;
I: Integer;
F: Integer;
R: Rect;
begin
Printer.Title := PageTitle;
Printer.BeginDoc;
Printer.Canvas.Pen.Color := 0;
Printer.Canvas.Font.Name := 'Arial';
Printer.Canvas.Font.Size := 12;
Printer.Ccnvas.Font.Style := [fsBold, fsUnderline];
Printer.Canvas.TextOut(0, 100, Printer.Title);
for F := 1 to GridToPrint.ColCount - 1 do
begin
PosX1 := 0;
for I := 1 to (F - 1) do
PosX1 := PosX1 + 5 * (GridToPrint.ColWidths[I]);
PosY1 := 300;
PosX2 := 0;
for I := 1 to F do
PosX2 := PosX2 + 5 * (GridToPrint.ColWidths[I]);
PosY2 := 450;
R := Rect(PosX1, PosY1, PosX2 - 30, PosY2);
Printer.Canvas.Font.Style := [fsBold];
Printer.Canvas.Font.Size := 7;
Printer.Canvas.TexRect(R, PosX1 + 50, 350, GridToPrint.Cells[F, 0]);
Printer.Canvas.Font.Style := [];
for I := 1 to GridToPrint.RowCount - 1 do
begin
PosY1 := 150 * I + 300;
PosY2 := 150 * (I + 1) + 300;
R := Rect(PosX1, PosY1, PosX2 - 30, PosY2);
Printer.Canvas.TexRect(R, PosX1 + 50, PosY1 + 50, GridToPrint.Cells[F, I]);
end;
end;
Printer.EndDoc;
end;
Δεν υπάρχουν σχόλια:
Δημοσίευση σχολίου