Fórum Qreport - Total por folha #262725

20/12/2004

0

Ola

Caros colegas preciso mais uma vez de ajuda. Tenho um relatório que tem de mostrar a quantidade total de produtos por folha, Isto é, cada folha impressa tem que mostrar o total apenas da folha. Como faço isso no quickreport ?

Grato

Marcos Roberto


Marcosrodias

Marcosrodias

Responder

Posts

20/12/2004

Gandalf.nho

Pelo que sei, isso não é possível. Diretamente só é possível total geral e total por grupo. Talvez via código seja possível implementar uma solução, mas a desconheço.


Responder

Gostei + 0

21/12/2004

Marcosrodias

sobe


Responder

Gostei + 0

21/12/2004

Alexandresbo2

Caro colega faz tempo que naum uso o quick(estou trabalhando com fortes no momento) e naum tenho certeza mas pelo que entendi ,naum dá certo vc colocar uma banda rbPagefootter e dentro dela um componente qrexpr ? pois se naum me engano rbPagefootter sai no final de cada pagina


Responder

Gostei + 0

21/12/2004

Gandalf.nho

QrExpr não funciona em banda rodapé de página.


Responder

Gostei + 0

26/12/2004

Carlosrm

marcosrodias,

desculpe se esta opção dá mão de obra (digitação), mas para mim tem resolvido.
No QuickReport crie uma variável pública (na seção interface) que armazenará os totais por página, valendo 0 (por ex: var_total_por_folha := 0; ).
No evento BeforPrint da rbPageHeader (ou qualquer outra banda que se repita a cada mudança de página, ANTES de imprimir a banda de detalhes), zere novamente esta variável.
Agora, no evento AfterPrint da banda detalhe (rbDetail, após imprimir uma linha), atualize o valor da variável que você criou:
var_total_por_folha := var_total_por_folha + var_valor_a_somar;
Agora, aproveitando as informações do AlexandresBo2 e gandalf.nho, coloque um rbPageFooter, mas NÃO um qrExpr... use um qrlabel para exibir o resultado (var_total_por_folha acumulado até agora). Como o rgPage Footer só será impresso no final de cada página/folha - antes de saltar para a próxima, exibirá corretamente o total dessa página.
E quando mudar para outra página? Já nos prevenimos, setando novamente esta variável em zero (var_total_por_folha := 0; ´No evento BeforPrint da rbPageHeader...´).

De quebra, se quiser saber o total geral (soma de todas as páginas/registros) basta criar uma segunda variável, mas que não seja zerada a cada mudança de pagina e seja exibida somente na última página (rbSummary).

Minha explicação está meio confusa, eu sei, mas é muito mais fácil de fazer do que explicar. Siga este roteiro, linha por linha, e verá que é tranquilo. Se esqueci alguma informação pertinente, gostaria de saber.
Conto com a colaboração dos colegas, inclusive pra sugerirem alternativas mais eficazes.

carlosrm :wink:


Responder

Gostei + 0

26/12/2004

Adilsond

Fiz um pequeno exemplo com delphi 3 e com BDE (DBDemos).

program Project1;

uses
  Forms,
  Unit1 in ´Unit1.pas´ ,
  Unit2 in ´Unit2.pas´ {QuickReport2: TQuickRep};

{$R *.RES}

begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.


unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses Unit2;

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
  QuickReport2 := TQuickReport2.Create(Self);
  try
    QuickReport2.DataSet.Open;
    try
      QuickReport2.Preview;
    finally
      QuickReport2.DataSet.Close;
    end;
  finally
    QuickReport2.Free;
    QuickReport2 := nil;
  end;
end;

end.


object Form1: TForm1
  Left = 200
  Top = 108
  Width = 544
  Height = 375
  Caption = ´Form1´
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = ´MS Sans Serif´
  Font.Style = []
  PixelsPerInch = 96
  TextHeight = 13
  object Button1: TButton
    Left = 128
    Top = 72
    Width = 75
    Height = 25
    Caption = ´Button1´
    TabOrder = 0
    OnClick = Button1Click
  end
end


unit Unit2;

interface

uses Windows, SysUtils, Messages, Classes, Graphics, Controls,
  StdCtrls, ExtCtrls, Forms, Quickrpt, QRCtrls, Db, DBTables;

type
  TQuickReport2 = class(TQuickRep)
    Table1: TTable;
    Table1EmpNo: TIntegerField;
    Table1LastName: TStringField;
    Table1FirstName: TStringField;
    Table1PhoneExt: TStringField;
    Table1HireDate: TDateTimeField;
    Table1Salary: TFloatField;
    PageHeaderBand1: TQRBand;
    QRSysData1: TQRSysData;
    DetailBand1: TQRBand;
    PageFooterBand1: TQRBand;
    QRExpr1: TQRExpr;
    QRDBText1: TQRDBText;
    QRDBText2: TQRDBText;
    QRDBText3: TQRDBText;
    procedure QRExpr1Print(sender: TObject; var Value: String);
  private

  public

  end;

var
  QuickReport2: TQuickReport2;

implementation

{$R *.DFM}

procedure TQuickReport2.QRExpr1Print(sender: TObject; var Value: String);
begin
  Value := ´Total desta página: ´ + Value;
