急!!急!!!这个报表怎么做?(200分)

  • 主题发起人 主题发起人 狂歌弄扁舟
  • 开始时间 开始时间

狂歌弄扁舟

Unregistered / Unconfirmed
GUEST, unregistred user!
如果报表中的数据把一张纸分成上中下三部分。
上部分是总的信息
中间有分成左右两半(左边信息和右边信息没关系是来自两个不同的表。但都是和总的有关联。)
下半部分是总计
主要是中间部分怎么完成 有没其他控件什么的
谢谢各位!!!!
 
FastReport报表工具很强的,做这个报表应该没问题
 
ReportBuilder 是不错的打印控件,功能非常强大
 
能用quickReport做吗?
 
用quickReport就自己画报表呗
 
用Report Machine 吧,非常好用的。
中间分两个的话就用两个子报表,两个子报表都关联上主的不就行了吗?
 
中间有分成左右两半(左边信息和右边信息没关系是来自两个不同的表。但都是和总的有关联。)
---这是不可能的!
除非你把中间的两个表的数据塞到一个表里才可以这样做!
否则没门!!!
 
用quickReport除了画还有其他方法吗?
有大概这样的例子:(其中材料和工时没关系但和都和产品有关系)
产品编码 NO—12345
-------------------------------------
材料编码 |材料价格|材料数量| 工时编码|工时|
0001 |20 | 34 |A110 |1.3|
0002 |34.2 |20 |B220 |2.3|
0003 |12 |5 | | |
| | | | | |
合计
 
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, QuickRpt, ExtCtrls, QRCtrls;
type
TForm1 = class(TForm)
QuickRep1: TQuickRep;
TitleBand1: TQRBand;
DetailBand1: TQRBand;
ADODataSet1: TADODataSet;
ADODataSet1a: TStringField;
ADODataSet1b: TIntegerField;
QRDBText1: TQRDBText;
QRDBText2: TQRDBText;
PageFooterBand1: TQRBand;
QRLabel1: TQRLabel;
QRExpr1: TQRExpr;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
i: integer;
begin
ADODataSet1.CreateDataSet;
ADODataSet1.Open;
for i:=1 to 65do
ADODataSet1.InsertRecord(['sad', i]);
QuickRep1.Preview;
end;

end.

