Solved

Print a table

Posted on 2001-07-19
4
206 Views
Last Modified: 2010-04-06
Hi, I would like to know how I can print a table ? for example, the table have 3 fielddefs . I would like to when I click on print button, it prints like:

Name: (the name[1] on the table1)   Address: (the address[1] on the table1)     phone: (the phone[1] on the table)
Name: (the name[2] on the table1)   Address: (the address[2] on the table1)     phone: (the phone[2] on the table)
....
and print all the data on the table1.

How I can do that?

Thanks Alexandre
0
Comment
Question by:alsantos
4 Comments
 
LVL 1

Expert Comment

by:alx512
ID: 6301070
This code demonstraint how you can print directly to printer. But better way is to use any report engine,
such as QReport in Delphi or Seagate Crystal Report.

procedure PrintTable(ATable: TTable);
var
  mt: TextFile;
begin
  try
    AssignPRN(mt);
    Append(mt);
    Printer.Canvas.Font.Name := 'Courier';
    Printer.Canvas.Font.Charset := DEFAULT_CHARSET;
    Printer.Canvas.Font.Pitch := fpFixed;
    Printer.Canvas.Font.Style := [];
    Printer.Canvas.Font.Size := 10;
    if not ATable.Active then ATable.Open else ATable.First;
    while not ATable.EOF
      begin
        WriteLn(mt,
          Format('Name: %s Address: %s phone: %s',
          [ATable.Fields[0].AsString,
           ATable.Fields[1].AsString,
           ATable.Fields[2].AsString]
        );
        ATable.Next;
      end;
  finally
    CloseFile(mt);
  end;
end;
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6301087
0
 
LVL 3

Accepted Solution

by:
nnbbb09 earned 100 total points
ID: 6301865
There is a component at http://www.orbital.co.za that can print a dataset.

Jo
0
 
LVL 2

Author Comment

by:alsantos
ID: 6305289
Thanks nnbbb09 , The components works very well :) Alexandre
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question