--------------------------------------------- Tech Tip: Create Reports in Code ---------------------------------------------
A ReportBuilder report is composed of a set of components. Like other standard Delphi components, the components which make up the report layout have a run-time interface. That is they can be created and configured using Object Pascal code.
A complete example of creating a report entirely in code is contained in the Developers Guide.
The Developers Guide is located in the ..\RBuilder\Developers Guide\ directory.
If you would like to add objects to a report after Report.Print has been called, you will need to manually create the TppDrawCommand objects and add them to the report. See the following example on how to add lines below the last detail band after the report has begun generating.
I spent many time but still can't wirte a line at run-time, my coding is: procedure TfmSalesOrder_Print_JewelMax.rpSalesOrderStartPage( Sender: TObject); var lDrawLine: TppDrawLine; begin inherited; lDrawLine := TppDrawLine.Create(nil); lDrawLine.Page := rpSalesOrder.Engine.Page; lDrawLine.Left := 104000; lDrawLine.Top := 30000; lDrawLine.Height := 50000; lDrawLine.lineposition := lpLEFT; //lDrawLine.Width := rpSalesOrder.PrinterSetup.PageDef.mmPrintableWidth; end; although no compile error, but the line still cannot be shown, what wrong is it?
The following code seemed to work correctly for me. Why are you commenting out the Width property? Also, be sure the measurements are correct for your page size.
Comments
Line Example...
uses
ppTypes;
procedure TForm1.CreateLineAndPrint;
var
lLine: TppLine;
begin
lLine := TppLine.Create(nil);
lLine.Band := ppReport1.DetailBand;
lLine.Style := lsSingle;
lLine.Position := lpTop;
lLine.Top := 0.2;
lLine.Left := 0.2;
lLine.Width := 3;
lLine.Height := 0.5;
ppReport1.Print;
end;
---------------------------------------------
Tech Tip: Create Reports in Code
---------------------------------------------
A ReportBuilder report is composed of a set
of components. Like other standard Delphi
components, the components which make up the
report layout have a run-time interface.
That is they can be created and configured
using Object Pascal code.
A complete example of creating a report entirely
in code is contained in the Developers Guide.
The Developers Guide is located in the
..\RBuilder\Developers Guide\ directory.
--
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
ppreport1.print, like placed in band.beforeprint, then how to do it?
If you would like to add objects to a report after Report.Print has been
called, you will need to manually create the TppDrawCommand objects and add
them to the report. See the following example on how to add lines below the
last detail band after the report has begun generating.
http://www.digital-metaphors.com/tips/FillPageWithLines.zip
--
Thanks for supporting ReportBuilder! Please vote for ReportBuilder in the
Delphi Informant Readers Choice awards!
http://www.delphizine.com/ballot2004/
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
lDrawLine.position := lpTop;
The error message is "Undeclared identifier lpTop"
procedure TfmSalesOrder_Print_JewelMax.rpSalesOrderStartPage(
Sender: TObject);
var
lDrawLine: TppDrawLine;
begin
inherited;
lDrawLine := TppDrawLine.Create(nil);
lDrawLine.Page := rpSalesOrder.Engine.Page;
lDrawLine.Left := 104000;
lDrawLine.Top := 30000;
lDrawLine.Height := 50000;
lDrawLine.lineposition := lpLEFT;
//lDrawLine.Width := rpSalesOrder.PrinterSetup.PageDef.mmPrintableWidth;
end;
although no compile error, but the line still cannot be shown, what wrong is
it?
The following code seemed to work correctly for me. Why are you commenting
out the Width property? Also, be sure the measurements are correct for your
page size.
lDrawLine := TppDrawLine.Create(nil);
lDrawLine.Page := ppReport1.Engine.Page;
lDrawLine.LinePosition := lpTop;
lDrawLine.Left := ppReport1.PrinterSetup.PageDef.mmMarginLeft;
lDrawLine.Width := ppReport1.PrinterSetup.PageDef.mmPrintableWidth;
lDrawLine.Top := ppReport1.Engine.PrintPosRect.Top;
--
Thanks for supporting ReportBuilder! Please vote for ReportBuilder in the
Delphi Informant Readers Choice awards!
http://www.delphizine.com/ballot2004/
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com