我測試通過:
資料:
if exists (select * from sysobjects where id = OBJECT_ID('[t3]') and OBJECTPROPERTY(id, 'IsUserTable') = 1) DROP TABLE [t3]
CREATE TABLE [t3] ( [dm] [char] (2) NULL , [je] [int] NULL )
INSERT [t3] ( [dm] , [je] ) VALUES ( '01' , 100 )
INSERT [t3] ( [dm] , [je] ) VALUES ( '02' , 200 )
INSERT [t3] ( [dm] , [je] ) VALUES ( '01' , 150 )
INSERT [t3] ( [dm] , [je] ) VALUES ( '03' , 100 )
INSERT [t3] ( [dm] , [je] ) VALUES ( '04' , 150 )
文件:Unit1.dfm
object Form1: TForm1
Left = 192
Top = 107
Width = 696
Height = 480
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object DBGrid1: TDBGrid
Left = 40
Top = 176
Width = 521
Height = 233
DataSource = DataSource1
TabOrder = 0
TitleFont.Charset = DEFAULT_CHARSET
TitleFont.Color = clWindowText
TitleFont.Height = -11
TitleFont.Name = 'MS Sans Serif'
TitleFont.Style = []
end
object Button1: TButton
Left = 464
Top = 88
Width = 75
Height = 25
Caption = 'Button1'
TabOrder = 1
OnClick = Button1Click
end
object ppReport1: TppReport
AutoStop = False
DataPipeline = ppDBPipeline1
PrinterSetup.BinName = 'Default'
PrinterSetup.DocumentName = 'Report'
PrinterSetup.PaperName = 'Letter'
PrinterSetup.PrinterName = 'Default'
PrinterSetup.mmMarginBottom = 6350
PrinterSetup.mmMarginLeft = 6350
PrinterSetup.mmMarginRight = 6350
PrinterSetup.mmMarginTop = 6350
PrinterSetup.mmPaperHeight = 279401
PrinterSetup.mmPaperWidth = 215900
PrinterSetup.PaperSize = 1
DeviceType = 'Screen'
Left = 320
Top = 96
Version = '6.03'
mmColumnWidth = 0
DataPipelineName = 'ppDBPipeline1'
object ppHeaderBand1: TppHeaderBand
mmBottomOffset = 0
mmHeight = 13229
mmPrintPosition = 0
end
object ppDetailBand1: TppDetailBand
mmBottomOffset = 0
mmHeight = 13229
mmPrintPosition = 0
end
object ppFooterBand1: TppFooterBand
mmBottomOffset = 0
mmHeight = 13229
mmPrintPosition = 0
object ppDBCalc1: TppDBCalc
UserName = 'DBCalc1'
DataField = 'je'
DataPipeline = ppDBPipeline1
Font.Charset = DEFAULT_CHARSET
Font.Color = clBlack
Font.Name = 'Arial'
Font.Size = 10
Font.Style = []
Transparent = True
DataPipelineName = 'ppDBPipeline1'
mmHeight = 3969
mmLeft = 49213
mmTop = 2381
mmWidth = 17198
BandType = 8
end
object ppLabel1: TppLabel
OnPrint = ppLabel1Print
UserName = 'Label1'
Caption = 'Label1'
Font.Charset = DEFAULT_CHARSET
Font.Color = clBlack
Font.Name = 'Arial'
Font.Size = 10
Font.Style = []
Transparent = True
mmHeight = 3969
mmLeft = 75142
mmTop = 2910
mmWidth = 10583
BandType = 8
end
end
end
object ADOConnection1: TADOConnection
Connected = True
ConnectionString =
'Provider=SQLOLEDB.1;Password=jserp;Persist Security Info=True;Us' +
'er ID=jserp;Initial Catalog=test;Data Source=BILL'
LoginPrompt = False
Provider = 'SQLOLEDB.1'
Left = 128
Top = 56
end
object ADOTable1: TADOTable
Active = True
Connection = ADOConnection1
CursorType = ctStatic
TableName = 't3'
Left = 208
Top = 48
end
object DataSource1: TDataSource
DataSet = ADOTable1
Left = 264
Top = 64
end
object ppDBPipeline1: TppDBPipeline
DataSource = DataSource1
UserName = 'DBPipeline1'
Left = 384
Top = 88
object ppDBPipeline1ppField1: TppField
FieldAlias = 'dm'
FieldName = 'dm'
FieldLength = 2
DisplayWidth = 2
Position = 0
end
object ppDBPipeline1ppField2: TppField
Alignment = taRightJustify
FieldAlias = 'je'
FieldName = 'je'
FieldLength = 0
DataType = dtInteger
DisplayWidth = 10
Position = 1
end
end
end
文件:Unit1.pas
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ppDB, ppDBPipe, Grids, DBGrids, DB, ADODB, ppCtrls, ppPrnabl,
ppClass, ppBands, ppCache, ppComm, ppRelatv, ppProd, ppReport, StdCtrls;
type
TForm1 = class(TForm)
ppReport1: TppReport;
ppHeaderBand1: TppHeaderBand;
ppDetailBand1: TppDetailBand;
ppFooterBand1: TppFooterBand;
ppLabel1: TppLabel;
ppDBCalc1: TppDBCalc;
ADOConnection1: TADOConnection;
ADOTable1: TADOTable;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
ppDBPipeline1: TppDBPipeline;
Button1: TButton;
procedure ppLabel1Print(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.ppLabel1Print(Sender: TObject);
begin
Self.ppLabel1.Caption:=ppDBCalc1.Value;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Self.ppReport1.Print;
end;
end.
注:pplabel1及ppdbcalc1均放在footer區,一卻正常