object Form1: TForm1
Left = 192
Top = 103
Width = 544
Height = 375
VertScrollBar.Position = 468
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
Scaled = False
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object QuickRep1: TQuickRep
Left = -32
Top = -212
Width = 794
Height = 1123
Frame.Color = clBlack
Frame.DrawTop = False
Frame.DrawBottom = False
Frame.DrawLeft = False
Frame.DrawRight = False
DataSet = ADODataSet1
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Arial'
Font.Style = []
Functions.Strings = (
'PAGENUMBER'
'COLUMNNUMBER'
'REPORTTITLE')
Functions.DATA = (
'0'
'0'
'''''')
Options = [FirstPageHeader, LastPageFooter]
Page.Columns = 2
Page.Orientation = poPortrait
Page.PaperSize = A4
Page.Values = (
100
2970
100
2100
100
100
0)
PrinterSettings.Copies = 1
PrinterSettings.Duplex = False
PrinterSettings.FirstPage = 0
PrinterSettings.LastPage = 0
PrinterSettings.OutputBin = Auto
PrintIfEmpty = True
SnapToGrid = True
Units = MM
Zoom = 100
object TitleBand1: TQRBand
Left = 38
Top = 38
Width = 718
Height = 99
Frame.Color = clBlack
Frame.DrawTop = False
Frame.DrawBottom = False
Frame.DrawLeft = False
Frame.DrawRight = False
AlignToBottom = False
Color = clWhite
ForceNewColumn = False
ForceNewPage = False
Size.Values = (
261.9375
1899.70833333333)
BandType = rbTitle
end
object DetailBand1: TQRBand
Left = 38
Top = 137
Width = 359
Height = 19
Frame.Color = clBlack
Frame.DrawTop = False
Frame.DrawBottom = False
Frame.DrawLeft = False
Frame.DrawRight = False
AlignToBottom = False
Color = clWhite
ForceNewColumn = False
ForceNewPage = False
Size.Values = (
50.2708333333333
949.854166666667)
BandType = rbDetail
object QRDBText1: TQRDBText
Left = 40
Top = 0
Width = 8
Height = 17
Frame.Color = clBlack
Frame.DrawTop = False
Frame.DrawBottom = False
Frame.DrawLeft = False
Frame.DrawRight = False
Size.Values = (
44.9791666666667
105.833333333333
0
21.1666666666667)
Alignment = taLeftJustify
AlignToBand = False
AutoSize = True
AutoStretch = False
Color = clWhite
DataSet = ADODataSet1
DataField = 'a'
Transparent = False
WordWrap = True
FontSize = 10
end
object QRDBText2: TQRDBText
Left = 192
Top = 0
Width = 8
Height = 17
Frame.Color = clBlack
Frame.DrawTop = False
Frame.DrawBottom = False
Frame.DrawLeft = False
Frame.DrawRight = False
Size.Values = (
44.9791666666667
508
0
21.1666666666667)
Alignment = taLeftJustify
AlignToBand = False
AutoSize = True
AutoStretch = False
Color = clWhite
DataSet = ADODataSet1
DataField = 'b'
Transparent = False
WordWrap = True
FontSize = 10
end
end
object PageFooterBand1: TQRBand
Left = 38
Top = 156
Width = 718
Height = 93
Frame.Color = clBlack
Frame.DrawTop = False
Frame.DrawBottom = False
Frame.DrawLeft = False
Frame.DrawRight = False
AlignToBottom = False
Color = clWhite
ForceNewColumn = False
ForceNewPage = False
Size.Values = (
246.0625
1899.70833333333)
BandType = rbPageFooter
object QRLabel1: TQRLabel
Left = 139
Top = 64
Width = 131
Height = 17
Frame.Color = clBlack
Frame.DrawTop = False
Frame.DrawBottom = False
Frame.DrawLeft = False
Frame.DrawRight = False
Size.Values = (
44.9791666666667
367.770833333333
169.333333333333
346.604166666667)
Alignment = taLeftJustify
AlignToBand = False
AutoSize = True
AutoStretch = False
Caption = 'SUM(ADODataSet1.b)'
Color = clWhite
Transparent = False
WordWrap = True
FontSize = 10
end
object QRExpr1: TQRExpr
Left = 307
Top = 64
Width = 131
Height = 17
Frame.Color = clBlack
Frame.DrawTop = False
Frame.DrawBottom = False
Frame.DrawLeft = False
Frame.DrawRight = False
Size.Values = (
44.9791666666667
812.270833333333
169.333333333333
346.604166666667)
Alignment = taLeftJustify
AlignToBand = False
AutoSize = True
AutoStretch = False
Color = clWhite
ResetAfterPrint = False
Transparent = False
WordWrap = True
Expression = 'SUM(ADODataSet1.b)'
FontSize = 10
end
end
end
object ADODataSet1: TADODataSet
Parameters = <>
Left = 40
Top = 24
object ADODataSet1a: TStringField
FieldName = 'a'
Size = 10
end
object ADODataSet1b: TIntegerField
FieldName = 'b'
end
end
end

 
Page.Columns = 2
 
我还是没看懂 怎么处理,有QQ吗? 我56130273 加我好吗
 
两个不同数据集的例子

unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, QuickRpt, ExtCtrls, QRCtrls;
type
TForm1 = class(TForm)
QuickRep1: TQuickRep;
ADODataSet1: TADODataSet;
ADODataSet1a: TStringField;
ADODataSet1b: TIntegerField;
QRStringsBand1: TQRStringsBand;
PageHeaderBand1: TQRBand;
PageFooterBand1: TQRBand;
QRLabel1: TQRLabel;
QRLabel2: TQRLabel;
QRDBText1: TQRDBText;
ADODataSet2: TADODataSet;
QRDBText2: TQRDBText;
ADODataSet2a: TStringField;
QRLabel3: TQRLabel;
procedure FormCreate(Sender: TObject);
procedure QRLabel1Print(sender: TObject;
var Value: string);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
i: integer;
begin
ADODataSet1.CreateDataSet;
ADODataSet1.Open;
for i := 1 to 65do
ADODataSet1.InsertRecord(['sad', i]);
ADODataSet2.CreateDataSet;
ADODataSet2.Open;
for i := 1 to 65do
ADODataSet2.InsertRecord(['DataSet2 ' +inttostr(i)]);
QuickRep1.Preview;
end;

