Editar Archivos Excel en Java Eclipse
Publicado por Guille (5 intervenciones) el 19/01/2019 19:13:19
Necesito Ayuda, ¿alguien sabe porque me da error ".getWorkbook()" ? ni siquiera puedo ejecutarlo ,sino que me marca en el código directamente,Me dice "The method getWorkbook(File) is undefined for the type XSSFWorkbook".
Este es el fragmento de código:
Yo lo que estoy intentando con ese codigo es agregar datos a un excel ya existente.
PD: Probé con "Workbook Libro=Workbook.getWorkbook(Excel);" pero también me da el mismo error
Este es el fragmento de código:
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
package Excel;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.FillPatternType;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public class Antes_Del_Traslado_Excel {
private static final Logger LOGGER = Logger.getLogger("mx.com.hash.newexcel.Antes_Del_Traslado_Excel");
public Antes_Del_Traslado_Excel() {
try {
File Excel = new File("Traslados.xlsx");
XSSFWorkbook Libro=XSSFWorkbook.getWorkbook(Excel);
XSSFSheet Hoja1= Libro.getSheetAt(0);
XSSFRow Fila=Hoja1.createRow(0);
XSSFCell Celda=Fila.createCell(2);
Celda.setCellValue("Prueba");
FileOutputStream Salid = new FileOutputStream(Excel);
Libro.write(Salid);
Salid.close();
}catch (FileNotFoundException ex) {
LOGGER.log(Level.SEVERE, "Archivo no localizable en sistema de archivos");
}catch (IOException ex) {
LOGGER.log(Level.SEVERE, "Error de entrada/salida");
}
}
}
Yo lo que estoy intentando con ese codigo es agregar datos a un excel ya existente.
PD: Probé con "Workbook Libro=Workbook.getWorkbook(Excel);" pero también me da el mismo error
Valora esta pregunta


0