자바(Java)

cannot get a text value from a numeric cell

xemaker 2022. 2. 7. 14:59

자바 엑셀 poi 관련 개발을 하다보면 cannot get a text value from a numeric cell
이런 에러를 접할 수 있다.

문자 1을 숫자 1로 읽혀서 1.0 으로 읽혔다.
흠.. 그냥 1은 1이여야 하는데.. 지멋대로 바꿔버리네..

그래서

Cell.CELL_TYPE_STRING 같은걸 해봤는데도 안되었다.

구글링 해서 StackOverFlow에서 답을 찾았다.

결론은 DataFormatter 를 쓰면 해결 되었다.

DataFormatter formatter = new DataFormatter();

String s = formatter.formatCellValue(row.getCell(1));



https://stackoverflow.com/questions/30125465/cannot-get-a-text-value-from-a-numeric-cell-poi