• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 244
  • Last Modified:

printing stringgrid

hi all, i would like to print stringgrid, what i have do not make job correctly, my grid have linefeed and cariage return in some cells (#13#10), and the procedure i have dont not make it just making some square,, if someone can help me it would appreciate.....

thanks you
0
popy
Asked:
popy
  • 3
  • 2
1 Solution
 
popyAuthor Commented:
me be someone would like have to code i already have there is the code....it print but dont making linefeed and cariage return

procedure PrintGrid(sGrid: TStringGrid; sTitle: String);
var
 X1, X2 : Integer;
 Y1, Y2 : Integer;
 TmpI   : Integer;
 F      : Integer;
 TR     : TRect;
begin
 Printer.Title:=sTitle;
 Printer.BeginDoc;
 Printer.Canvas.Pen.Color:=0;
 Printer.Canvas.Font.Name:='Times New Roman';
 Printer.Canvas.Font.Size:=12;
 Printer.Canvas.Font.Style:=[fsBold, fsUnderline];
 Printer.Canvas.TextOut(0, 100, Printer.Title);
 For F:=1 to sGrid.ColCount-1 do begin
   X1:=0;
   For TmpI:=0 to (F-1) do
     X1:=X1+5*(sGrid.ColWidths[TmpI]);
   Y1:=300;
   X2:=0;
   For TmpI:=1 to F do
     X2:=X2+5*(sGrid.ColWidths[TmpI]);
   Y2:=450;
   TR:=Rect(X1, Y1, X2-30, Y2);
   Printer.Canvas.Font.Style:=[fsBold];
   Printer.Canvas.Font.Size:=7;
   Printer.Canvas.TextRect(TR, X1+50, 350, sGrid.Cells[F, 0]);
   Printer.Canvas.Font.Style:=[];
   For TmpI:=1 to sGrid.RowCount-1 do begin
     Y1:=150*TmpI+300;
     Y2:=150*(TmpI+1)+300;
     TR:=Rect(X1, Y1, X2-30, Y2);
     Printer.Canvas.TextRect(TR, X1+50, Y1+50, sGrid.Cells[F, TmpI]);
   end;
 end;
 Printer.EndDoc;
end;
0
 
Scay7Commented:
Here a nice object that i found which will help you:
http://www.delphipages.com/result.cfm?AC=8469

look for...
TObjectPrinter V2.0.7

Download the version of delphi you are using and simple as:

With ObjectPrinter1 do
begin
  ClearObject;
  AddObject(StringGrid1);
  Execute;  
end;

Peace Scay7
0
 
popyAuthor Commented:
Wow, exactly what i looking for


thanks alot
0
 
popyAuthor Commented:
i have a question

  i would like to bypass the preview, can i..???
0
 
Scay7Commented:
Yes you should beable to in the options menu...
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now