1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| procedure PrintGrid2(sGrid: TStringGrid);
var
X, Y: Integer;
ACol, ARow: Integer;
EmptyRow: Boolean;
TR : TRect;
begin
Printer.Title:='blabla';
Printer.BeginDoc;
Printer.Canvas.Pen.Color := 0;
Printer.Canvas.Font.Name := 'Verdana';
Printer.Canvas.Font.Size := 12;
Printer.Canvas.Font.Style := [fsBold, fsUnderline];
Printer.Canvas.TextOut(0, 0, 'blabla');
//
Printer.Canvas.Font.Size := 8;
// Entête
Printer.Canvas.Font.Style:=[fsBold];
X := 0;
for ACol := 1 to sGrid.ColCount - 1 do
begin
X := X + ACol * 50;
TR := Rect(X, Y, X + Printer.Canvas.TextWidth(sGrid.Cells[ACol, 0]), Y + 50);
Printer.Canvas.TextRect(TR, X, 100, sGrid.Cells[ACol, 0]);
end;
// Contenu
Printer.Canvas.Font.Style:=[];
Y := 0;
for ARow := 1 to sGrid.RowCount - 1 do
begin
//
EmptyRow := True;
for ACol := 1 to sGrid.ColCount - 1 do
if sGrid.Cells[ACol, Arow] <> '' then
begin
EmptyRow := False;
Break;
end;
if EmptyRow then
Continue;
//
X := 0;
Y := Y + 50;
for ACol := 1 to sGrid.ColCount - 1 do
begin
X := X + 50 * ACol;
TR := Rect(X, Y, X + Printer.Canvas.TextWidth(sGrid.Cells[ACol, ARow]), Y + 50);
Printer.Canvas.TextRect(TR, X, Y, sGrid.Cells[ACol, ARow]);
end;
end;
Printer.EndDoc;
end; |
Partager