procedure TForm1.QRLabel1Print(sender: TObject;
var Value: string);
begin
//Value := QRStringsBand1.Item;
ADODataSet1.RecNo := QRStringsBand1.Index + 1;
ADODataSet2.RecNo := QRStringsBand1.Index + 1;
end;

end.

object Form1: TForm1
Left = 192
Top = 103
Width = 544
Height = 375
VertScrollBar.Position = 590
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
Scaled = False
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object QuickRep1: TQuickRep
Left = 32
Top = 74
Width = 794
Height = 1123
Frame.Color = clBlack
Frame.DrawTop = False
Frame.DrawBottom = False
Frame.DrawLeft = False
Frame.DrawRight = False
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Arial'
Font.Style = []
Functions.Strings = (
'PAGENUMBER'
'COLUMNNUMBER'
'REPORTTITLE'
'QRSTRINGSBAND1')
Functions.DATA = (
'0'
'0'
''''''
'''''')
Options = [FirstPageHeader, LastPageFooter]
Page.Columns = 1
Page.Orientation = poPortrait
Page.PaperSize = A4
Page.Values = (
100
2970
100
2100
100
100
0)
PrinterSettings.Copies = 1
PrinterSettings.Duplex = False
PrinterSettings.FirstPage = 0
PrinterSettings.LastPage = 0
PrinterSettings.OutputBin = Auto
PrintIfEmpty = True
SnapToGrid = True
Units = MM
Zoom = 100
object QRStringsBand1: TQRStringsBand
Left = 38
Top = 118
Width = 718
Height = 40
Frame.Color = clBlack
Frame.DrawTop = False
Frame.DrawBottom = False
Frame.DrawLeft = False
Frame.DrawRight = False
AlignToBottom = False
Color = clWhite
ForceNewColumn = False
ForceNewPage = False
Size.Values = (
105.833333333333
1899.70833333333)
Items.Strings = (
'dfgsdfsdf'
'sdf'
'ds'
'f'
'ds'
'f'
'sd'
'f'
'ds'
'f'
'ds'
'f'
'ds'
'f')
PrintBefore = False
object QRLabel1: TQRLabel
Left = 16
Top = 16
Width = 58
Height = 17
Frame.Color = clBlack
Frame.DrawTop = False
Frame.DrawBottom = False
Frame.DrawLeft = False
Frame.DrawRight = False
Size.Values = (
44.9791666666667
42.3333333333333
42.3333333333333
153.458333333333)
Alignment = taLeftJustify
AlignToBand = False
AutoSize = True
AutoStretch = False
Caption = 'QRLabel1'
Color = clWhite
OnPrint = QRLabel1Print
Transparent = False
WordWrap = True
FontSize = 10
end
object QRDBText1: TQRDBText
Left = 112
Top = 16
Width = 8
Height = 17
Frame.Color = clBlack
Frame.DrawTop = False
Frame.DrawBottom = False
Frame.DrawLeft = False
Frame.DrawRight = False
Size.Values = (
44.9791666666667
296.333333333333
42.3333333333333
21.1666666666667)
Alignment = taLeftJustify
AlignToBand = False
AutoSize = True
AutoStretch = False
Color = clWhite
DataSet = ADODataSet1
DataField = 'b'
Transparent = False
WordWrap = True
FontSize = 10
end
object QRDBText2: TQRDBText
Left = 352
Top = 8
Width = 169
Height = 17
Frame.Color = clBlack
Frame.DrawTop = False
Frame.DrawBottom = False
Frame.DrawLeft = False
Frame.DrawRight = False
Size.Values = (
44.9791666666667
931.333333333333
21.1666666666667
447.145833333333)
Alignment = taLeftJustify
AlignToBand = False
AutoSize = False
AutoStretch = False
Color = clWhite
DataSet = ADODataSet2
DataField = 'a'
Transparent = False
WordWrap = True
FontSize = 10
end
end
object PageHeaderBand1: TQRBand
Left = 38
Top = 38
Width = 718
Height = 40
Frame.Color = clBlack
Frame.DrawTop = False
Frame.DrawBottom = False
Frame.DrawLeft = False
Frame.DrawRight = False
AlignToBottom = False
Color = clWhite
ForceNewColumn = False
ForceNewPage = False
Size.Values = (
105.833333333333
1899.70833333333)
BandType = rbPageHeader
object QRLabel3: TQRLabel
Left = 328
Top = 16
Width = 17
Height = 17
Frame.Color = clBlack
Frame.DrawTop = False
Frame.DrawBottom = False
Frame.DrawLeft = False
Frame.DrawRight = False
Size.Values = (
44.9791666666667
867.833333333333
42.3333333333333
44.9791666666667)
Alignment = taLeftJustify
AlignToBand = False
AutoSize = True
AutoStretch = False
Caption = '头'
Color = clWhite
Transparent = False
WordWrap = True
FontSize = 10
end
end
object PageFooterBand1: TQRBand
Left = 38
Top = 78
Width = 718
Height = 40
Frame.Color = clBlack
Frame.DrawTop = False
Frame.DrawBottom = False
Frame.DrawLeft = False
Frame.DrawRight = False
AlignToBottom = False
Color = clWhite
ForceNewColumn = False
ForceNewPage = False
Size.Values = (
105.833333333333
1899.70833333333)
BandType = rbPageFooter
object QRLabel2: TQRLabel
Left = 352
Top = 16
Width = 17
Height = 17
Frame.Color = clBlack
Frame.DrawTop = False
Frame.DrawBottom = False
Frame.DrawLeft = False
Frame.DrawRight = False
Size.Values = (
44.9791666666667
931.333333333333
42.3333333333333
44.9791666666667)
Alignment = taLeftJustify
AlignToBand = False
AutoSize = True
AutoStretch = False
Caption = '尾'
Color = clWhite
Transparent = False
WordWrap = True
FontSize = 10
end
end
end
object ADODataSet1: TADODataSet
Parameters = <>
Left = 40
Top = 24
object ADODataSet1a: TStringField
FieldName = 'a'
Size = 10
end
object ADODataSet1b: TIntegerField
FieldName = 'b'
end
end
object ADODataSet2: TADODataSet
Parameters = <>
Left = 128
Top = 24
object ADODataSet2a: TStringField
FieldName = 'a'
Size = 30
end
end
end



 
我看了你这样处理
不对
你的a和b是一个表里面的 只是把报表分成2快处理了。
我的材料和工时是不同表 都有循环。。
 
