POI cell.setCellType() obsolete alternative

POI cell.setCellType() alternative

When using poi to read excell cell data, you need to specify the format, otherwise the report may be like:

Cannot get a STRING value from a NUMERIC cell

Such a mistake, but

r.getCell(0).setCellType();

This method is outdated (=.=#), click in to find out if there is an alternative, and see this line of comments:

/**If what you want to do is get a String value for your numeric cell, stop! This is not the way to do it. Instead, for fetching the string value of a numeric or boolean or date cell, use DataFormatter instead.**/

When you need to get data of type String, you can use a code in the form of the following:

String a = dataFormatter.formatCellValue(r.getCell(0));

Guess you like

Origin blog.csdn.net/qq_42026590/article/details/115001759