Q&A

  • 그룹헤더에 소계를 출력하는 방법은??
질문과 같이 그룹헤더에 소계가 나타나게 하면 해결이 될듯 싶습니다.
데이터셋 그리고 그룹밴드를 사용하였습니다.
그룹헤더에 소계가 필요한것은 선택 출력시 그룹헤더의 사용여부를 판단하기 위해서 입니다.
건수가 0건 이상일때만 그룹헤더에 출력하려고 하는데 이벤트 순서가 그룹헤더 후에 디테일이 출력되니 헤더에 소계가 원하는 값이 나오지 않습니다.
그룹이벤트를 재호출 할수도 없는것 같고해서.
이런경우에 어떻게 하면 되는지 알려주시면 감사하겠습니다.
수고하세요~  
1  COMMENTS
  • Profile
    nilriri™ 2006.11.11 01:19
    퀵레포트라면...     QuickRep1.Prepare 를 이용하시면 될듯 싶습니다.

    그리고 기본적으로 그룹헤더는 디테일벤드가 존재할때만 찍히는 거구요..

    디테일이 없이 그룹헤더가 찍힌다면 뭔가 다른 버그일듯 싶습니다...^^


    아래는 간단한 테스트 셈플의 pas소스 입니다.

    <!--CodeS-->

    unit Unit1;

    interface

    uses
       Windows,
       Messages,
       SysUtils,
       Variants,
       Classes,
       Graphics,
       Controls,
       Forms,
       Dialogs,
       DB,
       DBTables,
       QRCtrls,
       QuickRpt,
       ExtCtrls,
       StdCtrls;

    type
       TForm1 = class(TForm)
          QuickRep1 : TQuickRep;
          DetailBand1 : TQRBand;
          PageHeaderBand1 : TQRBand;
          PageFooterBand1 : TQRBand;
          ColumnHeaderBand1 : TQRBand;
          SummaryBand1 : TQRBand;
          TitleBand1 : TQRBand;
          QRLabel1 : TQRLabel;
          QRLabel2 : TQRLabel;
          QRLabel3 : TQRLabel;
          QRLabel4 : TQRLabel;
          QRLabel5 : TQRLabel;
          QRLabel6 : TQRLabel;
          QRBand1 : TQRBand;
          QRGroup1 : TQRGroup;
          QRLabel7 : TQRLabel;
          QRLabel8 : TQRLabel;
          QRDBText1 : TQRDBText;
          QRDBText2 : TQRDBText;
          QRExpr1 : TQRExpr;
          Query1 : TQuery;
          Button1 : TButton;
          QRLabel9 : TQRLabel;
          procedure Button1Click(Sender : TObject);
          procedure QRLabel9Print(sender : TObject; var Value : string);
          procedure QRExpr1Print(sender : TObject; var Value : string);
          procedure QuickRep1BeforePrint(Sender : TCustomQuickRep;
             var PrintReport : Boolean);
          procedure QRGroup1BeforePrint(Sender : TQRCustomBand;
             var PrintBand : Boolean);
          procedure FormClose(Sender : TObject; var Action : TCloseAction);
          procedure FormCreate(Sender : TObject);
       private
          { Private declarations }
          idx : integer;
          isPrepare : boolean;
          list : TStrings;
       public
          { Public declarations }
       end;

    var
       Form1 : TForm1;

    implementation

    {$R *.dfm}

    procedure TForm1.Button1Click(Sender : TObject);
    begin
       isPrepare := True;
       self.QuickRep1.Prepare;

       isPrepare := False;

       self.QuickRep1.PreviewModal;
    end;

    procedure TForm1.QRLabel9Print(sender : TObject; var Value : string);
    begin
       if List.Count > idx then
          Value := List.Strings[idx];
    end;

    procedure TForm1.QRExpr1Print(sender : TObject; var Value : string);
    begin
       List.Add(Value);
    end;

    procedure TForm1.QuickRep1BeforePrint(Sender : TCustomQuickRep;
       var PrintReport : Boolean);
    begin
       if isPrepare then
          List.Clear;
          
       idx := -1;
    end;

    procedure TForm1.QRGroup1BeforePrint(Sender : TQRCustomBand;
       var PrintBand : Boolean);
    begin
       idx := idx + 1;
    end;

    procedure TForm1.FormClose(Sender : TObject; var Action : TCloseAction);
    begin
       List.Clear;
       List.Free;
    end;

    procedure TForm1.FormCreate(Sender : TObject);
    begin
       list := TStringList.Create;
    end;

    end.


    <!--CodeE-->

    dfm파일 내용 ^^


    object Form1: TForm1
      Left = 344
      Top = 152
      Width = 870
      Height = 640
      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
      OnClose = FormClose
      OnCreate = FormCreate
      PixelsPerInch = 96
      TextHeight = 13
      object QuickRep1: TQuickRep
        Left = 55
        Top = 87
        Width = 794
        Height = 1123
        Frame.Color = clBlack
        Frame.DrawTop = False
        Frame.DrawBottom = False
        Frame.DrawLeft = False
        Frame.DrawRight = False
        BeforePrint = QuickRep1BeforePrint
        DataSet = Query1
        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 = 1
        Page.Orientation = poPortrait
        Page.PaperSize = A4
        Page.Values = (
          100.000000000000000000
          2970.000000000000000000
          100.000000000000000000
          2100.000000000000000000
          100.000000000000000000
          100.000000000000000000
          0.000000000000000000)
        PrinterSettings.Copies = 1
        PrinterSettings.OutputBin = Auto
        PrinterSettings.Duplex = False
        PrinterSettings.FirstPage = 0
        PrinterSettings.LastPage = 0
        PrinterSettings.ExtendedDuplex = 0
        PrinterSettings.UseStandardprinter = False
        PrinterSettings.UseCustomBinCode = False
        PrinterSettings.CustomBinCode = 0
        PrinterSettings.UseCustomPaperCode = False
        PrinterSettings.CustomPaperCode = 0
        PrinterSettings.PrintMetaFile = False
        PrintIfEmpty = True
        SnapToGrid = True
        Units = MM
        Zoom = 100
        PrevFormStyle = fsNormal
        PreviewInitialState = wsNormal
        object DetailBand1: TQRBand
          Left = 38
          Top = 198
          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.833333333333300000
            1899.708333333333000000)
          BandType = rbDetail
          object QRLabel4: TQRLabel
            Left = 8
            Top = 12
            Width = 34
            Height = 17
            Frame.Color = clBlack
            Frame.DrawTop = False
            Frame.DrawBottom = False
            Frame.DrawLeft = False
            Frame.DrawRight = False
            Size.Values = (
              44.979166666666670000
              21.166666666666670000
              31.750000000000000000
              89.958333333333340000)
            Alignment = taLeftJustify
            AlignToBand = False
            AutoSize = True
            AutoStretch = False
            Caption = 'Detail'
            Color = clWhite
            Transparent = True
            WordWrap = True
            FontSize = 10
          end
          object QRDBText1: TQRDBText
            Left = 248
            Top = 13
            Width = 72
            Height = 17
            Frame.Color = clBlack
            Frame.DrawTop = False
            Frame.DrawBottom = False
            Frame.DrawLeft = False
            Frame.DrawRight = False
            Size.Values = (
              44.979166666666670000
              656.166666666666800000
              34.395833333333340000
              190.500000000000000000)
            Alignment = taLeftJustify
            AlignToBand = False
            AutoSize = True
            AutoStretch = False
            Color = clWhite
            DataSet = Query1
            DataField = 'AmountPaid'
            Transparent = True
            WordWrap = True
            FontSize = 10
          end
          object QRDBText2: TQRDBText
            Left = 150
            Top = 13
            Width = 44
            Height = 17
            Frame.Color = clBlack
            Frame.DrawTop = False
            Frame.DrawBottom = False
            Frame.DrawLeft = False
            Frame.DrawRight = False
            Size.Values = (
              44.979166666666670000
              396.875000000000000000
              34.395833333333340000
              116.416666666666700000)
            Alignment = taLeftJustify
            AlignToBand = False
            AutoSize = True
            AutoStretch = False
            Color = clWhite
            DataSet = Query1
            DataField = 'CustNo'
            Transparent = True
            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 = 13688765
          ForceNewColumn = False
          ForceNewPage = False
          Size.Values = (
            105.833333333333300000
            1899.708333333333000000)
          BandType = rbPageHeader
          object QRLabel1: TQRLabel
            Left = 8
            Top = 12
            Width = 72
            Height = 17
            Frame.Color = clBlack
            Frame.DrawTop = False
            Frame.DrawBottom = False
            Frame.DrawLeft = False
            Frame.DrawRight = False
            Size.Values = (
              44.979166666666670000
              21.166666666666670000
              31.750000000000000000
              190.500000000000000000)
            Alignment = taLeftJustify
            AlignToBand = False
            AutoSize = True
            AutoStretch = False
            Caption = 'PageHeader'
            Color = clWhite
            Transparent = True
            WordWrap = True
            FontSize = 10
          end
        end
        object PageFooterBand1: TQRBand
          Left = 38
          Top = 318
          Width = 718
          Height = 40
          Frame.Color = clBlack
          Frame.DrawTop = False
          Frame.DrawBottom = False
          Frame.DrawLeft = False
          Frame.DrawRight = False
          AlignToBottom = False
          Color = 13688765
          ForceNewColumn = False
          ForceNewPage = False
          Size.Values = (
            105.833333333333300000
            1899.708333333333000000)
          BandType = rbPageFooter
          object QRLabel6: TQRLabel
            Left = 8
            Top = 12
            Width = 68
            Height = 17
            Frame.Color = clBlack
            Frame.DrawTop = False
            Frame.DrawBottom = False
            Frame.DrawLeft = False
            Frame.DrawRight = False
            Size.Values = (
              44.979166666666670000
              21.166666666666670000
              31.750000000000000000
              179.916666666666700000)
            Alignment = taLeftJustify
            AlignToBand = False
            AutoSize = True
            AutoStretch = False
            Caption = 'PageFooter'
            Color = clWhite
            Transparent = True
            WordWrap = True
            FontSize = 10
          end
        end
        object ColumnHeaderBand1: TQRBand
          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 = 14680047
          ForceNewColumn = False
          ForceNewPage = False
          Size.Values = (
            105.833333333333300000
            1899.708333333333000000)
          BandType = rbColumnHeader
          object QRLabel3: TQRLabel
            Left = 8
            Top = 7
            Width = 86
            Height = 17
            Frame.Color = clBlack
            Frame.DrawTop = False
            Frame.DrawBottom = False
            Frame.DrawLeft = False
            Frame.DrawRight = False
            Size.Values = (
              44.979166666666670000
              21.166666666666670000
              18.520833333333330000
              227.541666666666700000)
            Alignment = taLeftJustify
            AlignToBand = False
            AutoSize = True
            AutoStretch = False
            Caption = 'ColumnHeader'
            Color = clWhite
            Transparent = True
            WordWrap = True
            FontSize = 10
          end
        end
        object SummaryBand1: TQRBand
          Left = 38
          Top = 278
          Width = 718
          Height = 40
          Frame.Color = clBlack
          Frame.DrawTop = False
          Frame.DrawBottom = False
          Frame.DrawLeft = False
          Frame.DrawRight = False
          AlignToBottom = False
          Color = 11599871
          ForceNewColumn = False
          ForceNewPage = False
          Size.Values = (
            105.833333333333300000
            1899.708333333333000000)
          BandType = rbSummary
          object QRLabel5: TQRLabel
            Left = 8
            Top = 12
            Width = 57
            Height = 17
            Frame.Color = clBlack
            Frame.DrawTop = False
            Frame.DrawBottom = False
            Frame.DrawLeft = False
            Frame.DrawRight = False
            Size.Values = (
              44.979166666666670000
              21.166666666666670000
              31.750000000000000000
              150.812500000000000000)
            Alignment = taLeftJustify
            AlignToBand = False
            AutoSize = True
            AutoStretch = False
            Caption = 'Summary'
            Color = clWhite
            Transparent = True
            WordWrap = True
            FontSize = 10
          end
        end
        object TitleBand1: 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 = 16765650
          ForceNewColumn = False
          ForceNewPage = False
          Size.Values = (
            105.833333333333300000
            1899.708333333333000000)
          BandType = rbTitle
          object QRLabel2: TQRLabel
            Left = 8
            Top = 12
            Width = 25
            Height = 17
            Frame.Color = clBlack
            Frame.DrawTop = False
            Frame.DrawBottom = False
            Frame.DrawLeft = False
            Frame.DrawRight = False
            Size.Values = (
              44.979166666666670000
              21.166666666666670000
              31.750000000000000000
              66.145833333333340000)
            Alignment = taLeftJustify
            AlignToBand = False
            AutoSize = True
            AutoStretch = False
            Caption = 'Title'
            Color = clWhite
            Transparent = True
            WordWrap = True
            FontSize = 10
          end
        end
        object QRBand1: TQRBand
          Left = 38
          Top = 238
          Width = 718
          Height = 40
          Frame.Color = clBlack
          Frame.DrawTop = False
          Frame.DrawBottom = False
          Frame.DrawLeft = False
          Frame.DrawRight = False
          AlignToBottom = False
          Color = 13820415
          ForceNewColumn = False
          ForceNewPage = False
          Size.Values = (
            105.833333333333300000
            1899.708333333333000000)
          BandType = rbGroupFooter
          object QRLabel8: TQRLabel
            Left = 8
            Top = 7
            Width = 73
            Height = 17
            Frame.Color = clBlack
            Frame.DrawTop = False
            Frame.DrawBottom = False
            Frame.DrawLeft = False
            Frame.DrawRight = False
            Size.Values = (
              44.979166666666670000
              21.166666666666670000
              18.520833333333330000
              193.145833333333300000)
            Alignment = taLeftJustify
            AlignToBand = False
            AutoSize = True
            AutoStretch = False
            Caption = 'GroupFooter'
            Color = clWhite
            Transparent = True
            WordWrap = True
            FontSize = 10
          end
          object QRExpr1: TQRExpr
            Left = 248
            Top = 12
            Width = 101
            Height = 17
            Frame.Color = clBlack
            Frame.DrawTop = False
            Frame.DrawBottom = False
            Frame.DrawLeft = False
            Frame.DrawRight = False
            Size.Values = (
              44.979166666666670000
              656.166666666666800000
              31.750000000000000000
              267.229166666666700000)
            Alignment = taLeftJustify
            AlignToBand = False
            AutoSize = True
            AutoStretch = False
            Color = clWhite
            OnPrint = QRExpr1Print
            ResetAfterPrint = True
            Transparent = True
            WordWrap = True
            Expression = 'sum(amountpaid)'
            FontSize = 10
          end
        end
        object QRGroup1: TQRGroup
          Left = 38
          Top = 158
          Width = 718
          Height = 40
          Frame.Color = clBlack
          Frame.DrawTop = False
          Frame.DrawBottom = False
          Frame.DrawLeft = False
          Frame.DrawRight = False
          AlignToBottom = False
          BeforePrint = QRGroup1BeforePrint
          Color = 13820415
          ForceNewColumn = False
          ForceNewPage = False
          Size.Values = (
            105.833333333333300000
            1899.708333333333000000)
          Expression = 'custno'
          FooterBand = QRBand1
          Master = QuickRep1
          ReprintOnNewPage = False
          object QRLabel7: TQRLabel
            Left = 7
            Top = 7
            Width = 77
            Height = 17
            Frame.Color = clBlack
            Frame.DrawTop = False
            Frame.DrawBottom = False
            Frame.DrawLeft = False
            Frame.DrawRight = False
            Size.Values = (
              44.979166666666670000
              18.520833333333330000
              18.520833333333330000
              203.729166666666700000)
            Alignment = taLeftJustify
            AlignToBand = False
            AutoSize = True
            AutoStretch = False
            Caption = 'GroupHeader'
            Color = clWhite
            Transparent = True
            WordWrap = True
            FontSize = 10
          end
          object QRLabel9: TQRLabel
            Left = 246
            Top = 12
            Width = 105
            Height = 17
            Frame.Color = clBlack
            Frame.DrawTop = False
            Frame.DrawBottom = False
            Frame.DrawLeft = False
            Frame.DrawRight = False
            Size.Values = (
              44.979166666666670000
              650.875000000000000000
              31.750000000000000000
              277.812500000000000000)
            Alignment = taLeftJustify
            AlignToBand = False
            AutoSize = False
            AutoStretch = False
            Caption = 'QRLabel9'
            Color = clWhite
            OnPrint = QRLabel9Print
            Transparent = True
            WordWrap = True
            FontSize = 10
          end
        end
      end
      object Button1: TButton
        Left = 132
        Top = 26
        Width = 75
        Height = 25
        Caption = 'Button1'
        TabOrder = 1
        OnClick = Button1Click
      end
      object Query1: TQuery
        Active = True
        DatabaseName = 'DBDEMOS'
        SQL.Strings = (
          'select custno, empno, amountpaid from orders'
          'order by custno')
        Left = 63
        Top = 31
      end
    end