Excel导入异常Cannot get a text value from a numeric cell解决
POI操作Excel時偶爾會出現Cannot get a text value from a numeric cell的異常錯誤。
異常原因:Excel數據Cell有不同的類型,當我們試圖從一個數字類型的Cell讀取出一個字符串并寫入數據庫時,就會出現Cannot get a text value from a numeric cell的異常錯誤。
此異常常見于類似如下代碼中:row.getCell(0).getStringCellValue();
解決辦法:先設置Cell的類型,然后就可以把純數字作為String類型讀進來了:
if(row.getCell(0)!=null){
????????? row.getCell(0).setCellType(Cell.CELL_TYPE_STRING);
????????? stuUser.setPhone(row.getCell(0).getStringCellValue());
?????}
---------------------
作者:ysughw
來源:CSDN
原文:https://blog.csdn.net/ysughw/article/details/9288307
版權聲明:本文為博主原創文章,轉載請附上博文鏈接!
轉載于:https://www.cnblogs.com/matd/p/11227249.html
總結
以上是生活随笔為你收集整理的Excel导入异常Cannot get a text value from a numeric cell解决的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 算命多少钱啊?
- 下一篇: 盘锦兴隆台的房价多少钱一平,田家的房价多