Solved

Generating a Report using TRichEdit

Posted on 2001-08-27
9
628 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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
 
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

770 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