?
Solved

Generating a Report using TRichEdit

Posted on 2001-08-27
9
Medium Priority
?
649 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
[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
  • 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 400 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
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!

 
LVL 10

Assisted Solution

by:Jacco
Jacco earned 400 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month9 days, 4 hours left to enroll

764 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