Excel import abnormal Can not get a text value from a numeric cell to solve

Occasionally, Can not get a text value from a numeric cell exception error occurs when the POI operation Excel.

Abnormal: Excel Cell data of different types, when we try to read a number from a string type of Cell and written to the database, Can not get a text value from a numeric cell exception error occurs.

This exception code similar to the following in common: row.getCell (0) .getStringCellValue ();

Workaround: Cell type setting, and then you can put pure numbers came in as a String read:

IF (! row.getCell (0) = null) {
          row.getCell (0) .setCellType (Cell.CELL_TYPE_STRING);
          stuUser.setPhone (row.getCell (0) .getStringCellValue ());
     }
------ ---------------
author: ysughw
source: CSDN
original: https: //blog.csdn.net/ysughw/article/details/9288307
copyright: This article is a blogger original article, Please attach reproduced Bowen link!

Guess you like

Origin www.cnblogs.com/matd/p/11227249.html