[RESOLVIDO]Ajuda com código do IREPORT

3 respostas
fabricioempresa

Bom pessoal tenho o seguinte código

@Action
    public void Gerar() throws JRException {
        JasperPrint jp = null;
        TableModel model = new ReportTableModel();
        JRTableModelDataSource ds = new JRTableModelDataSource(model);
        System.out.println("this.reportTable.getRowCount() = " + this.reportTable.getRowCount());
        for (int j = 0; j < this.reportTable.getRowCount(); j++) {
            Map registro = new HashMap();
            String date = this.reportTable.getValueAt(j, 0).toString();
            System.out.println("dt = " + date);
            String vol = this.reportTable.getValueAt(j, 1).toString();
            System.out.println("vol = " + vol);
            String desc = this.reportTable.getValueAt(j, 2).toString();
            System.out.println("desc = " + desc);
            String port = this.reportTable.getValueAt(j, 3).toString();
            System.out.println("port = " + port);
            registro.put("data", date);
            registro.put("desc", desc);
            registro.put("vol", vol);
            registro.put("port", port);
        try {
            jp = JasperFillManager.fillReport("report4.jasper", registro, ds);
           
         } catch (JRException e) {
            e.printStackTrace();
        }
     }
     JasperViewer.viewReport(jp, false);
    }

Eu tenho uma tabela com 23 registros porém nesse código ele aparece apenas o último dentro do ireport

No meu IREPORT está com todos os campos String.

Alguém tem uma idéia de como proceder?

obrigado a todos

3 Respostas

TheKill

amigo…

vc nao ta prestando atenção no que esta a fazer.
esta passando um objeto hashmap chamado parameter, que só tem 1 linha.
ele nao tem 23 linhas. ele tem a sua linha 23 e deu.

Cria um objeto do tipo ArrayList<> e passa no seu hashMap.
e para cada linha, vc da um add. no seu Array.

fabricioempresa

Enfim funcionou o que estava a uns 3 dias pesquisando

Seguem os arquivos

TheKill

é só ter mais paciência, e entender oque esta tentando fazer

Criado 7 de julho de 2010
Ultima resposta 8 de jul. de 2010
Respostas 3
Participantes 2