end;

end.


object QuickReport2: TQuickReport2
  Left = 0
  Top = 0
  Width = 794
  Height = 1123
  Frame.Color = clBlack
  Frame.DrawTop = False
  Frame.DrawBottom = False
  Frame.DrawLeft = False
  Frame.DrawRight = False
  DataSet = Table1
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -13
  Font.Name = ´Arial´
  Font.Style = []
  Options = [FirstPageHeader, LastPageFooter]
  Page.Columns = 1
  Page.Orientation = poPortrait
  Page.PaperSize = A4
  Page.Values = (
    100
    2970
    100
    2100
    100
    100
    0)
  PrintIfEmpty = False
  PrinterSettings.Copies = 1
  PrinterSettings.Duplex = False
  PrinterSettings.FirstPage = 0
  PrinterSettings.LastPage = 0
  PrinterSettings.OutputBin = First
  ReportTitle = ´Teste de Impressão [Total por página]´
  SnapToGrid = True
  Units = MM
  Zoom = 100
  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 QRSysData1: TQRSysData
      Left = 323
      Top = 8
      Width = 72
      Height = 17
      Frame.Color = clBlack
      Frame.DrawTop = False
      Frame.DrawBottom = False
      Frame.DrawLeft = False
      Frame.DrawRight = False
      Size.Values = (
        44.9791666666667
        854.604166666667
        21.1666666666667
        190.5)
      Alignment = taCenter
      AlignToBand = True
      AutoSize = True
      Color = clWhite
      Data = qrsReportTitle
      Transparent = False
      FontSize = 10
    end
  end
  object DetailBand1: 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 = rbDetail
    object QRDBText1: TQRDBText
      Left = 8
      Top = 8
      Width = 44
      Height = 17
      Frame.Color = clBlack
      Frame.DrawTop = False
      Frame.DrawBottom = False
      Frame.DrawLeft = False
      Frame.DrawRight = False
      Size.Values = (
        44.9791666666667
        21.1666666666667
        21.1666666666667
        116.416666666667)
      Alignment = taLeftJustify
      AlignToBand = False
      AutoSize = True
      AutoStretch = False
      Color = clWhite
      DataSet = Table1
      DataField = ´EmpNo´
      Transparent = False
      WordWrap = True
      FontSize = 10
    end
    object QRDBText2: TQRDBText
      Left = 80
      Top = 8
      Width = 61
      Height = 17
      Frame.Color = clBlack
      Frame.DrawTop = False
      Frame.DrawBottom = False
      Frame.DrawLeft = False
      Frame.DrawRight = False
      Size.Values = (
        44.9791666666667
        211.666666666667
        21.1666666666667
        161.395833333333)
      Alignment = taLeftJustify
      AlignToBand = False
      AutoSize = True
      AutoStretch = False
      Color = clWhite
      DataSet = Table1
      DataField = ´FirstName´
      Transparent = False
      WordWrap = True
      FontSize = 10
    end
    object QRDBText3: TQRDBText
      Left = 304
      Top = 8
      Width = 60
      Height = 17
      Frame.Color = clBlack
      Frame.DrawTop = False
      Frame.DrawBottom = False
      Frame.DrawLeft = False
      Frame.DrawRight = False
      Size.Values = (
        44.9791666666667
        804.333333333333
        21.1666666666667
        158.75)
      Alignment = taLeftJustify
      AlignToBand = False
      AutoSize = True
      AutoStretch = False
      Color = clWhite
      DataSet = Table1
      DataField = ´LastName´
      Transparent = False
      WordWrap = True
      FontSize = 10
    end
  end
  object PageFooterBand1: 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 = clWhite
    ForceNewColumn = False
    ForceNewPage = False
    Size.Values = (
      105.833333333333
      1899.70833333333)
    BandType = rbPageFooter
    object QRExpr1: TQRExpr
      Left = 24
      Top = 8
      Width = 45
      Height = 17
      Frame.Color = clBlack
      Frame.DrawTop = False
      Frame.DrawBottom = False
      Frame.DrawLeft = False
      Frame.DrawRight = False
      Size.Values = (
        44.9791666666667
        63.5
        21.1666666666667
        119.0625)
      Alignment = taLeftJustify
      AlignToBand = False
      AutoSize = True
      AutoStretch = False
      Color = clWhite
      Master = Owner
      OnPrint = QRExpr1Print
      ResetAfterPrint = True
      Transparent = False
      WordWrap = True
      Expression = ´COUNT´
      FontSize = 10
    end
  end
  object Table1: TTable
    DatabaseName = ´DBDEMOS´
    SessionName = ´Default´
    TableName = ´employee.db´
    Left = 8
    object Table1EmpNo: TIntegerField
      FieldName = ´EmpNo´
    end
    object Table1LastName: TStringField
      FieldName = ´LastName´
    end
    object Table1FirstName: TStringField
      FieldName = ´FirstName´
      Size = 15
    end
    object Table1PhoneExt: TStringField
      FieldName = ´PhoneExt´
      Size = 4
    end
    object Table1HireDate: TDateTimeField
      FieldName = ´HireDate´
    end
    object Table1Salary: TFloatField
      FieldName = ´Salary´
    end
  end
end



Responder

Gostei + 0

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar