List of usage examples for org.apache.poi.ss.usermodel CellType ERROR
CellType ERROR
To view the source code for org.apache.poi.ss.usermodel CellType ERROR.
Click Source Link
From source file:cn.edu.zjnu.acm.judge.util.excel.ExcelUtil.java
License:Apache License
private static void create(Stream<?> stream, Row row) { AtomicInteger counter = new AtomicInteger(); stream.forEach(value -> {/*from w ww . j a va2 s. c o m*/ if (value != null) { if (value instanceof String) { row.createCell(counter.getAndIncrement(), CellType.STRING).setCellValue((String) value); } else if (value instanceof Number) { row.createCell(counter.getAndIncrement(), CellType.NUMERIC) .setCellValue(((Number) value).doubleValue()); } else if (value instanceof Boolean) { row.createCell(counter.getAndIncrement(), CellType.BOOLEAN).setCellValue((Boolean) value); } else if (value instanceof Date) { row.createCell(counter.getAndIncrement(), CellType.NUMERIC).setCellValue((Date) value); } else if (value instanceof Calendar) { row.createCell(counter.getAndIncrement(), CellType.NUMERIC).setCellValue((Calendar) value); } else { row.createCell(counter.getAndIncrement(), CellType.ERROR); } } else { row.createCell(counter.getAndIncrement(), CellType.BLANK); } }); }
From source file:com.cloudera.sa.ExcelRecordReader.java
License:Apache License
private Text getCellValue(Cell cell) { Text out = new Text(); CellType cellType = cell.getCellTypeEnum(); if (cellType == CellType.STRING) { out.set(cell.getStringCellValue()); } else if (cellType == CellType.NUMERIC) { out.set(String.valueOf(cell.getNumericCellValue())); } else if (cellType == CellType.FORMULA) { out.set(cell.getCellFormula());/* www . j a va2s.c o m*/ } else if (cellType == CellType.ERROR) { out.set(String.valueOf(cell.getErrorCellValue())); } else if (cellType == CellType.BOOLEAN) { out.set(String.valueOf(cell.getBooleanCellValue())); } else { out.set(""); } return out; }
From source file:com.funtl.framework.smoke.core.commons.excel.ImportExcel.java
License:Apache License
/** * ??/*from ww w . jav a 2 s. c o m*/ * * @param row ? * @param column ??? * @return ? */ @SuppressWarnings("deprecation") public Object getCellValue(Row row, int column) { Object val = ""; try { Cell cell = row.getCell(column); if (cell != null) { if (cell.getCellTypeEnum() == CellType.NUMERIC) { val = cell.getNumericCellValue(); } else if (cell.getCellTypeEnum() == CellType.STRING) { val = cell.getStringCellValue(); } else if (cell.getCellTypeEnum() == CellType.FORMULA) { val = cell.getCellFormula(); } else if (cell.getCellTypeEnum() == CellType.BOOLEAN) { val = cell.getBooleanCellValue(); } else if (cell.getCellTypeEnum() == CellType.ERROR) { val = cell.getErrorCellValue(); } } } catch (Exception e) { return val; } return val; }
From source file:de.jlo.talendcomp.excel.SpreadsheetNamedCellInput.java
License:Apache License
public Object getCellValue() { if (currentNamedCell != null) { // cell.getCellTypeEnum() == CellType.BLANK if (currentNamedCell.getCellTypeEnum() == CellType.BLANK) { valueClass = null;// w w w. ja v a 2 s. c o m return null; } else if (currentNamedCell.getCellTypeEnum() == CellType.BOOLEAN) { valueClass = "java.lang.Boolean"; return currentNamedCell.getBooleanCellValue(); } else if (currentNamedCell.getCellTypeEnum() == CellType.ERROR) { valueClass = null; return null; } else if (currentNamedCell.getCellTypeEnum() == CellType.FORMULA) { valueClass = "java.lang.String"; return getDataFormatter().formatCellValue(currentNamedCell, getFormulaEvaluator()); } else if (currentNamedCell.getCellTypeEnum() == CellType.NUMERIC) { if (DateUtil.isCellDateFormatted(currentNamedCell)) { valueClass = "java.util.Date"; return currentNamedCell.getDateCellValue(); } else { valueClass = "java.lang.Double"; return currentNamedCell.getNumericCellValue(); } } else if (currentNamedCell.getCellTypeEnum() == CellType.STRING) { valueClass = "java.lang.String"; return currentNamedCell.getStringCellValue(); } else { valueClass = null; return null; } } else { valueClass = null; return null; } }
From source file:de.jlo.talendcomp.excel.SpreadsheetReferencedCellInput.java
License:Apache License
private boolean fetchCurrentCellValue(Cell cell) { if (cell != null) { currentCell = cell;//from www . j ava 2 s . c om currentCellValueString = getStringCellValue(cell); Comment comment = cell.getCellComment(); if (comment != null) { currentCellComment = comment.getString().getString(); currentCellCommentAuthor = comment.getAuthor(); } CellType cellType = cell.getCellTypeEnum(); if (cellType == CellType.BLANK) { currentCellValueClassName = "Object"; } else if (cellType == CellType.STRING) { currentCellValueClassName = "String"; currentCellValueObject = currentCellValueString; } else if (cellType == CellType.BOOLEAN) { currentCellValueClassName = "Boolean"; currentCellValueBool = cell.getBooleanCellValue(); currentCellValueObject = currentCellValueBool; } else if (cellType == CellType.ERROR) { currentCellValueClassName = "Byte"; currentCellValueObject = cell.getErrorCellValue(); } else if (cellType == CellType.FORMULA) { currentCellValueClassName = "String"; currentCellFormula = cell.getCellFormula(); currentCellValueString = getDataFormatter().formatCellValue(cell, getFormulaEvaluator()); currentCellValueObject = currentCellValueString; } else if (cellType == CellType.NUMERIC) { if (DateUtil.isCellDateFormatted(cell)) { currentCellValueClassName = "java.util.Date"; currentCellValueDate = cell.getDateCellValue(); currentCellValueObject = currentCellValueDate; } else { currentCellValueClassName = "Double"; currentCellValueNumber = cell.getNumericCellValue(); currentCellValueObject = currentCellValueNumber; } } currentCellBgColor = getBgColor(cell); currentCellFgColor = getFgColor(cell); return currentCellValueObject != null; } else { return false; } }
From source file:org.tiefaces.components.websheet.utility.CellUtility.java
License:MIT License
/** * return cell value with format.//from w ww .j a v a2 s . c o m * * @param poiCell * cell. * @param formulaEvaluator * formula evaluator. * @param dataFormatter * data formatter. * @return cell string value with format. */ @SuppressWarnings("deprecation") public static String getCellValueWithFormat(final Cell poiCell, final FormulaEvaluator formulaEvaluator, final DataFormatter dataFormatter) { if (poiCell == null) { return null; } String result; try { CellType cellType = poiCell.getCellTypeEnum(); if (cellType == CellType.FORMULA) { cellType = formulaEvaluator.evaluate(poiCell).getCellTypeEnum(); } if (cellType == CellType.ERROR) { result = ""; } else { result = dataFormatter.formatCellValue(poiCell, formulaEvaluator); } } catch (Exception e) { LOG.log(Level.SEVERE, "Web Form WebFormHelper getCellValue Error row = " + poiCell.getRowIndex() + " column = " + poiCell.getColumnIndex() + " error = " + e.getLocalizedMessage() + "; Change return result to blank", e); result = ""; } return result; }
From source file:ru.icc.cells.ssdc.DataLoader.java
License:Apache License
private void fillCell(CCell cell, Cell excelCell) { String rawTextualContent = null; CellType cellType = null;/*ww w . ja v a 2s . c o m*/ String text = null; if (withoutSuperscript) { if (hasSuperscriptText(excelCell)) { text = getNotSuperscriptText(excelCell); } else { text = getText(excelCell); } } else { text = getText(excelCell); } cell.setText(text); rawTextualContent = getFormatCellValue(excelCell); cell.setRawText(rawTextualContent); switch (excelCell.getCellType()) { case Cell.CELL_TYPE_NUMERIC: if (DateUtil.isCellDateFormatted(excelCell)) { //rawTextualContent = "DATE"; // TODO - ? cellType = CellType.DATE; } else { cellType = CellType.NUMERIC; } break; case Cell.CELL_TYPE_STRING: cellType = CellType.STRING; break; case Cell.CELL_TYPE_BOOLEAN: cellType = CellType.BOOLEAN; break; case Cell.CELL_TYPE_FORMULA: cellType = CellType.FORMULA; break; case Cell.CELL_TYPE_BLANK: cellType = CellType.BLANK; break; case Cell.CELL_TYPE_ERROR: cellType = CellType.ERROR; break; } cell.setId(this.cellCount); cell.setCellType(cellType); int height = excelCell.getRow().getHeight(); cell.setHeight(height); int width = excelCell.getSheet().getColumnWidth(excelCell.getColumnIndex()); cell.setWidth(width); CellStyle excelCellStyle = excelCell.getCellStyle(); CStyle cellStyle = cell.getStyle(); fillCellStyle(cellStyle, excelCellStyle); String reference = new CellReference(excelCell).formatAsString(); cell.setProvenance(reference); this.cellCount++; }