
Problema al escribir excel desde java
Publicado por Brandon (3 intervenciones) el 22/06/2017 19:50:39
Hola tengo el siguiente problema intento escribir un Excel a partir de una consulta de base de datos y todo esto desde java pero no termina de escribir y me sale el siguiente error
Exception in thread "main" java.io.FileNotFoundException: D:\User\usr025535\Desktop\brandon.xlsx (El proceso no tiene acceso al archivo porque está siendo utilizado por otro proceso)
at java.io.FileOutputStream.open0(Native Method)
dejo mi código en java ojala me puedan ayudar......
Exception in thread "main" java.io.FileNotFoundException: D:\User\usr025535\Desktop\brandon.xlsx (El proceso no tiene acceso al archivo porque está siendo utilizado por otro proceso)
at java.io.FileOutputStream.open0(Native Method)
dejo mi código en java ojala me puedan ayudar......
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
wb = new XSSFWorkbook();
Sheet hoja = ((org.apache.poi.ss.usermodel.Workbook) wb).createSheet("Movimientos");
int cuenta = 1;
String titulos [] = {"no.","rollo","corre","bolsa","fecha","lugar","docto","desc","valor","Cuenta","nombre cuenta","requerimiento"};
Row titulosExcel = hoja.createRow(0);
for (int j = 0; j < titulos.length ; j++){
Cell titul = titulosExcel.createCell(j);
titul.setCellValue(titulos[j]);
}
String sbl="Select * from reqs LEFT JOIN rollos on reqs.concatenado = rollos.concatenar WHERE carga ='"+carga1+"' ";
ResultSet r = cn.buscar(sbl);
while(r.next()){
Row celdaescribir = hoja.createRow(cuenta);
Cell no = celdaescribir.createCell(0);
Cell rollo = celdaescribir.createCell(1);
Cell corre = celdaescribir.createCell(2);
Cell bolsa = celdaescribir.createCell(3);
Cell fecha = celdaescribir.createCell(4);
Cell lugar = celdaescribir.createCell(5);
Cell docto = celdaescribir.createCell(6);
Cell desc = celdaescribir.createCell(7);
Cell valor = celdaescribir.createCell(8);
Cell cuentad = celdaescribir.createCell(9);
Cell nom_cuenta = celdaescribir.createCell(10);
Cell requerimiento = celdaescribir.createCell(11);
no.setCellValue(cuenta);
fecha.setCellValue(r.getString("Fecha"));
lugar.setCellValue(r.getString("lugar"));
docto.setCellValue(r.getString("docto"));
desc.setCellValue(r.getString("descripcion"));
valor.setCellValue(r.getString("valor"));
cuentad.setCellValue(r.getString("cuenta"));
nom_cuenta.setCellValue(r.getString("nm_cuenta"));
requerimiento.setCellValue(r.getString("solicitud"));
rollo.setCellValue(r.getString(11));
corre.setCellValue(r.getString(12));
bolsa.setCellValue(r.getString(13));
System.out.println(cuenta);
cuenta++;
wb.write(new FileOutputStream(archivo+ ".xlsx"));
}
wb.close();
Valora esta pregunta


0