게시판 즐겨찾기
편집
드래그 앤 드롭으로
즐겨찾기 아이콘 위치 수정이 가능합니다.
ArrayIndexOutOfBoundsException 질문드립니다.
게시물ID : programmer_14952짧은주소 복사하기
작성자 : 아안돼
추천 : 0
조회수 : 1166회
댓글수 : 2개
등록시간 : 2015/12/13 02:52:57
옵션
  • 창작글
  • 본인삭제금지
사용환경은 android eclipse 입니다.

우선 코드 적으면

public void readExcel(Context context)
{
try
{
InputStream dbInputStream = context.getAssets().open("hospital.xls", Context.MODE_WORLD_READABLE);
Workbook workbook = Workbook.getWorkbook(dbInputStream);
Sheet sheet=workbook.getSheet(0);
int rowLength = sheet.getRows();
int columnLength=sheet.getColumns();
Log.e("row : " , ""+rowLength);
Log.e("Colum : ", ""+columnLength);
String[][]data=new String[rowLength][columnLength];
for(int i = 0; i<rowLength ; i++)
{
for(int j =0; j<columnLength; j++)
{
Cell cell = sheet.getCell(i,j);
data[i][j]=cell.getContents();
Log.e("cell["+i+"]["+j+"]", ""+cell);
Log.e("data["+i+"]["+j+"]", ""+data[i][j]);
}
}
Log.e("row : " , ""+rowLength);
Log.e("Colum : ", ""+columnLength);
}
catch(Exception e )
{
Log.e("exception error : ", ""+e);
}

}

입니다.
log를 통해 row와 column 을 살펴보면 
row : 84   ,  column : 15 입니다.

나오는 에러메세지는
java.lang.ArrayIndexOutOfBoundsException: length=15; index=15

인데요..

column 수에따라서 뒤에 에레메세지가 변경됩니다.
예를들어 column 을 7로 조정하면
java.lang.ArrayIndexOutOfBoundsException: length=7; index=7
로 에러메세지가 출력됩니다..

뭐가 문제일까요 ..? 조언부탁드립니다.ㅠㅠ
감사합니다 

전체 추천리스트 보기
새로운 댓글이 없습니다.
새로운 댓글 확인하기
글쓰기
◀뒤로가기
PC버전
맨위로▲
공지 운영 자료창고 청소년보호