Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Print a table

Posted on 2001-07-19
4
Medium Priority
?
213 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 300 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Loops Section Overview

885 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