import java.io.File;
import java.io.IOException;
import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;
public class SpreadsheetRead {
/**
* @param args
* @throws IOException
* @throws BiffException
*/
public static void main(String[] args) throws BiffException, IOException {
// TODO Auto-generated method stub
Workbook workbook = Workbook.getWorkbook(new File("Book1.xls"));
Sheet sheet = workbook.getSheet(0);
Cell name = sheet.getCell(0, 0);
Cell name1 = sheet.getCell(1, 0);
try {
Cell name2 = sheet.getCell(2, 0);
Cell name3 = sheet.getCell(3, 0);
}catch (Exception e){
e.printStackTrace();
}
Cell value = sheet.getCell(0, 1);
Cell value1 = sheet.getCell(1, 1);
Cell value2 = sheet.getCell(2, 1);
Cell value3 = sheet.getCell(3, 1);
System.out.println(sheet.getRows());
System.out.println(sheet.getColumns());
System.out.println(name.getContents());
System.out.println(name1.getContents());
System.out.println(value.getContents());
System.out.println(value1.getContents());
}
}
Excel Sheet Content (Book1.xls) ... It Contains 4 Rows and 2 Columns as mentioned below.
Name Value A 1 B 2 C 3
This code is working for cell [(0,0),(0,1),(1,0) & (1,1)] and for rest of the cells it is giving ArrayIndexOutOfBoundException... please help
Stack Trace
java.lang.ArrayIndexOutOfBoundsException: 2 4 2 Name Value A at jxl.read.biff.SheetImpl.getCell(SheetImpl.java:356) at SpreadsheetRead.main(SpreadsheetRead.java:25) 1