JasperReports

0 respostas
G

Aí galera,

Estou a desenvolver uma app, onde estou gerando reports com o Ireports e a lib JasperReports, e tudo dá certo até ao momento de exportar, porque eu consigo visualizar o report no JasperView, mas aí quando quero exportar pra excel o report fica todo desformatado.
E quando eu testo directamente no ireport tudo funciona direitinho, e cria a folha de excel como eu quero, o único prob. é qdo eu chamo na minha app.

public void generateReport2()throws Exception
    {
            Conexao cn = new Conexao();
            cn.abrirConexao();
            java.sql.Statement st = cn.getConn().createStatement();
            ResultSet rs = st.executeQuery("select * from temp");
            JasperReport jr;  
            JasperPrint jprint;
            JRResultSetDataSource jrrs = new JRResultSetDataSource(rs);
            HashMap param = new HashMap();
            JasperCompileManager.compileReportToFile("temp.jrxml","temp.jasper");
            jprint=JasperFillManager.fillReport("temp.jasper",param,jrrs);
            
                     JRXlsExporter exporterXLS = new JRXlsExporter();
         exporterXLS.setParameter(JRXlsExporterParameter.JASPER_PRINT, jprint);
         //exporterXLS.setParameter(JRXlsExporterParameter.OUTPUT_STREAM,output);
         exporterXLS.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.FALSE);
         //exporterXLS.setParameter(JRXlsExporterParameter.IS_AUTO_DETECT_CELL_TYPE, Boolean.TRUE);
         exporterXLS.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.TRUE);
         exporterXLS.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE);
         exporterXLS.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_COLUMNS, Boolean.TRUE);

            JasperViewer.viewReport(jprint,false);
            JasperViewer.setDefaultLookAndFeelDecorated(true);
}

A forma como aparece no excel é mto estranha, os dados aparecem todos na mesma folha, mas faz uma separação de linhas,como se tivesse a separar páginas.

Será que alguém me pode ajudar?

//Graveyard

Criado 20 de maio de 2008
Respostas 0
Participantes 1