Solved

Print a table

Posted on 2001-07-19
4
202 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

914 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now