[转]Excel导入异常Cannot get a text value from a numeric cell解决
生活随笔
收集整理的這篇文章主要介紹了
[转]Excel导入异常Cannot get a text value from a numeric cell解决
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
原文地址:http://blog.csdn.net/ysughw/article/details/9288307
POI操作Excel時偶爾會出現(xiàn)Cannot get a text value from a numeric cell的異常錯誤。
異常原因:Excel數(shù)據(jù)Cell有不同的類型,當(dāng)我們試圖從一個數(shù)字類型的Cell讀取出一個字符串并寫入數(shù)據(jù)庫時,就會出現(xiàn)Cannot get a text value from a numeric cell的異常錯誤。
此異常常見于類似如下代碼中:row.getCell(0).getStringCellValue();
解決辦法:先設(shè)置Cell的類型,然后就可以把純數(shù)字作為String類型讀進(jìn)來了:
if(row.getCell(0)!=null){
?
???????? row.getCell(0).setCellType(Cell.CELL_TYPE_STRING);
????????? stuUser.setPhone(row.getCell(0).getStringCellValue());
?????}
總結(jié)
以上是生活随笔為你收集整理的[转]Excel导入异常Cannot get a text value from a numeric cell解决的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: centos7.0搭建svn服务器
- 下一篇: Oracle级联查询