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

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

Introduction

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

Prototype

boolean getBooleanCellValue();

Source Link

Document

Get the value of the cell as a boolean.

Usage

From source file:com.yqboots.initializer.core.builder.excel.factory.DomainMetadataFactory.java

License:Apache License

/**
 * Gets the properties.//w  w  w .j ava  2s .co m
 *
 * @param row the row of one sheet in the Excel
 * @return one DomainMetadataProperty
 */
private static DomainMetadataProperty getMetadataProperty(final Row row) {
    final DomainMetadataProperty result = new DomainMetadataProperty();

    Cell cell = row.getCell(3);
    if (cell != null) {
        result.setDbColumn(cell.getStringCellValue());
    }
    cell = row.getCell(4);
    if (cell != null) {
        result.setClassField(cell.getStringCellValue());
    }
    cell = row.getCell(5);
    if (cell != null) {
        result.setFieldType(cell.getStringCellValue());
    }
    cell = row.getCell(6);
    if (cell != null && cell.getCellType() == Cell.CELL_TYPE_BOOLEAN) {
        result.setNullable(cell.getBooleanCellValue());
    }
    cell = row.getCell(7);
    if (cell != null && cell.getCellType() == Cell.CELL_TYPE_BOOLEAN) {
        result.setUnique(cell.getBooleanCellValue());
    }
    cell = row.getCell(8);
    if (cell != null) {
        switch (cell.getCellType()) {
        case Cell.CELL_TYPE_NUMERIC:
            result.setDefaultValue(Double.toString(cell.getNumericCellValue()));
            break;
        case Cell.CELL_TYPE_BOOLEAN:
            result.setDefaultValue(Boolean.toString(cell.getBooleanCellValue()));
            break;
        default:
            result.setDefaultValue(cell.getStringCellValue());
        }
    }

    return result;
}

From source file:com.yyl.common.utils.excel.ExcelTools.java

/**
 * ?excel/*from   w  ww .  j ava 2  s .com*/
 * @param cell
 * @return
 */
private static String getCellValue(Cell cell) {
    String cellValue = "";
    DecimalFormat df = new DecimalFormat("#");
    if (cell == null || cell.equals("") || cell.getCellType() == Cell.CELL_TYPE_BLANK) {
        System.out.println(cellValue);
        return cellValue;
    }
    switch (cell.getCellType()) {
    case Cell.CELL_TYPE_STRING:
        cellValue = cell.getRichStringCellValue().getString().trim();
        break;
    case Cell.CELL_TYPE_NUMERIC:
        if (DateUtil.isCellDateFormatted(cell)) {
            cellValue = cell.getDateCellValue().toString();
        } else {
            cellValue = df.format(cell.getNumericCellValue()).toString();
        }
        break;
    case Cell.CELL_TYPE_BOOLEAN:
        cellValue = String.valueOf(cell.getBooleanCellValue()).trim();
        break;
    default:
        cellValue = "";
    }
    return cellValue;
}

From source file:com.zlfun.framework.excel.ExcelUtils.java

private static <T> Map<String, String> genRowMap(Row row, List<String> cols, FormulaEvaluator evaluator) {
    Map<String, String> map = new HashMap<String, String>();
    int j = 0;//from   w  ww .j  a v  a  2s  .co m
    for (String col : cols) {
        Cell cell = row.getCell(j);// ??
        switch (cell.getCellType()) {
        case Cell.CELL_TYPE_BOOLEAN:
            map.put(col, String.valueOf(cell.getBooleanCellValue()));
            break;
        case Cell.CELL_TYPE_NUMERIC:
            map.put(col, String.valueOf(cell.getNumericCellValue()));

            break;
        case Cell.CELL_TYPE_STRING:

            map.put(col, String.valueOf(cell.getStringCellValue()));
            break;
        case Cell.CELL_TYPE_BLANK:
            map.put(col, String.valueOf(""));

            break;
        case Cell.CELL_TYPE_ERROR:
            map.put(col, String.valueOf("error"));
            break;

        // CELL_TYPE_FORMULA will never occur  
        case Cell.CELL_TYPE_FORMULA:

            evaluator.evaluateFormulaCell(cell);
            map.put(col, String.valueOf(cell.getNumericCellValue()));
            break;

        }
        j++;
    }

    return map;
}

From source file:common.ReadExcelData.java

License:Apache License

