Created
          August 4, 2020 15:41 
        
      - 
      
- 
        Save HashRaygoza/2408dcd9932228c4639a6c5dfa1ed8e8 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | public class ProcesoReporte extends SwingWorker<Void, Void>{ | |
| public ProcesoReporte() { | |
| this.setProgress(0); | |
| } | |
| public void generarExcel() throws FileNotFoundException, IOException { | |
| XSSFWorkbook libro = new XSSFWorkbook(); | |
| XSSFSheet pagina = libro.createSheet("Pagina"); | |
| GeneradorDatos generadorDatos = new GeneradorDatos(); | |
| ArrayList<Double> datos = generadorDatos.datos(); | |
| for(int i=0; i< datos.size(); i++){ | |
| Row fila = pagina.createRow(i); | |
| Cell celda = fila.createCell(0); | |
| celda.setCellValue( datos.get(i)); | |
| Double indice = Double.valueOf(i); | |
| Double total = Double.valueOf( datos.size() -1 ); | |
| System.out.println(indice / total); | |
| double avance = (indice / total) * 100.0; | |
| int progreso = (int) Math.round(avance); | |
| System.out.println("Progreso " + progreso); | |
| this.setProgress(progreso); | |
| System.out.println("Agregando elemento " + i); | |
| } | |
| try (FileOutputStream salida = new FileOutputStream(new File("eventoExcel.xlsx"))) { | |
| libro.write(salida); | |
| } | |
| } | |
| @Override | |
| protected Void doInBackground() throws Exception { | |
| this.generarExcel(); | |
| return null; | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment