-
-
Save parzibyte/70ef8f7af82cbaad83718675428c1942 to your computer and use it in GitHub Desktop.
This file contains 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
Workbook libro = new XSSFWorkbook(); | |
final String nombreArchivo = "Mi archivo creado con Java.xlsx"; | |
Sheet hoja = libro.createSheet("Hoja 1"); | |
Row primeraFila = hoja.createRow(0); | |
Cell primeraCelda = primeraFila.createCell(0); | |
primeraCelda.setCellValue("Yo voy en la primera celda y primera fila"); | |
File directorioActual = new File("."); | |
String ubicacion = directorioActual.getAbsolutePath(); | |
String ubicacionArchivoSalida = ubicacion.substring(0, ubicacion.length() - 1) + nombreArchivo; | |
FileOutputStream outputStream; | |
try { | |
outputStream = new FileOutputStream(ubicacionArchivoSalida); | |
libro.write(outputStream); | |
libro.close(); | |
System.out.println("Libro guardado correctamente"); | |
} catch (FileNotFoundException ex) { | |
System.out.println("Error de filenotfound"); | |
} catch (IOException ex) { | |
System.out.println("Error de IOException"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment