commit 4c6e932c2c71be3e78ad6a6f2f007a58695f331a Author: Isidoro Nevares Martín Date: Mon Nov 10 10:03:07 2025 +0100 primer commit diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..f7e4a1d --- /dev/null +++ b/.classpath @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9f1d3ca --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/target/ +*.class \ No newline at end of file diff --git a/.project b/.project new file mode 100644 index 0000000..76c61c3 --- /dev/null +++ b/.project @@ -0,0 +1,23 @@ + + + ProyectosIES-Excel + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..2f5cc74 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..f897a7f --- /dev/null +++ b/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/ficheros/Gastos-Ingresos_Hiperbaric_2024-2025.xlsx b/ficheros/Gastos-Ingresos_Hiperbaric_2024-2025.xlsx new file mode 100644 index 0000000..3e94d0d Binary files /dev/null and b/ficheros/Gastos-Ingresos_Hiperbaric_2024-2025.xlsx differ diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..447c084 --- /dev/null +++ b/pom.xml @@ -0,0 +1,21 @@ + + 4.0.0 + ProyectosIES-Excel + ProyectosIES-Excel + 0.0.1-SNAPSHOT + + + + org.apache.poi + poi + 5.4.0 + + + + + org.apache.poi + poi-ooxml + 5.4.0 + + + \ No newline at end of file diff --git a/src/main/java/org/lapaloma/proyectosies/AppPrincipal.java b/src/main/java/org/lapaloma/proyectosies/AppPrincipal.java new file mode 100644 index 0000000..6b03d71 --- /dev/null +++ b/src/main/java/org/lapaloma/proyectosies/AppPrincipal.java @@ -0,0 +1,101 @@ +package org.lapaloma.proyectosies; + +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; +import java.util.Date; + +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.usermodel.WorkbookFactory; + +public class AppPrincipal { + private static int INDICE_GASTOS = 0; + private static int INDICE_INGRESOS = 1; + + public static void main(String[] args) { + AppPrincipal app = new AppPrincipal(); + try { + File f = new File("ficheros/Gastos-Ingresos_Hiperbaric_2024-2025.xlsx"); + InputStream inputStream = new FileInputStream(f); + Workbook libroHiperbaric= WorkbookFactory.create(inputStream); + + Sheet hojaGastos = libroHiperbaric.getSheetAt(INDICE_GASTOS); + + app.tratarGastosExcel(hojaGastos); + + Sheet hojaIngresos=libroHiperbaric.getSheetAt(INDICE_INGRESOS); + app.tratarGastosExcel(hojaIngresos); + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + private void tratarIngresosExcel(Sheet hojaIngresos) throws Exception { + + int filaInicio = 3; // En la fila 3 comienzan los datos. + + Row filaTrabajo = hojaIngresos.getRow(filaInicio); // En qué fila empezar ya dependerá también de si tenemos, por + // ejemplo, el título de cada columna en la primera fila + while (filaTrabajo != null) { + // Concepto - celda 1 + Cell celdaConcepto = filaTrabajo.getCell(1); + String concepto = celdaConcepto.getStringCellValue(); + + // Precio por concepto - celda 1 + Cell celdaCantidad = filaTrabajo.getCell(2); + double cantidadUnidad = celdaCantidad.getNumericCellValue(); + + // Número de unidades - celda 3 + Cell celdaNumeroElementos = filaTrabajo.getCell(3); + double numeroUnidades = celdaNumeroElementos.getNumericCellValue(); + + System.out.println("Concepto: " + concepto); + System.out.println("Número unidades: " + numeroUnidades); + System.out.println("Cantidad por unidad: " + cantidadUnidad); + + filaInicio++; + filaTrabajo = hojaIngresos.getRow(filaInicio); + System.out.println(); + } + } + + private void tratarGastosExcel(Sheet hojaGastos) throws Exception { + + int filaInicio = 3; // En la fila 3 comienzan los datos. + + Row filaTrabajo = hojaGastos.getRow(filaInicio); // En qué fila empezar ya dependerá también de si tenemos, por + // ejemplo, el título de cada columna en la primera fila + while (filaTrabajo != null) { + // Patrocinador - celda 1 + Cell celdaPatrocinador = filaTrabajo.getCell(1); + String patrocinador = celdaPatrocinador.getStringCellValue(); + + // Importe - celda 2 + Cell celdaCantidad = filaTrabajo.getCell(2); + double cantidad = celdaCantidad.getNumericCellValue(); + + // Observación - celda 3 + Cell celdaObservacion = filaTrabajo.getCell(3); +// String observacion = celdaObservacion.getStringCellValue(); + + // Fecha - celda 4 + Cell celdaFecha= filaTrabajo.getCell(4); + String fecha = celdaFecha.getStringCellValue(); + + System.out.println("Patrocinador: " + patrocinador); + System.out.println("Cantidad: " + cantidad); + System.out.println("Observación: " + celdaObservacion); + System.out.println("Fecha: " + fecha); + + filaInicio++; + filaTrabajo = hojaGastos.getRow(filaInicio); + System.out.println(); + } + } + +}