PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Wer kann mir beim Ausdrucken eines DBGrid helfen ??


Egon Kaschuba
14.10.2007, 20:43
//************************************************** ************
Printer.Canvas.Font.Name:='arial'; // Schriftgröße für Quittung
Printer.Canvas.Font.Size:=16;
Printer.Canvas. font.Style:=[fsBold];

Printer.Canvas.TextOut(0,270,'Quittung :'+' '+IntToStr(VQuittung));
Printer.Canvas.Font.Name:='arial';
Printer.Canvas.Font.Size:=16;
Printer.Canvas. font.Style:=[];

Printer.Canvas.Font.Name:='arial'; // Schriftgröße für Datum
Printer.Canvas.Font.Size:=12;
VDatum:=table1.fieldbyname('DATUM').asString ;
Printer.Canvas.TextOut(450,270,'Datum :'+' '+VDatum);
//************************************************** ***************************************

// Schriftgröße für Artikel ... u.s.w
Printer.Canvas.Font.Name:='arial';
Printer.Canvas.Font.Size:=14;
Printer.Canvas.TextOut(10,350,'Nr Artikel Anz. EP. Rab. Ges.');
Printer.Canvas.TextOut(1,355,'____________________ ____________________________________');
Printer.Canvas.TextOut(0,410,IntToStr(xLfn));
Printer.Canvas.TextOut(80,410,VArtikel);
VVerkaufspreis:=table2.fieldbyname('VERKAUFSPREIS' ).asCurrency;
sum := sum +(vverkaufspreis);// * Vmenge);
Format_VKPreis:=format ('%n',[sum]);
Printer.Canvas.TextOut(360,410,Format_VKPreis);
Printer.Canvas.TextOut(80,410,VArtikel);
VMenge:=table2.fieldbyname('MENGE').asInteger;
Printer.Canvas.TextOut(245,410,IntToStr(VMenge));
Printer.Canvas.TextOut(500,410,DBRabatt.Text+''+'% ');
//************************************************** ***************************************
//************************************************** ***************************************
Printer.Canvas.Font.Name:='control'; // Steuercode für Bondrucker und Schublade
Printer.Canvas.Font.Size:=10;
Printer.Canvas.TextOut(0,0,'A');
//************************************************** ***************************************:confused:

Christoph Krieg
25.10.2007, 17:06
Wenn Du ein Reporting-Toosl wie z.B. QuickReport benutzest (Muss bei D7 von der CD nachinstalliert werden, ist aber noch dabei) kannst Du die Zellen aus dem DBGrid auslesen und als QRLabel, das ist die Label-Komponente von QuickReport, darstellen.

Hatte dafür mal folgende Funktion geschrieben:


procedure DrawGrid( Source: TObject;
Target: TObject;
bx : Integer;
by : Integer;
PosX : Integer;
PosY : Integer;
tFont : Integer);

// ---------------------------------------------------------------------------
// Parameter:
// ---------------------------------------------------------------------------
// Source: Ursprungstabelle als StringGrid
// Target: Quickreport-Komponente auf der die Tabelle dargestellt werden soll
// bx : Box Länge (Box bezeichnet das Gridfeld
// by : Box Breite
// PosX : X-Position bei der das Grid gezeichnet wird
// PosY : Y-Position bei der das Grid gezeichnet wird
// tFont : Schriftgröße für die Texte innerhalb des Grids
// ---------------------------------------------------------------------------

var zCol : Integer;
zRow : Integer;
ColCount: Integer;
RowCount: Integer;
box : TQRShape;
bLeft : Integer;
bTop : Integer;
cText : TQRLabel;
bxTemp : Integer;
aWidth : Integer;
dummy : Double;
err : Integer;
rColor : TColor;
cColor : TColor;

begin
aWidth:=bx + 30; // Breite der Überschrift
rColor:=clSilver;
cColor:=clSilver;
ColCount:=TStringGrid(Source).ColCount;
RowCount:=TStringGrid(Source).RowCount;
bLeft:=PosX;
bTop:=PosY;
for zCol:=1 to ColCount do
begin
for zRow:=1 to RowCount do
begin
// Erzeuge das Gridgitter
box:=TQRShape.Create(nil);
box.Parent:=TQRSubDetail(Target);
box.Left:=bLeft;
if zCol = 1 then
box.Width:=aWidth
else
box.Width:=bx;
box.Height:=by;
box.Top:=bTop;
// Erzeuge den Gitterinhalt
cText:=TQRLabel.Create(nil);
cText.Parent:=TQRSubDetail(Target);
// Schriftzuweisung
cText.Font.Name:='Arial';
cText.Font.Size:=tFont;
// Zuweisung des Inhalts
cText.Caption:=TStringGrid(Source).Cells[(zCol - 1), (zRow - 1)];
cText.Top:=box.Top + round((box.Height - cText.Height) / 2);
if zCol = 1 then
cText.Left:=box.Left + TextAlign
else
cText.Left:=((box.Left + bx) - (cText.Width + TextAlign));
if zRow = 1 then
cText.Left:=box.Left + round((bx - cText.Width) / 2);
// Formatierung
// --------------------------------------------------
// Spalten und Zeilenüberschriften:
if (zCol = 1) and (cText.Caption <> '') and (zRow < RowCount) then
begin
box.Brush.Color:=cColor;
cText.Font.Style:=[fsBold];
cText.Transparent:=True;
end;
if (zRow = 1) and (cText.Caption <> '') then
begin
box.Brush.Color:=rColor;
cText.Font.Style:=[fsBold];
cText.Transparent:=True;
end;
if (zRow = RowCount) then
cText.Font.Style:=[fsBold];
// Textinhalt
val(cText.Caption, dummy, err);
if (err = 0) and (dummy < 0) then
cText.Font.Color:=clRed;
bTop:=bTop + by;
end;
if zCol = 1 then
bLeft:=bLeft + aWidth
else
bLeft:=bLeft + bx;
bTop:=PosY;
end;
end;


Wird innerhalb des Reports aufgerufen:

procedure TRpUmsatzPG.QuickRepBeforePrint(Sender: TCustomQuickRep;
var PrintReport: Boolean);
begin
DrawGrid(TStringGrid(F_Display.TabUmsatzPG), TQRSubDetail(Detail1), 74, 20, 10, 30, 10);
end;


Vielleicht hilft Dir das weiter

Grüße

Christoph

Egon Kaschuba
14.11.2007, 18:14
:D

Hallo Christoph,
kommer erst heute dazu mich zu bedanken.

Prima geklappt.

Gruß Egon