public String getCellValue(int index, String heading) {
    String cellValue = "";
    try {//from   w  w  w . j  av  a  2  s . c o  m
        sheet = workbook.getSheet(sheetName);
        row = sheet.getRow(0);
        int cellNumber = 0;
        for (Cell cell : row) {
            if (cell.getCellType() == Cell.CELL_TYPE_STRING) {
                if (cell.getRichStringCellValue().getString().trim().equals(heading)) {
                    cellNumber = cell.getColumnIndex();
                }
            }
        }
        row = sheet.getRow(findRow(sheet, index));
        cell = row.getCell(cellNumber);
        switch (cell.getCellType()) {
        case Cell.CELL_TYPE_NUMERIC:
            cellValue = String.valueOf(((long) cell.getNumericCellValue()));
            break;
        case Cell.CELL_TYPE_STRING:
            cellValue = cell.getStringCellValue();
            break;
        case Cell.CELL_TYPE_BOOLEAN:
            cellValue = String.valueOf(cell.getBooleanCellValue());
            break;
        case Cell.CELL_TYPE_BLANK:
            cellValue = null;
        }
    } catch (NullPointerException e) {
        cellValue = null;
    }
    return cellValue;
}

From source file:Controller.ThreadExcelImport.java

private String getStringFromCell(Cell cell) {
    int tipo = cell.getCellType();
    String value = "";
    switch (tipo) {

    //NUMERIC//from ww w .  j av  a 2 s  .  c o m
    case 0:
        DataFormatter df = new DataFormatter();
        // value = df.formatCellValue(row.getCell(columnPos));
        value = String.valueOf(cell.getNumericCellValue()).trim().toLowerCase();
        //at.setString(columnName, value);
        break;
    //STRING
    case 1:
        value = cell.getStringCellValue().trim().toLowerCase();
        //at.setString(columnName, value);
        break;
    // FORMULA

    // BLANK
    case 3:
        value = ""; //row.getCell(columnPos).getStringCellValue();
        //at.setString(columnName, value);
        break;
    // BOOLEAN
    case 4:
        value = String.valueOf(cell.getBooleanCellValue()).trim().toLowerCase();
        //  at.setString(columnName, value);
        break;
    // NONE (ERROR)
    case 5:
        value = cell.getStringCellValue().trim().toLowerCase();
        //at.setString(columnName, value);
        break;

    }
    return value;

    //return  String.valueOf( cell.getNumericCellValue());
}

From source file:coolmap.application.io.external.ImportCOntologyFromXLS.java

@Override
public void configure(File... file) {
    try {/*from  ww w . j av  a  2  s . c  om*/
        File inFile = file[0];
        String fileNameString = inFile.getName().toLowerCase();
        FileInputStream inStream = new FileInputStream(inFile);
        Workbook workbook = null;
        if (fileNameString.endsWith("xls")) {
            workbook = new HSSFWorkbook(inStream);
        } else if (fileNameString.toLowerCase().endsWith("xlsx")) {
            workbook = new XSSFWorkbook(inStream);
        }
        int sheetCount = workbook.getNumberOfSheets();
        String[] sheetNames = new String[sheetCount];
        for (int i = 0; i < sheetNames.length; i++) {
            String sheetName = workbook.getSheetAt(i).getSheetName();

            sheetNames[i] = sheetName == null || sheetName.length() == 0 ? "Untitled" : sheetName;
        }

        DefaultTableModel tableModels[] = new DefaultTableModel[sheetCount];
        Cell cell;
        Row row;

        ArrayList<ArrayList<ArrayList<Object>>> previewData = new ArrayList();
        for (int si = 0; si < sheetCount; si++) {

            //The row iterator automatically skips the blank rows
            //so only need to figure out how many rows to skip; which is nice
            //columns, not the same though
            Sheet sheet = workbook.getSheetAt(si);
            Iterator<Row> rowIterator = sheet.rowIterator();

            int ri = 0;

            ArrayList<ArrayList<Object>> data = new ArrayList<ArrayList<Object>>();

            while (rowIterator.hasNext()) {

                row = rowIterator.next();
                ArrayList<Object> rowData = new ArrayList<>();

                for (int j = 0; j < row.getLastCellNum(); j++) {
                    cell = row.getCell(j);

                    try {
                        if (cell == null) {
                            rowData.add(null);
                        } else if (cell.getCellType() == Cell.CELL_TYPE_BLANK) {
                            rowData.add(null);
                        } else if (cell.getCellType() == Cell.CELL_TYPE_STRING) {
                            rowData.add(cell.getStringCellValue());
                        } else if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
                            rowData.add(cell.getNumericCellValue());
                        } else if (cell.getCellType() == Cell.CELL_TYPE_BOOLEAN) {
                            rowData.add(cell.getBooleanCellValue());
                        } else {
                            rowData.add(cell.toString());
                        }
                    } catch (Exception e) {
                        //
                        CMConsole.logError(" error parsing excel cell: " + cell + ", [" + ri + "," + j + "]");
                        rowData.add(null);
                    }

                }

                data.add(rowData);

                ri++;

                if (ri == previewNum) {
                    break;
                }
            } //end 

            //                System.out.println(data);
            //                now the data is the data
            //                ugh-> this is not a generic importer
            previewData.add(data);

        } //end of loop sheets

        ConfigPanel configPanel = new ConfigPanel(sheetNames, previewData);
        int returnVal = JOptionPane.showConfirmDialog(CoolMapMaster.getCMainFrame(), configPanel,
                "Import from Excel: " + inFile.getAbsolutePath(), JOptionPane.OK_CANCEL_OPTION,
                JOptionPane.PLAIN_MESSAGE, null);

        if (returnVal == JOptionPane.OK_OPTION) {
            proceed = true;

            inStream.close();
            workbook = null;

            //set parameters
            inFile = file[0];
            rowStart = configPanel.getRowStart();
            columnStart = configPanel.getColumnStart();
            sheetIndex = configPanel.getSheetIndex();
            formatIndex = configPanel.getFormatIndex();

        } else {
            //mark operation cancelled
            proceed = false;
        }

    } catch (Exception e) {

    }

}

