Advertisement
Metziop

Untitled

May 31st, 2021
794
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.73 KB | None | 0 0
  1. //---------------- Creando el stream para generar el reporte en la ventana-----------//
  2.     private void streamReporte() {
  3.         try {
  4.             int fila2 = jTRerporte.getSelectedRow();
  5.             String id = jTRerporte.getValueAt(fila2, 0).toString();
  6.             String usuario = jTRerporte.getValueAt(fila2, 1).toString();
  7.             String sucursal = jTRerporte.getValueAt(fila2, 2).toString();
  8.             String trabajos = jTRerporte.getValueAt(fila2, 3).toString();
  9.             String tiempos = jTRerporte.getValueAt(fila2, 4).toString();
  10.             String comisiones = jTRerporte.getValueAt(fila2, 5).toString();
  11.             String bono = jTRerporte.getValueAt(fila2, 6).toString();
  12.             //Creando el objeto bw de la clase  BufferedWriter Y se le pasa como parametro la ruta donde se guardara el archivo
  13.             BufferedWriter bw = new BufferedWriter(new FileWriter("C:\\Users\\dario\\Documents\\NetBeansProjects\\floreria2\\src\\reportes.txt"));
  14.             //se le pasa lo contenido en la caja de texto para que lo imprima en el archivo txt
  15.             bw.write("REPORTE INDIVDUAL" + "\n");
  16.             bw.write("Num. Empleado:" + id + "\n");
  17.             bw.write("Usuario:" + usuario + "\n");
  18.             bw.write("Sucursal:" + sucursal + "\n");
  19.             bw.write("Trabajos realizados en el periodo" + trabajos + "\n");
  20.             bw.write("Tiempo Total:" + tiempos + "\n");
  21.             bw.write("Commisiones totales durante el periodo:" + comisiones + "\n");
  22.             bw.write("Bono Extra:" + bono + "\n");
  23.             bw.close(); //se cierra el stream
  24.  
  25.             JOptionPane.showMessageDialog(null, "Archivo creado con exito");
  26.         } catch (HeadlessException | IOException e) {
  27.  
  28.         }
  29.  
  30.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement