Solved

Generating a Report using TRichEdit

Posted on 2001-08-27
9
623 Views
Last Modified: 2012-06-27
How do I generate a report from a SQL database,
reading the fields into a TRichEdit, knowing the
length of the fields and their text discriptions and
going over to a new line if the fields and their
discriptions exceed the RichEdit components width (wordwrap is disabled) ?
0
Comment
Question by:Gert76
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 3

Expert Comment

by:Slavak
ID: 6431138
why RichEdit?
0
 

Author Comment

by:Gert76
ID: 6435460
The client wants a RichEdit report because they want to save the report as tab delimited file and they want to
edit the information in the report etc. The previous
reports before I got involved in the project was all done
with RichEdit's so I don't think they will change this.
0
 
LVL 3

Accepted Solution

by:
Slavak earned 100 total points
ID: 6435541
1. To save report as tab delimited file you not must generate it in richedit.

2. If you still want richedit it can be like this:

procedure TForm1.Button1Click(Sender: TObject);
begin
 RichEdit1.Text := '';

 Query1.Open;
 While not Query1.Eof Do Begin
  RichEdit1.Lines.Add(Format('%40s %10d %10d %50s',
                             [Query1.Fields[0].AsString,
                              Query1.Fields[1].AsInteger,
                              Query1.Fields[2].AsInteger,
                              Query1.Fields[3].AsString]));
  Query1.Next;
 End;
 Query1.Close;
end;
 
0
 
LVL 10

Assisted Solution

by:Jacco
Jacco earned 100 total points
ID: 6442228
Hi Gert,

You could also use the available export filters:

uses
  QRExport;

procedure TForm1.Button1Click(Sender: TObject);
var
  lFilter: TQRRTFExportFilter;
begin
 lFilter := TQRRTFExportFilter.Create('c:\tst.rtf');
 try
   MyReport.ExportToFilter(lFilter);
 finally
   lFilter.Free;
 end;
end;

Other available filters are:

TAsciiExportFilter
TWMFExportFilter

Regards Jacco
0
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.

 
LVL 10

Expert Comment

by:Jacco
ID: 6442234
A problem with the RTFExportFilter is that all components that need to be on one line of the RTF need to have their Top properties exactly the same.

Regards Jacco
0
 
LVL 10

Expert Comment

by:Jacco
ID: 6460575
Hi Gert,

Are you still here?
0
 

Author Comment

by:Gert76
ID: 6463714
Hi Jaco

To save the file as RTF is not an option !
They want to save the file as a tab delimited file to
import and edit it in Excel.

Thanks
Gert
0
 
LVL 10

Expert Comment

by:Jacco
ID: 6466382
Hi Gert,

Then you might consider using:

procedure TForm1.Button1Click(Sender: TObject);
var
  lFilter: TQRCommaSeparatedFilter;
begin
  lFilter := TQRCommaSeparatedFilter.Create('test.csv');
  try
    QuickRep1.ExportToFilter(lFilter);
  finally
    lFilter.Free;
  end;
end;

This will give you a file you can import into Excel.

Regards Jacco
0
 
LVL 17

Expert Comment

by:geobul
ID: 9288647
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

split points between Slavak and Jacco

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Thanks,

geobul
EE Cleanup Volunteer
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

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 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…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

863 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

25 Experts available now in Live!

Get 1:1 Help Now