From source file:coolmap.application.io.external.ImportDataFromXLS.java

@Override
public void importFromFile(File inFile) throws Exception {
    //Ignore the file, choose only a single file
    //I actually don't know the row count
    if (!proceed) {
        throw new Exception("Import from excel was cancelled");
    } else {// www  .  j  av a 2  s.co m
        try {
            String fileNameString = inFile.getName().toLowerCase();
            FileInputStream inStream = new FileInputStream(inFile);
            Workbook workbook = null;
            if (fileNameString.endsWith("xls")) {
                workbook = new HSSFWorkbook(inStream);
            } else if (fileNameString.toLowerCase().endsWith("xlsx")) {
                workbook = new XSSFWorkbook(inStream);
            }

            Sheet sheet = workbook.getSheetAt(sheetIndex);

            int rowCounter = 0;

            //need to first copy the file over
            ArrayList<ArrayList<Object>> data = new ArrayList<ArrayList<Object>>();

            Iterator<Row> rowIterator = sheet.rowIterator();

            while (rowIterator.hasNext()) {
                Row row = rowIterator.next();

                //                    if (rowCounter < rowStart) {
                //                        rowCounter++;
                //                        //import ontology rows
                //                        
                //                        continue;
                //
                //                        //skip first rows
                //                    }
                ArrayList<Object> rowData = new ArrayList<Object>();

                for (int i = 0; i < row.getLastCellNum(); i++) {
                    Cell cell = row.getCell(i);
                    //                        System.out.print(cell + " ");
                    //                        now add data
                    try {
                        if (cell == null) {
                            rowData.add(null);
                        } else if (cell.getCellType() == Cell.CELL_TYPE_BLANK) {
                            rowData.add(null);
                        } else if (cell.getCellType() == Cell.CELL_TYPE_STRING) {
                            rowData.add(cell.getStringCellValue());
                        } else if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
                            rowData.add(cell.getNumericCellValue());
                        } else if (cell.getCellType() == Cell.CELL_TYPE_BOOLEAN) {
                            rowData.add(cell.getBooleanCellValue());
                        } else {
                            rowData.add(cell.toString());
                        }
                    } catch (Exception e) {
                        //
                        CMConsole.logError(" error parsing excel cell: " + cell + ", [" + row + "," + i + "]");
                        rowData.add(null);
                    }

                }

                //                    System.out.println("");
                data.add(rowData);

            }

            //now I have row data
            int rowCount = data.size() - rowStart - 1;
            int columnCount = data.get(0).size() - columnStart - 1;

            DoubleCMatrix matrix = new DoubleCMatrix(Tools.removeFileExtension(inFile.getName()), rowCount,
                    columnCount);
            String[] rowNames = new String[rowCount];
            String[] columnNames = new String[columnCount];

            for (int i = rowStart; i < data.size(); i++) {
                ArrayList row = data.get(i);
                if (i == rowStart) {
                    //first row contains names
                    for (int j = columnStart + 1; j < row.size(); j++) {
                        try {
                            columnNames[j - columnStart - 1] = row.get(j).toString();
                        } catch (Exception e) {
                            columnNames[j - columnStart - 1] = "Untitled " + Tools.randomID();
                        }
                    }
                    continue;
                }

                for (int j = columnStart; j < row.size(); j++) {
                    Object cell = row.get(j);
                    if (j == columnStart) {
                        try {
                            rowNames[i - rowStart - 1] = cell.toString();
                        } catch (Exception e) {
                            rowNames[i - rowStart - 1] = "Untitled" + Tools.randomID();
                        }
                    } else {
                        //set values
                        try {
                            Object value = (Double) row.get(j);
                            if (value == null) {
                                matrix.setValue(i - rowStart - 1, j - columnStart - 1, null);
                            } else if (value instanceof Double) {
                                matrix.setValue(i - rowStart - 1, j - columnStart - 1, (Double) value);
                            } else {
                                matrix.setValue(i - rowStart - 1, j - columnStart - 1, Double.NaN);
                            }
                        } catch (Exception e) {
                            matrix.setValue(i - rowStart - 1, j - columnStart - 1, null);
                        }

                    }
                } //end of iterating columns

            } //end of iterating rows

            //                matrix.printMatrix();
            //

            matrix.setRowLabels(rowNames);
            matrix.setColLabels(columnNames);

            CoolMapObject object = new CoolMapObject();
            object.setName(Tools.removeFileExtension(inFile.getName()));
            object.addBaseCMatrix(matrix);
            ArrayList<VNode> nodes = new ArrayList<VNode>();
            for (Object label : matrix.getRowLabelsAsList()) {
                nodes.add(new VNode(label.toString()));
            }
            object.insertRowNodes(nodes);

            nodes.clear();
            for (Object label : matrix.getColLabelsAsList()) {
                nodes.add(new VNode(label.toString()));
            }
            object.insertColumnNodes(nodes);

            object.setAggregator(new DoubleDoubleMean());
            object.setSnippetConverter(new DoubleSnippet1_3());
            object.setViewRenderer(new NumberToColor(), true);

            object.getCoolMapView().addColumnMap(new ColumnLabels(object));
            object.getCoolMapView().addColumnMap(new ColumnTree(object));
            object.getCoolMapView().addRowMap(new RowLabels(object));
            object.getCoolMapView().addRowMap(new RowTree(object));

            importedCoolMaps.clear();
            importedCoolMaps.add(object);
            ////////////////////////////////////////////////////////////////
            ////////////////////////////////////////////////////////////////
            //
            //let's add COntologies
            if (columnStart > 0) {
                COntology columnOntology = new COntology(
                        Tools.removeFileExtension(inFile.getName()) + " column ontology", null);
                ArrayList<Object> columnLabels = data.get(rowStart); //these are column labels

                for (int i = 0; i < rowStart; i++) {
                    ArrayList ontologyColumn = data.get(i);
                    for (int j = columnStart + 1; j < columnLabels.size(); j++) {
                        Object parent = ontologyColumn.get(j);
                        Object child = columnLabels.get(j);

                        if (parent != null && child != null) {
                            columnOntology.addRelationshipNoUpdateDepth(parent.toString(), child.toString());
                        }

                        //Also need to create presets
                    }
                }

                columnOntology.validate();
                //                    COntologyUtils.printOntology(columnOntology);
                importedOntologies.add(columnOntology);

                //                    need to finish the preset 
            }

            if (rowStart > 0) {
                COntology rowOntology = new COntology(
                        Tools.removeFileExtension(inFile.getName()) + " row ontology", null);

                List rowLabels = Arrays.asList(rowNames);

                for (int j = 0; j < columnStart; j++) {

                    for (int i = rowStart + 1; i < data.size(); i++) {
                        Object parent = data.get(i).get(j);
                        Object child = rowLabels.get(i - rowStart - 1);

                        if (parent != null && child != null) {
                            rowOntology.addRelationshipNoUpdateDepth(parent.toString(), child.toString());
                        }
                    }

                }

                rowOntology.validate();

                COntologyUtils.printOntology(rowOntology);

                importedOntologies.add(rowOntology);
            }

            //                create row and column complex combinatorial ontology (intersections)
        } catch (Exception e) {
            //                e.printStackTrace();
            throw new Exception("File error");
        }

    }
}

