Solved

Generating a Report using TRichEdit

Posted on 2001-08-27
9
619 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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

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

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…
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 video discusses moving either the default database or any database to a new volume.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

762 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

20 Experts available now in Live!

Get 1:1 Help Now