Solved

Print a table

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

743 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

13 Experts available now in Live!

Get 1:1 Help Now