Ver Mensaje Individual
  #2 (permalink)  
Antiguo 17/04/2008, 11:30
Solidux
 
Fecha de Ingreso: diciembre-2007
Mensajes: 24
Antigüedad: 16 años, 5 meses
Puntos: 1
Re: iReport: El documento no tiene páginas

Hola.....

Cuando estuve tratando de hacer reporte como tu, tuvo muchos problemas, y la
mejor solucion es utilizar el ya compilado(*.jasper), el mismo que genera Ireport .
Te mando la porcion de codigo:
Connection con = null;
try {
con = rp.conectarse();//clase donde se realiza la conexion a la base de datos y retorna la conexion
String master = "jaspers/javaPrueba00.jasper";//paquete donde esta el jasper compilado
JasperReport masterReport = null;
try{
masterReport = (JasperReport) JRLoader.loadObject(master);
}catch (JRException e){
JOptionPane.showMessageDialog(this,"Error cargando el reporte maestro: " + e.getMessage());
System.exit(0);
}
Map parametro = new HashMap();//parametros externos
JasperPrint jasperPrint;
if(this.txt_edad.getText().length() != 0){
parametro.put("edad",this.txt_edad.getText());
jasperPrint = JasperFillManager.fillReport(masterReport,parametr o,con);
}
else
jasperPrint = JasperFillManager.fillReport(masterReport,null,con );
JasperViewer jviewer = new JasperViewer(jasperPrint,false);
jviewer.setTitle("Reporte General.-");
jviewer.setVisible(true);

} catch (Exception e) {
System.out.println("Error: " + e.getMessage());
}