JasperReports 5.6: JRXlsExporter.setParameter is deprecated

前端 未结 3 830
無奈伤痛
無奈伤痛 2020-12-07 18:31

I have this code to export a JasperReprot to XLS:

        JasperPrint jprint=JasperFillManager.fillReport(expRpg, null, new JRBeanCollectionDataSource(datali         


        
3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-07 19:34

    Thank to the above code , here is my code : Notice : Export excel with ireport, ireport 6.0 , java 7

     Map parametro = new HashMap();
                    parametro.put("USUARIO", UConstante.NAME_MINISTERIO_USER);
                    parametro.put("RUTA_LOGO", PuenteFile.getRutaFiles(FacesContext.getCurrentInstance(), PuenteFile.RUTA_IMG_LOGO));
                    parametro.put("PATH_SYSTEM", rutaFileSystemHD);
                    parametro.put("WHERE_DATA", WHERE_REGISTRO);
                    parametro.put("WHERE_PROYECTO_USUARIO", WHERE_PROYECTO_USUARIO);
                    parametro.put("WHERE_ZONA", WHERE_ZONA);
                    parametro.put("NAME_APP", RutaFile.NAME_APP);
                    parametro.put("ID_USUARIO", getUsuario().getId());
                    parametro.put("ID_PROYECTO", beanProyecto.getId());
                    parametro.put("SUBREPORT_DIR", SUBREPORT_DIR);
    
                    System.out.println(">>>>>> PARAMETROS :" + parametro.toString());
    
                  try {
                        JasperPrint jasperPrint = JasperFillManager.fillReport(path, parametro, PgConnector.getConexion());
                        JRXlsExporter xlsExporter = new JRXlsExporter();
                        xlsExporter.setExporterInput(new SimpleExporterInput(jasperPrint));
                        xlsExporter.setExporterOutput(new SimpleOutputStreamExporterOutput(PuenteFile.getRutaFiles(FacesContext.getCurrentInstance(), PuenteFile.RUTA_REPORT_FILE) + nameExcel));
                        SimpleXlsReportConfiguration xlsReportConfiguration = new SimpleXlsReportConfiguration();
                        SimpleXlsExporterConfiguration xlsExporterConfiguration = new SimpleXlsExporterConfiguration();
                        xlsReportConfiguration.setOnePagePerSheet(true);
                        xlsReportConfiguration.setRemoveEmptySpaceBetweenRows(false);
                        xlsReportConfiguration.setDetectCellType(true);
                        xlsReportConfiguration.setWhitePageBackground(false);
                        xlsExporter.setConfiguration(xlsReportConfiguration);
                        xlsExporter.exportReport();
    
                    } catch (Exception ex) {
                        ex.printStackTrace();
                    }
    

提交回复
热议问题