Board index » delphi » Report printing component that prints a ttable

Report printing component that prints a ttable

What I'm looking for is a component or function that, given a ttable, can
print a very basic "dump" that has the field names as headings and the
data.

Anyone know of anything?

-Peter

 

Re:Report printing component that prints a ttable


Depends on how basic you are looking for...   Here is code which dumps a
ttable to a CommaDelimited file which you could probably modify to include
field lengths.  Here is a nice function also...  Modify all the writes below
to look like the one I just commented in and you can have a fixed format
dump...  Good luck!

Function Nice(old: string; newlen : short): string;
begin
Result := Copy(trim(old) + StringOfChar(' ', 100), 1, newlen);
end;

procedure TfNet98.bACNExportClick(Sender: TObject);
var
  tf: TextFile;
  text: String;
  i: short;
begin
    sdExport.FileName := 'ACN.TXT';
    sdExport.Filter := 'Text files (*.txt)|*.TXT';

    if not sdExport.Execute then Exit;

    AssignFile(tf, sdExport.FileName);
  try
    Rewrite(tf);
    Write(tf, '"', tNet98.Fields[0].FieldName, '"');  //Try this:  Write(tf,
Nice(FIELD HERE, tNet98.Fields[0].DisplayWidth));

      for i := 1 to tNet98.FieldCount - 1 do
           Write(tf, ',"', tNet98.Fields[i].FieldName + '"');
    Writeln(tf);

    tNet98.First;
    while not tNet98.EOF do
      begin
      Write(tf, '"', tNet98.Fields[0].AsString, '"');

      for i := 1 to tNet98.FieldCount - 1 do
        begin
          text := tNet98.Fields[i].AsString;

          While Pos(Chr(13), text) > 0 do
            Delete(text, Pos(Chr(13), Text), 1);

          Write(tf, ',"', text, '"');
        end;

      Writeln(tf);
      tNet98.Next;
      end;
    finally
      CloseFile(tf);
    end;
end;

Quote
Peter Steele wrote in message <01bd5cfa$6bf416a0$2b19d9cd@peter>...
>What I'm looking for is a component or function that, given a ttable, can
>print a very basic "dump" that has the field names as headings and the
>data.

>Anyone know of anything?

>-Peter

Re:Report printing component that prints a ttable


On 1 Apr 1998 14:50:02 GMT, "Peter Steele"

Quote
<pste...@pinncorp.com> wrote:
>What I'm looking for is a component or function that, given a ttable, can
>print a very basic "dump" that has the field names as headings and the
>data.

>Anyone know of anything?

>-Peter

I have a DBGrid that will print itself out.  It uses
whatever font the grid, and whatever font the titles are in.
I could email you the source if you would like.

Iman L. Crawford
g...@arn.net

'Cthulu for president in '98'
'Why choose the lesser evil?'

Re:Report printing component that prints a ttable


Quote
Peter Steele wrote:

> What I'm looking for is a component or function that, given a ttable, can
> print a very basic "dump" that has the field names as headings and the
> data.

> Anyone know of anything?

> -Peter

There is in DSP a component "prtgrid" for printing a table in a grid.

Regards

Other Threads