Example usage for org.apache.poi.ss.usermodel Cell getRichStringCellValue

List of usage examples for org.apache.poi.ss.usermodel Cell getRichStringCellValue

Introduction

In this page you can find the example usage for org.apache.poi.ss.usermodel Cell getRichStringCellValue.

Prototype

RichTextString getRichStringCellValue();

Source Link

Document

Get the value of the cell as a XSSFRichTextString

For numeric cells we throw an exception.

Usage

From source file:Utilities.ExcelTools.java

private static void extractString(ArrayList<String> errors, ArrayList<String> texts, Cell cell) {
    if (cell == null) {
        errors.add(missingData());/*from  ww  w.ja  va  2  s  .  c om*/
    } else if (cell.getCellType() != Cell.CELL_TYPE_STRING) {
        errors.add(wrongFormat(cell));
    } else {
        String text = cell.getRichStringCellValue().toString();
        if (text.isEmpty()) {
            errors.add(missingData(cell));
        } else {
            texts.add(text);
        }
    }
}

From source file:utilities.TableReader.java

private static int[] getExcelColumns(XSSFSheet sheet, ArrayList<TableMetaData> meta) throws UploadException {
    int[] columns = Tools.defaultIntArray(meta.size() + 1);

    Row row = sheet.getRow(0);//from  ww w .j ava  2  s  . co  m
    for (int i = row.getFirstCellNum(); i < row.getLastCellNum(); i++) {
        Cell cell = row.getCell(i);
        String colName = cell.getRichStringCellValue().toString();

        checkColumn(columns, colName, i, meta);
    }

    if (Tools.contains(columns, -1)) {
        throw new UploadException(UploadException.MISSING_COLUMNS);
    }

    return columns;
}

From source file:utilities.TableReader.java

private static String getCellContents(Cell cell) {
    if (cell == null)
        return "";
    if (cell.getCellType() == Cell.CELL_TYPE_STRING) {
        return cell.getRichStringCellValue().toString();
    }//from  w  w  w  . jav  a 2 s  .com
    return cell.getNumericCellValue() + "";
}

From source file:xlsParser.hffsimpl.SSReader.java

private String cellToString(Cell c) {
    if (c == null)
        return "";

    switch (c.getCellType()) {
    case Cell.CELL_TYPE_NUMERIC:
        return Double.toString(c.getNumericCellValue());
    case Cell.CELL_TYPE_STRING:
        return c.getStringCellValue();
    case Cell.CELL_TYPE_FORMULA:
        switch (c.getCachedFormulaResultType()) {
        case Cell.CELL_TYPE_NUMERIC:
            return Double.toString(c.getNumericCellValue());
        case Cell.CELL_TYPE_STRING:
            return c.getRichStringCellValue().getString();
        }/*  w ww  . j av a  2 s .  c  o  m*/
        break;
    }

    return "";
}