Apache POI for Excel中的替代getCellType()是什么?

时间:2016-10-27 03:26:59

标签: java apache-poi

我想要更改这些弃用的方法:

    if (sheet.getRow(1).getCell(1).getCellType() == XSSFCell.CELL_TYPE_BLANK) {
        testSuite = "";
    } else if (sheet.getRow(1).getCell(1).getCellType() == XSSFCell.CELL_TYPE_NUMERIC) {
        double password1 = sheet.getRow(1).getCell(1).getNumericCellValue();
        testSuite = String.valueOf(password1);
    } else if (sheet.getRow(1).getCell(1).getCellType() == XSSFCell.CELL_TYPE_STRING) {
        testSuite = sheet.getRow(1).getCell(1).getStringCellValue();
    } else if (sheet.getRow(1).getCell(1).getCellType() == XSSFCell.CELL_TYPE_FORMULA) {
        testSuite = sheet.getRow(1).getCell(1).getStringCellValue();
    }

enter image description here 我看到内部来源:

/**
 * Return the cell type.
 * 
 * Will return {@link CellType} in a future version of POI.
 * For forwards compatibility, do not hard-code cell type literals in your code.
 *
 * @return the cell type
 * @deprecated 3.15. Will return a {@link CellType} enum in the future.
 */
@Override
public int getCellType() {
    return getCellTypeEnum().getCode();
}

0 个答案:

没有答案