选择报表控件,有哪个可以?(100分)

  • 主题发起人 主题发起人 FeiDao
  • 开始时间 开始时间
F

FeiDao

Unregistered / Unconfirmed
GUEST, unregistred user!
有哪个报表控件可以在运行时自定义,并且支持在ActiveForm下使用的?
http://www.delphibbs.com/delphibbs/dispq.asp?lid=784458
 
f1book不是很好吗?
 
DELPHI自带的不就可以吗?
 
to:ssgang,
Delphi自带的可以在运行时让客户自已修改吗?

 
加分吧:
在建一个Form,在这个Form上放frReport,AdoTable,frdbdataset,datasource
 
to:whf
看来这200分应该是你的,我先试试。
 
I believe Fast Report cando
this, butdo
believe Report Builder cando
this too.
Copy the codes from RB developer Guide (of course, you must good at English):
Creating Reports in Code
Coding a Report
A report layout is composed of a set of compo-nents.
Like other standard Delphi components, the
components that make up a report layout have a
run-time interface. That is, they can be created and
configured using Object Pascal code. This capabil-ity
can be used to create entire reports dynamically.
Take these steps to create a report dynamically:
1 Create data access components.
2 Create the report.
3 Create the report bands.
4 Add data-aware components.
5 Add formatting components.
These are the same steps you would follow to cre-ate
a report using the Delphi IDE and the Report-Builder
Report Designer. Creating the components
manually requires some additional knowledge of
how the different parts of the report fit together.
The following discussion steps you through the
actual code necessary to build a simple report.
1 Declare the necessary uses clause.
uses
DB, {contains TDataSource}
DBTables, {contains TTable}
ppReport, {contains TppReport}
ppDBBDE, {contains TppBDEPipeline}
ppBands, {contains all band classes}
ppCtrls, {contains standard components}
ppTypes, {contains all ReportBuilder enumerated types}
ppVar;
{contains SystemVariable and Variable classes}
The types that are being used from each unit are
documented in the comments of this code.
2 Declare the local variables necessary to create
the report.
procedure TForm1.Button1Click(Sender:
 TObject);
var
lTable: TTable;
lDataSource: TDataSource;
lDataPipeline: TppBDEPipeline;
lReport: TppReport;
lLabel1: TppLabel;
lLabel2: TppLabel;
lDBText1: TppDBText;
lDBText2: TppDBText;
lSysVar: TppSystemVariable;
The prefix 'l' stands for local. This coding standard
makes local variables easily distinguishable from
component level variables (which are prefixed with
an 'F') and from proper component names (such as
'Report1').
3 Create data access components.
lTable := TTable.Create(Self);
lTable.Name := 'tblCustomer';
lTable.DatabaseName := 'DBDemos';
lTable.TableName := 'customer.db';
lDataSource := TDataSource.Create(Self);
lDataSource.Name := 'dsCustomer';
lDataSource.DataSet := lTable;
lDataPipeline := TppBDEPipeline.Create.
 (Self);
lDataPipeline.Name := 'plCustomer';
lDataPipeline.DataSource := lDataSource;
These are standard Delphi data access components.
It is not necessary to assign the Name property of
these components;
we'vedo
ne this to give you an
idea of how they would be named if they were cre-ated
within the Delphi IDE.
4 Create the report.
lReport := TppReport.Create(Self);
lReport.DataPipeline := lDataPipeline;
The data pipeline assignment is vital here. Without
a data pipeline assigned, this report would generate
an endless number of pages.
5 Create the report bands.
lReport.CreateDefaultBands;
This method creates a header band, a detail band,
and a footer band. It is also possible to create the
bands individually and assign them to the report.
A report must always have a detail band in order to
generate properly.
6 Add labels to the header band.
lLabel1 := TppLabel.Create(Self);
lLabel1.Band := lReport.HeaderBand;
lLabel1.spLeft := 2;
lLabel1.spTop := 2;
lLabel1.Caption := 'Customer No.';
lLabel2 := TppLabel.Create(Self);
lLabel2.Band := lReport.HeaderBand;
lLabel2.spLeft := lLabel1.spLeft +
lLabel1.spWidth + 3;
lLabel2.spTop := 2;
lLabel2.Caption := 'Company Name';
These two labels will print at the top of each page.
The 'sp' in the spLeft and spTop properties refers to
screen pixels. All positional properties of the com-ponents
within a report are expressed in the units of
the report itself (i.e. the value of the Report.Units
property). Using the screen pixel version of these
properties allows us to size and position compo-nents
without concern for the current value of the
Unit property.
7 Add data-aware components to the detail band.
lDBText1 := TppDBText.Create(Self);
lDBText1.Band := lReport.DetailBand;
lDBText1.spLeft := lLabel1.spLeft;
lDBText1.spTop := lLabel1.spTop;
lDBText1.DataPipeline := lDataPipeline;
lDBText1.DataField := 'CustNo';
lDBText2 := TppDBText.Create(Self);
lDBText2.Band := lReport.DetailBand;
lDBText2.spLeft := lLabel2.spLeft;
lDBText2.spTop := lLabel2.spTop;
lDBText2.DataPipeline := lDataPipeline;
lDBText2.DataField := 'Company';
These components are positioned in the detail band
directly below their corresponding label compo-nents.
8 Add a page number and timestamp to the footer band.
lSysVar := TppSystemVariable.Create
 (Self);
lSysVar.Band := lReport.FooterBand;
lSysVar.VarType := vtPrintDateTime;
lSysVar.spLeft := 2;
lSysVar.spTop := 2;
lSysVar := TppSystemVariable.Create.
 (Self);
lSysVar.Band := lReport.FooterBand;
lSysVar.VarType := vtPageNoDesc;
lSysVar.Alignment := taRightJustify;
lSysVar.spLeft := (lReport.PrinterSetup.PageDef.spPrintableWidth
 -lSysVar.spWidth) -2;
lSysVar.spTop := 2;

Notice how the second system variable component
is right-justified. The AutoSize property defaults
to True for system variables, so we need only to set
the Alignment property and component position.
Hereweset spLeft so that thecomponent isflush
with the right margin of the page (less 2 pixels for
spacing). Because it is right-justified, this compo-nent
will expand to the right when it prints. The
PrinterSetup.PageDef object contains all of the
dimensions of the page. The spPrintableWidth
property contains the width of the paper less the
left and right margins (in screen pixels).
9 Preview the report.
lReport.Print;
The DeviceType property of a report defaults to
'Screen,' so calling print here causes the Print Pre-view
form to be displayed.
10 Free the report.
lReport.Free;
The ModalPreview property of the report defaults
to True;
therefore, this line of code will only fire
after the Print Preview form has been closed. When
the report is freed, it will automatically free the
bands and components it contains.
11 Free the data access components.
lTable.Free;
lDataSource.Free;
lDataPipeline.Free;
The data access components are not freed by the
report, and so must be freed separately.
 
后退
顶部