From source file:coolmap.application.io.external.ImportDataFromXLS.java

@Override
public void configure(File... file) {
    //need to popup a secondary dialog; this must be done differently

    try {//from  www  . j  ava  2 s  .  c om
        File inFile = file[0];
        String fileNameString = inFile.getName().toLowerCase();

        FileInputStream inStream = new FileInputStream(inFile);

        Workbook workbook = null;
        if (fileNameString.endsWith("xls")) {
            workbook = new HSSFWorkbook(inStream);
        } else if (fileNameString.toLowerCase().endsWith("xlsx")) {
            workbook = new XSSFWorkbook(inStream);
        }

        int sheetCount = workbook.getNumberOfSheets();

        String[] sheetNames = new String[sheetCount];

        for (int i = 0; i < sheetNames.length; i++) {
            String sheetName = workbook.getSheetAt(i).getSheetName();

            sheetNames[i] = sheetName == null || sheetName.length() == 0 ? "Untitled" : sheetName;
        }

        //also need to get the top 100 rows + all columns
        DefaultTableModel tableModels[] = new DefaultTableModel[sheetCount];
        Cell cell;
        Row row;

        ArrayList<ArrayList<ArrayList<Object>>> previewData = new ArrayList();
        for (int si = 0; si < sheetCount; si++) {

            //The row iterator automatically skips the blank rows
            //so only need to figure out how many rows to skip; which is nice
            //columns, not the same though
            Sheet sheet = workbook.getSheetAt(si);
            Iterator<Row> rowIterator = sheet.rowIterator();

            int ri = 0;

            ArrayList<ArrayList<Object>> data = new ArrayList<ArrayList<Object>>();

            while (rowIterator.hasNext()) {

                row = rowIterator.next();
                ArrayList<Object> rowData = new ArrayList<>();

                for (int j = 0; j < row.getLastCellNum(); j++) {
                    cell = row.getCell(j);

                    try {
                        if (cell == null) {
                            rowData.add(null);
                        } else if (cell.getCellType() == Cell.CELL_TYPE_BLANK) {
                            rowData.add(null);
                        } else if (cell.getCellType() == Cell.CELL_TYPE_STRING) {
                            rowData.add(cell.getStringCellValue());
                        } else if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
                            rowData.add(cell.getNumericCellValue());
                        } else if (cell.getCellType() == Cell.CELL_TYPE_BOOLEAN) {
                            rowData.add(cell.getBooleanCellValue());
                        } else {
                            rowData.add(cell.toString());
                        }
                    } catch (Exception e) {
                        //
                        CMConsole.logError(" error parsing excel cell: " + cell + ", [" + ri + "," + j + "]");
                        rowData.add(null);
                    }

                }

                data.add(rowData);

                ri++;

                if (ri == previewNum) {
                    break;
                }
            } //end 

            //                System.out.println(data);
            //                now the data is the data
            //                ugh-> this is not a generic importer
            previewData.add(data);

        } //end of iterating all sheets

        ConfigPanel configPanel = new ConfigPanel(sheetNames, previewData);

        //int returnVal = JOptionPane.showMessageDialog(CoolMapMaster.getCMainFrame(), configPanel);
        int returnVal = JOptionPane.showConfirmDialog(CoolMapMaster.getCMainFrame(), configPanel,
                "Import from Excel: " + inFile.getAbsolutePath(), JOptionPane.OK_CANCEL_OPTION,
                JOptionPane.PLAIN_MESSAGE, null);

        if (returnVal == JOptionPane.OK_OPTION) {
            proceed = true;

            inStream.close();
            workbook = null;

            //set parameters
            inFile = file[0];
            importOntology = configPanel.getImportOntology();
            rowStart = configPanel.getRowStart();
            columnStart = configPanel.getColumnStart();
            sheetIndex = configPanel.getSheetIndex();

        } else {
            //mark operation cancelled
            proceed = false;
        }

    } catch (Exception e) {
        CMConsole.logError(" failed to import numeric matrix data from: " + file);
        e.printStackTrace();
    }
}

