Solved

Print a table

Posted on 2001-07-19
4
209 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month10 days, 23 hours left to enroll

632 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