public void xls() throws JRException {
    long start = System.currentTimeMillis();
    File sourceFile = new File("build/reports/JRMDbReport.jrprint");

    JasperPrint jasperPrint = (JasperPrint) JRLoader.loadObject(sourceFile);

    File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".xls");

    JRXlsExporter exporter = new JRXlsExporter();

    exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
    exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(destFile));
    SimpleXlsReportConfiguration configuration = new SimpleXlsReportConfiguration();
    configuration.setOnePagePerSheet(false);
    exporter.setConfiguration(configuration);

    exporter.exportReport();

    System.err.println("XLS creation time : " + (System.currentTimeMillis() - start));
  }
  public void generarReporteEvaluador() {
    HttpServletRequest request =
        (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();

    ByteArrayOutputStream outReporte = new ByteArrayOutputStream();
    String pathJasperReporte =
        request.getSession().getServletContext().getRealPath("")
            + "/reportesJasper/variables/cuantitativasPorInformacionIes.jasper";

    Map<String, Object> parametrosReporte = new HashMap<>();

    String pathLogo =
        request.getSession().getServletContext().getRealPath("") + "/images/logo_ceaaces.png";
    parametrosReporte.put("par_logo", pathLogo);
    parametrosReporte.put("ies", informacionIesDTO.getIes().getNombre());

    // parametrosReporte.put("SUBREPORT_DIR", request.getSession()
    // .getServletContext().getRealPath("")
    // + "/reportesJasper/mallasGrafico/");
    try {

      JRDataSource dataSourceMallas =
          new JRBeanCollectionDataSource(listaValoresVariablesEvaluador);
      if (dataSourceMallas != null) {
        JRXlsExporter exporter = new JRXlsExporter();
        cargarPropiedadesReporte(exporter);

        JasperPrint jasperPrint =
            JasperFillManager.fillReport(pathJasperReporte, parametrosReporte, dataSourceMallas);
        exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
        exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(outReporte));

        exporter.exportReport();
        reporteBytes = outReporte.toByteArray();
      }
    } catch (Exception e) {
      e.printStackTrace();
      JsfUtil.msgError("Error al generar el reporte, comuníquese con el administrador del sistema");
    }
  }
  public void xls() throws JRException {
    long start = System.currentTimeMillis();
    File sourceFile = new File(TMP_DIR + ALL_CHARTS_REPORT_JRPRINT);
    Map<String, String> dateFormats = new HashMap<String, String>();
    dateFormats.put("EEE, MMM d, yyyy", "ddd, mmm d, yyyy");
    JasperPrint jasperPrint = (JasperPrint) JRLoader.loadObject(sourceFile);
    File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".xls");

    JRXlsExporter exporter = new JRXlsExporter();

    exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
    exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(destFile));
    SimpleXlsReportConfiguration configuration = new SimpleXlsReportConfiguration();
    configuration.setOnePagePerSheet(true);
    configuration.setDetectCellType(true);
    configuration.setFormatPatternsMap(dateFormats);
    exporter.setConfiguration(configuration);

    exporter.exportReport();

    System.err.println("XLS creation time : " + (System.currentTimeMillis() - start));
  }
  public void generarReporteInformeEvaluacion() {
    HttpServletRequest request =
        (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();

    ListaIesController controller =
        (ListaIesController) JsfUtil.obtenerObjetoSesion("listaIesController");

    IesDTO ies = controller.getIes();

    ByteArrayOutputStream outReporte = new ByteArrayOutputStream();
    String pathJasperReporteCuantitativas =
        request.getSession().getServletContext().getRealPath("")
            + "/reportesJasper/variables/informeEvaluacionCuantitativas.jasper";

    String pathJasperReporteCualitativas =
        request.getSession().getServletContext().getRealPath("")
            + "/reportesJasper/variables/informeEvaluacionCualitativas.jasper";

    Map<String, Object> parametrosReporte = new HashMap<>();

    String pathLogo =
        request.getSession().getServletContext().getRealPath("") + "/images/logo_ceaaces.png";
    parametrosReporte.put("par_logo", pathLogo);
    parametrosReporte.put("IES", ies.getNombre());
    parametrosReporte.put("CODIGO_IES", ies.getCodigo());
    parametrosReporte.put("ID_INFORMACION_IES", informacionIesDTO.getId());
    parametrosReporte.put("ID_PROCESO", controller.getFaseIesDTO().getProcesoDTO().getId());

    DataSource dataSource = null;
    Connection connection = null;
    try {
      InitialContext ic = new InitialContext();
      Context xmlContext = (Context) ic.lookup("java:comp/env");
      dataSource = (DataSource) xmlContext.lookup("jdbc/casDbConnection");
      connection = dataSource.getConnection();

      JRXlsExporter exporter = new JRXlsExporter();
      cargarPropiedadesReporte(exporter);

      JasperPrint jasperCuantitativas =
          JasperFillManager.fillReport(
              pathJasperReporteCuantitativas, parametrosReporte, connection);
      JasperPrint jasperPrintCualitativas =
          JasperFillManager.fillReport(
              pathJasperReporteCualitativas, parametrosReporte, connection);
      ArrayList<JasperPrint> hojasReporte = new ArrayList<JasperPrint>();
      hojasReporte.add(jasperCuantitativas);
      hojasReporte.add(jasperPrintCualitativas);

      exporter.setExporterInput(SimpleExporterInput.getInstance(hojasReporte));
      exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(outReporte));

      exporter.exportReport();
      reporteBytes = outReporte.toByteArray();
      outReporte.flush();
      outReporte.close();
    } catch (Exception e) {
      e.printStackTrace();
      JsfUtil.msgError(
          "Error al generar el reporte, comuníquese con el administrador del sistema");
    } finally {
      try {
        if (connection != null) {
          connection.close();
        }
      } catch (Exception ex) {
        ex.printStackTrace();
      }
    }
  }