From source file:coverageqc.data.DoNotCall.java

public static DoNotCall populate(Row xslxHeadingRow, Row xslxDataRow, Integer calltype) {
    DoNotCall donotcall = new DoNotCall();
    int columnNumber;
    int cellIndex;
    String[] headerArray;/*from  w w  w  . j  a  va2s.  co  m*/
    HashMap<String, Integer> headings = new HashMap<String, Integer>();

    columnNumber = xslxHeadingRow.getLastCellNum();
    headerArray = new String[columnNumber];

    Iterator<Cell> cellIterator = xslxHeadingRow.cellIterator();
    while (cellIterator.hasNext()) {
        Cell cell = cellIterator.next();
        cellIndex = cell.getColumnIndex();
        switch (cell.getCellType()) {
        case Cell.CELL_TYPE_BOOLEAN:
            headerArray[cellIndex] = Boolean.toString(cell.getBooleanCellValue());
            break;
        case Cell.CELL_TYPE_NUMERIC:
            headerArray[cellIndex] = Double.toString(cell.getNumericCellValue());
            break;
        case Cell.CELL_TYPE_STRING:
            headerArray[cellIndex] = cell.getStringCellValue();
            break;
        default:
            headerArray[cellIndex] = "";
        }

    } //end while celliterator

    for (int x = 0; x < headerArray.length; x++) {
        headings.put(headerArray[x].substring(0, headerArray[x].indexOf("_")), x);
    }

    //String[] dataArray = xslxDataLine.split("\t");
    if (xslxDataRow.getCell(headings.get("HGVSc")) != null) {
        donotcall.hgvsc = xslxDataRow.getCell(headings.get("HGVSc").intValue()).getStringCellValue();

    }
    //donotcall.hgvsp = xslxDataRow.getCell(headings.get("HGVSp").intValue()).getStringCellValue();
    if (xslxDataRow.getCell(headings.get("ENSP")) != null) {
        donotcall.ensp = xslxDataRow.getCell(headings.get("ENSP").intValue()).getStringCellValue();
    }
    if (xslxDataRow.getCell(headings.get("Transcript")) != null) {
        donotcall.transcript = xslxDataRow.getCell(headings.get("Transcript").intValue()).getStringCellValue();
    } else {
        System.out.println(
                "Transcript_27 column entry is negative!  This is essential to do not call! Do not call list needs to be fixed!  Crashing to prevent abnormal behavior!");
        System.exit(1);
    }
    donotcall.coordinate = (long) xslxDataRow.getCell(headings.get("Coordinate").intValue())
            .getNumericCellValue();

    // CallType is the page of the xlsx :
    // 1 => Always_Not_Real
    // 2 => Not_Real_When_Percentage_Low
    // 3 => Undetermined_Importance
    if (calltype == 1) {
        donotcall.callType = "Don't call, always";
    } else if (calltype == 2) {
        donotcall.callType = "If percentage low, don't call";

    } else {
        donotcall.callType = "On lab list, Unknown significance";
    }

    return donotcall;
}

From source file:csv.impl.ExcelReader.java

License:Open Source License

/**
 * Returns the value of the specified cell.
 * If the cell contained// ww w .j a  v a  2s .  c  om
 * a formula, the formula is evaluated before returning the row.
 * @param cell cell object
 * @return value of cell
 */
public Object getValue(Cell cell) {
    if (cell == null)
        return null;

    int cellType = cell.getCellType();
    if (cellType == Cell.CELL_TYPE_FORMULA && !isEvaluateFormulas()) {
        cellType = cell.getCachedFormulaResultType();
    }

    switch (cellType) {
    case Cell.CELL_TYPE_STRING:
        return cell.getStringCellValue();
    case Cell.CELL_TYPE_NUMERIC:
        if (DateUtil.isCellDateFormatted(cell)) {
            return cell.getDateCellValue();
        } else {
            return cell.getNumericCellValue();
        }
    case Cell.CELL_TYPE_BLANK:
        return null;
    case Cell.CELL_TYPE_BOOLEAN:
        return cell.getBooleanCellValue();
    case Cell.CELL_TYPE_FORMULA:
        return evaluateCellValue(cell);
    case Cell.CELL_TYPE_ERROR:
        return cell.getErrorCellValue();
    }
    return null;
}