Assuming that you already have the sheet, you attach detailed information.
1.- You need the Java library first, you can download it from here.
http://www.java2s.com/Code/Jar/j/Downloadjxljar.htm
2.- You incorporate the Excel file
You select the right button on the project folder \ Properties; "Java Build Path" option; Libraries tab; finally click on "Add External JAR" and select the file.
This is an example, let's see what you think.
Go through each sheet of the excel file. Within each sheet, scroll through all the columns of each row of the excel file and display its contents on the screen.
importjxl. *;
importjava.io. *;
public class LeerExcel {
private void leerArchivoExcel(String archivoDestino) {
try {
Workbook archivoExcel = Workbook.getWorkbook(new File(
archivoDestino));
System.out.println("Número de Hojas\t"
+ archivoExcel.getNumberOfSheets());
for (int sheetNo = 0; sheetNo < archivoExcel.getNumberOfSheets(); sheetNo++) // Recorre las hojas
{
Sheet hoja = archivoExcel.getSheet(sheetNo);
int numColumnas = hoja.getColumns();
int numFilas = hoja.getRows();
String data;
System.out.println("Nombre de la Hoja\t"
+ archivoExcel.getSheet(sheetNo).getName());
for (int fila = 0; fila < numFilas; fila++) { // Recorre cada
// fila de la
// hoja
for (int columna = 0; columna < numColumnas; columna++) {
// Recorre
// cada
// columna
// de
// la
// fila
data = hoja.getCell(columna, fila).getContents();
System.out.print(data + " ");
}
System.out.println("\n");
}
}
} catch (Exception ioe) {
ioe.printStackTrace();
}
}
public static void main(String arg[]) {
ReadExcel excel = new ReadExcel();
excel.leerArchivoExcel("archivoPrueba.xls");
}
}