Ver Mensaje Individual
  #918 (permalink)  
Antiguo 11/09/2007, 15:42
Avatar de glomer
glomer
 
Fecha de Ingreso: septiembre-2007
Mensajes: 5
Antigüedad: 16 años, 8 meses
Puntos: 0
Re: Jasper Report + iReport + NetBeans 4

Hola me parece muy buena la logica de el archivo en excel, yo soy nuevo en esto y estoy tratando de entenderle, espero me puedas ayudar.
Yo genero el pdf y me lo guarda en el disco del servidor pero no logro invocarlo para abrirlo y poderlo ver, hay unas soluciones ya en el foro lo malo es que todas la clase que lo corre esta la sesion del servidor y yo le pasa la consulta y no el parametro asi que lo hago en una clase y luego la mando a traer.
Ahora el excel no lo he genera en tu logica me puedes decir que es xlsFilesSource
o como lo generas como paso ese parametro?
Gracias
anexo el codigo

public void ReporteRolTurnoM(int folio) throws JRException,SQLException,Exception
{
conn = getConexion();
stmt = conn.createStatement();
StringBuffer sb = new StringBuffer();
Map mapa = new HashMap();
try
{
if(!conn.isClosed())
{
FileInputStream file = new FileInputStream("C:\\Archivos de programa\\JasperSoft\\iReport-1.3.3\\RolTurnoM.jasper");
String pdffile = "C:\\Archivos de programa\\JasperSoft\\iReport-1.3.3\\RolTurnoM.pdf";
String xlsFileName = "C:\\Archivos de programa\\JasperSoft\\iReport-1.3.3\\RolTurnoM.xls";
sb.append("SELECT t1.i35_folrol, t1.i35_numpla, t1.d35_fecini, t1.d35_fecfin, t1.i35_tiprol, t1.c35_starol, ");
sb.append(" t2.i42_numemp, t2.i42_cvetno, t2.i42_diauno, t2.i42_diados, t2.i42_diatre, t2.i42_diacua, ");
sb.append("t2.i42_cvemov, t2.d42_fecini, t2.d42_fecfin, t2.i42_cvepto, t3.c20_nomemp, t3.c20_apater, t3.c20_amater,");
sb.append("t4.c34_destip, t5.c19_nompla, t6.c21_destno, t7.c33_desmot, t8.c36_desdia a, t9.c36_desdia b,");
sb.append("t10.c36_desdia c, t11.c36_desdia d");
sb.append(" FROM t35_roltno t1, t42_emprol t2, t20_emplea t3, t34_tiprol t4,t19_plazas t5,t21_turnos t6 ");
sb.append(",t33_motivo t7,t36_semana t8,t36_semana t9, t36_semana t10, t36_semana t11");
sb.append(" WHERE t1.i35_folrol = ");
sb.append(folio);
sb.append(" and t1.c35_starol = 'A' ");
sb.append(" and t3.i20_cveemp = ( SELECT t2.i42_numemp FROM t42_emprol t1 WHERE t1.i42_numemp = t3.i20_cveemp ");
sb.append(" and t1.i42_cverol = ");
sb.append(folio);
sb.append(")");
sb.append(" and (t2.i42_cvepto = 11 or t2.i42_cvepto = 12 or t2.i42_cvepto = 13 or t2.i42_cvepto = 25 or t2.i42_cvepto = 26 or t2.i42_cvepto = 27 or t2.i42_cvepto = 33 or t2.i42_cvepto = 34 or t2.i42_cvepto = 38 or t2.i42_cvepto = 35 or t2.i42_cvepto = 39 or t2.i42_cvepto = 18 or t2.i42_cvepto = 20 or t2.i42_cvepto = 30)");
sb.append(" and t4.i34_cvetip = (SELECT t1.i35_tiprol FROM t35_roltno t1 WHERE t1.i35_folrol = ");
sb.append(folio);
sb.append(")");
sb.append(" and t5.i19_cvepla = (SELECT t1.i35_numpla FROM t35_roltno t1 WHERE t1.i35_folrol = ");
sb.append(folio);
sb.append(")");
sb.append(" and t6.i21_cvetno = ( SELECT t2.i42_cvetno FROM t42_emprol t1 WHERE t1.i42_cverol = t1.i35_folrol and t1.i42_numemp = t3.i20_cveemp)");
sb.append(" and t7.i33_cvemot = ( SELECT t2.i42_cvemov FROM t42_emprol t1 WHERE t1.i42_cverol = t1.i35_folrol and t1.i42_numemp = t3.i20_cveemp)");
sb.append(" and t8.i36_cvedia = ( SELECT t2.i42_diauno FROM t42_emprol t1 WHERE t1.i42_cverol = t1.i35_folrol and t1.i42_numemp = t3.i20_cveemp)");
sb.append(" and t9.i36_cvedia = ( SELECT t2.i42_diados FROM t42_emprol t1 WHERE t1.i42_cverol = t1.i35_folrol and t1.i42_numemp = t3.i20_cveemp)");
sb.append(" and t10.i36_cvedia = ( SELECT t2.i42_diatre FROM t42_emprol t1 WHERE t1.i42_cverol = t1.i35_folrol and t1.i42_numemp = t3.i20_cveemp)");
sb.append(" and t11.i36_cvedia = ( SELECT t2.i42_diacua FROM t42_emprol t1 WHERE t1.i42_cverol = t1.i35_folrol and t1.i42_numemp = t3.i20_cveemp)");
sb.append(";");

trace(sb.toString());

ResultSet rs = stmt.executeQuery(sb.toString());

JasperReport jr = (JasperReport)JRLoader.loadObject(file);
JRResultSetDataSource jrRS = new JRResultSetDataSource(rs);
JasperPrint jp = JasperFillManager.fillReport(jr,mapa,jrRS);

JasperExportManager.exportReportToPdfFile(jp, pdffile);


JRXlsExporter exporter = new JRXlsExporter();
exporter.setParameter(JRExporterParameter.JASPER_P RINT, jp);
exporter.setParameter(JRExporterParameter.OUTPUT_F ILE_NAME,xlsFilesSource + xlsFileName);
exporter.setParameter(JRXlsExporterParameter.IS_ON E_PAGE_PER_SHEET, Boolean.TRUE);
exporter.exportReport();


// JasperViewer.viewReport(jp);
JasperViewer.viewReport(jp,false);
// JasperPrintManager jpm = new JasperPrintManager();
// jpm.printReport(jp,false);
}
}
catch(Exception e)
{
e.printStackTrace();
}
}