Introduction To Rave Reports
Introduction To Rave Reports
Reports
By: Leonel Togniolli
Abstract: This is a introduction to Rave Reports. Part I describes how to work with Code Base reports. - by Leonel
Togniolli
Delphi 7 ships with Rave Reports 5.0.8. If you haven't already, download the update from the registered users
page, since it fixes some important problems.
You can develop reports with Rave using two different ways: Code Based or with the Visual Designer. This
document describes how to work with the code based engine. Part II will describe the Visual Designer.
To write a code based report, just drop a TRvSystem component on the form and write the report on the OnPrint
event handler. Sender is the report you are creating, and can be typecasted to TBaseReport. It contains all the
methods you need to output information to that particular report.
So, what does that simple code do? First, it calls SetFont to select the font and size of the text that will be printed
from that point on. Then it positions the cursor on the coordinates (1,1). These coordinates are expressed using
the units set in the SystemPrinter.Units property of the RvSystem object, and it defaults to Inches. You can set it
to unUser and set a number relative to Inches in the SystemPrinter.UnitsFactor property. For example, if
UnitsFactor was set to 0.5 then 1 unit would correspond to half an inch. Finally, the code calls the Print method to
output the text. Here's the output:
Tabular Code Based Report
Here's another example. It displays a list of the folders in the root of the current drive, along with a recursive count
of number of files and folder, and total size of the files included in each folder.
Notice that a different approach has been taken: instead of specifying the coordinates of each text output, the
printing was done using Lines and Columns as references. The line heigh depends on the size of the current font:
each unit represents 1/72nds of an inch, so each line printed with a size 10 font will have, aproximatelly, a height
of 0.138 inches. Lines are advanced after calls to PrintLn or NewLine. Colums are defined using calls to the
SetTabs method, and the PrintTab method will print the text in the current column and advance to the next one.
Here's the output:
You can find the full source, including the implementation of EnumFolders and GetFolderInfo, on CodeCentral.
In this example the methods Rectangle, Ellipse and Pie have been used draw shapes with different fills. Bitmaps
were outputted using PrintBitmap and as the brush of the ellipses. Here's the output:
A sample application, containing full source code for those three examples can be found at CodeCentral.
procedure TForm1.ImprimerClick(Sender: TObject);
begin
RvProject1.Open; // <<<<<<<<<<<<<<<<<<<<<<<<<<<< ici
RvProject1.ExecuteReport('Etiquettes');
RvProject1.Close;
end;
end;
[jpg][D2006][Rave 6.5] mettre une image JPG
dans rave
FUNCTION
bitmap1_onbeforePrint(self :
TRaveBitmap);
begin
IF (DataMemoryNOMIMAGE.isnull) then
self.visible:=false;
else
self.visible:=true;
self.filelink:=DataMemoryNOMIMAGE.as
String;
end IF;
end OnBeforePrint;
Comment puis-je
a) modifier le composant de rave pour
faire de filelink une propriété reconnue
ou
b) faire pour que delphi envoie l'image (là
j'ai carrément besoin d'une bouée)
00
07/05/2008, 11h30 #2
// C'est un bitmap
variable //
if fileExists(BdPath
+ 'Images\' + xText + '.bmp')
then begin
(rvPage.Components[ncmp] as
TRaveBitMap).Image.LoadFromFile
(BdPath + 'Images\' + xText +
'.bmp');
Inscription: octobre 2002
end
Messages: 379
else begin
00
07/05/2008, 14h26 #3
Code :
// uses JPEG ajouté
Nom : Serge Girard
procedure TForm1.RvDataSetConnection2ValidateRow(
Inscription: janvier 2007 Connection: TRvCustomConnection; var ValidRow:
BOOLEAN);
Localisation: Nantes - Ile var
d'Yeu Image: TJPEGImage;
begin
Âge: 54
IF pos('.JPG','PONTON.JPG')>0 then begin // ici
Messages: 2 904
ce n'est qu'un test bidon
Image := TJPEGImage.CREATE; // CREATE a
Points: 3 374 TJPEGImage class
try
Image.LoadFromStream('C:\Temp\ponton.jpg'); //
LOAD up JPEG image FROM ImageStream
Image.DIBNeeded; // Convert JPEG TO bitmap
format
Bitmap.Assign(Image);
finally
Image.Free;
end;
end; { IF }
end;
00
07/05/2008, 14h54 #4
Membre éclairé
il te suffit de mettre un composant Bitmap (onglet Standard
dans le concepteur Rave) sur ton état Rave ou de le créer en
dynamique avec createChild
Messages: 379
Points: 356
00
08/05/2008, 09h06 #5
Modérateur Code :
procedure TForm1.RvDataSetConnection2ValidateRow(
Connection: TRvCustomConnection; var ValidRow:
BOOLEAN);
var
MyPage : TRavePage;
Ravebitmap : TRaveBitMap;
ImageJPEG : TJpegImage;
begin
MyPage :=
RvProject1.ProjMan.FindRaveComponent('Report2.MainPage',
nil) AS TRavePage;
RaveBitMap :=
Nom : Serge Girard RvProject1.ProjMan.FindRaveComponent('BitMap1',MyPage)
AS TRaveBitMap;
Inscription: janvier 2007 IF assigned(RaveBitMap) then
begin
Localisation: Nantes - Ile
ImageJPEG := TJPEGImage.CREATE; // CREATE a
d'Yeu
TJPEGImage class
Âge: 54 try
ImageJPEG.LoadFromFile('C:\Temp\ponton.jpg'); //
Messages: 2 904 LOAD up JPEG ImageJPEG FROM ImageStream
ImageJPEG.DIBNeeded; // Convert JPEG TO bitmap
Points: 3 374 format
RaveBitMap.Image.Assign(ImageJPEG);
finally
ImageJPEG.Free;
end;
end; { IF }
end;
08/05/2008, 10h06 #6
SergioMaster Finalisation ?
Modérateur
ImageJPEG.DIBNeeded; //
Conversion JPEG vers Bitmap
RaveBitMap.Image.Assign(ImageJPEG);
finally
ImageJPEG.Free;
end;
end
else begin
RaveBitmap.Image.LoadFromFile(NomImage);
end; { IF }
end
else RaveBitmap.Image:=nil;
end;
J' hésite à mettre résolu , pour que l'on puisse me faire des
remarques et suggestions