Solved

Generating a Report using TRichEdit

Posted on 2001-08-27
9
640 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 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
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 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi application Soap connection 5 133
Controlled Assessment GCSE - desperate help needed 4 112
how to resize animated Gif image in delphi ? 1 45
RESTRequest Parameter 4 54
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

733 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