你用QuickRep迟早会出问题.
 
转Fastreport吧!我只转过两天就感到其比Qreport的优越性了!Qreport太累也不方便!
 
不知道有没有理解错,其实你就是想在报表里显示两个query或者table里的内容是吧?
那就在quickrep里的onNeedData里手工写代码就行了,不会很复杂的。
在quickrep上放一个QRBand,BandType 设为 rbTitle,在上面放上
产品编码 NO—12345
-------------------------------------
材料编码 |材料价格|材料数量| 工时编码|工时|
再放一个QRBand ,BandType 设为 rbDetail,再扔一些qrlabel,然后在quickrep里的onNeedData人工给这些qrlabel赋值。比如:
procedure TForm1.QuickRep1NeedData(Sender: TObject;
var MoreData: Boolean);
begin
if not query1.Eof then
begin
qrlab1.Caption := query1.FieldbyName('材料编码').AsString;
qrlab2.Caption := query1.FieldByName('材料价格').AsString;
qrlab3.Caption := query1.FieldByName('材料数量').AsString;
query1.Next;
end
else
begin
qrlab1.Caption := '';
qrlab2.Caption := '';
qrlab3.Caption := '';
end;

if not query2.Eof then
begin
qrlab4.Caption := query2.FieldByName('工时编码').AsString;
qrlab5.Caption := query2.FieldByName('工时').AsString;
query2.Next;
end
else
begin
qrlab4.Caption := '';
qrlab5.Caption := '';
end;

if query1.RecordCount > query2.RecordCount then
MoreData := not query1.Eof
else
MoreData := not query2.Eof;
end;
记得要在beforeprint里把query置为first
procedure TForm1.QuickRep1BeforePrint(Sender: TCustomQuickRep;
var PrintReport: Boolean);
begin
query1.First;
query2.First;
end;

还有,quickrep 的dataset属性要设为nil,不知道能否对你有些帮助,^_^
 
两个不同数据集的例子
使用了两个数据集
 
object QRDBText1: TQRDBText
DataSet = ADODataSet1
DataField = 'b'
end
object QRDBText2: TQRDBText
DataSet = ADODataSet2
 
好象没什么难度嘛,你的控件的数据源应该是运行时绑定的吧,中间的两栏根本不要去管它,就当作一栏,然后在指定运行时的绑定数据源的时候绑定不同的表,作为DETAL和第一页的GROUP绑定不就行了
 
后退
顶部