Fórum QReport XML #292332
19/08/2005
0
Quero fazer um relatório no QReport a partir de uma base de dados XML.
Mostrando o relatorio nesse formato:[/b:b57bd0714e]
Relatorio de Clientes ---------------------------------------- Nome: JOAO SANTOS Endereco: RUA TAL Numero: 10 Bairro: CENTRO Estado: PR Cidade: MARINGÁ Pais: Brasil Cnpj: 000000000000 Status: Ativo ---------------------------------------- Nome: JOAO SANTOS Endereco: RUA TAL Numero: 10 Bairro: CENTRO Estado: PR Cidade: MARINGÁ Pais: Brasil Cnpj: 000000000000 Status: Ativo ---------------------------------------- Nome: JOAO SANTOS Endereco: RUA TAL Numero: 10 Bairro: CENTRO Estado: PR Cidade: MARINGÁ Pais: Brasil Cnpj: 000000000000 Status: Ativo ----------------------------------------
[color=green:b57bd0714e]
[b:b57bd0714e]Coloquei esse código na Detail, queria que ele mostrasse desse jeito, sem ter que colocar varias bands...[/b:b57bd0714e][/color:b57bd0714e]
procedure TFQR.Imprime(XMLDocument :TXMLDocument); var Clientes : IXMLClientesType; Cliente : IXMLClienteType; i : Integer; begin Clientes:= GetClientes(XMLDocument); for i:=0 to Clientes.Count-1 do begin Cliente := Clientes.Cliente[i]; QRLabel1.Caption := Cliente.Nome; QRLabel2.Caption := Cliente.Endereco; QRLabel3.Caption := IntToStr(Cliente.No); QRLabel4.Caption := Cliente.Bairro; QRLabel5.Caption := Cliente.Cidade; QRLabel6.Caption := Cliente.Pais; QRLabel7.Caption := Cliente.Cnpj; QRLabel8.Caption := Cliente.Status; end; QuickRep1.Preview; end;
[b:b57bd0714e]Pensei em algo no beforePrint da banda, [color=orange:b57bd0714e]Alguma idéia?[/color:b57bd0714e][/b:b57bd0714e]
Michelli88
Curtir tópico
+ 0Posts
19/08/2005
Michelli88
Entao, usei a StringsBand, e o QRExpr para imprimir.
Coloca o [b:021c75e392]QRExpr [/b:021c75e392]dentro do [b:021c75e392]StringsBand[/b:021c75e392], e na propriedade ´Expression´ do QRExpr, coloca o nome do StringBand.
A StringBand imprime o que armazenamos na propriedade items.
Por exemplo: Maria, João, José, Carlos
Porem eu precisava de imprimir varias listas e não uma só.
Para resolver isso, eu mandei imprimir uma lista, a de nome por exemplo. E no evento beforePrint da StringBand, eu mandei os outros QrLabels receber o dado desejado... Deu certo!
[b:021c75e392]o código ficou assim: [/b:021c75e392]
procedure TFQR.FormCreate(Sender: TObject); var lista : TStringList; i : Integer; begin lista:=TStringList.Create; Clientes:= GetClientes(XMLDocument1); for i := 0 to Clientes.Count-1 do begin Cliente := Clientes.Cliente[i]; //aqui adicionei os itens da lista lista.Add(Cliente.Nome); QRStringsBand1.Items:=lista; end; lista.Free; end;
procedure TFQR.QRStringsBand1BeforePrint(Sender: TQRCustomBand; var PrintBand: Boolean); begin QRLabel1.Caption := Cliente.Nome; QRLabel2.Caption := Cliente.Endereco; QRLabel3.Caption := IntToStr(Cliente.No); QRLabel4.Caption := Cliente.Bairro; QRLabel5.Caption := Cliente.Cidade; QRLabel6.Caption := Cliente.Pais; QRLabel7.Caption := Cliente.Cnpj; QRLabel8.Caption := Cliente.Status; end;
[color=violet:021c75e392][b:021c75e392][size=18:021c75e392]No fim, o resultado foi exatamente o desejado:[/size:021c75e392][/b:021c75e392]
[/color:021c75e392]
[size=18:021c75e392][color=blue:021c75e392]Quer quizer o tutorial que usei está neste link: [/color:021c75e392][url=https://www.devmedia.com.br/curso/relatorios/moduloIresumo.pdf] Tutorial do Quick Report[/url][/size:021c75e392]
Gostei + 0
19/08/2005
Michelli88
procedure TFQR.FormCreate; var i : Integer; begin Clientes:= GetClientes(XMLDocument1); for i := 0 to Clientes.Count-1 do begin StringBand.Items.Add(InttoStr(i)); end; end;
procedure TFQR.StringbandBeforePrint(Sender: TQRCustomBand; var PrintBand: Boolean); begin LNome.Caption :=Clientes.Cliente[StrToInt(StringBand.Item)].Nome; LEndereco.Caption:=Clientes.Cliente[StrToInt(StringBand.Item)].Endereco; LBairro.Caption :=Clientes.Cliente[StrToInt(StringBand.Item)].Bairro; LCidade.Caption :=Clientes.Cliente[StrToInt(StringBand.Item)].Cidade; LCpf.Caption :=Clientes.Cliente[StrToInt(StringBand.Item)].Cnpj; LNo.Caption :=Clientes.Cliente[StrToInt(StringBand.Item)].Estado; LPais.Caption :=Clientes.Cliente[StrToInt(StringBand.Item)].Pais; LStatus.Caption :=Clientes.Cliente[StrToInt(StringBand.Item)].Status; end;
Gostei + 0
22/08/2005
Martins
Muda muita coisa.
Valew!!!
Gostei + 0
22/08/2005
Michelli88
inves de colocar assim:
coloque direto da query:
procedure TForm1.StringbandBeforePrint(Sender: TQRCustomBand; var PrintBand: Boolean); begin LNome.Caption := QueryNome.AsString;
Gostei + 0
22/08/2005
Martins
[b:0caa9ac57b] Moderadores e administradores[/b:0caa9ac57b] podem fechar o tópico.
Martins
Gostei + 0
22/08/2005
Martins
Desculpe Michelli, postei a mensagem no link errado
[/size:36c3173bd5]
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)