private void handleStringCell(StringBuilder text, Cell cell) { String contents = cell.getRichStringCellValue().getString(); checkMaxTextSize(text, contents); text.append(contents); }
for(Cell cell : row) { if(cell.getCellType() == Cell.CELL_TYPE_FORMULA) { System.out.println("Formula is " + cell.getCellFormula()); switch(cell.getCachedFormulaResultType()) { case Cell.CELL_TYPE_NUMERIC: System.out.println("Last evaluated as: " + cell.getNumericCellValue()); break; case Cell.CELL_TYPE_STRING: System.out.println("Last evaluated as \"" + cell.getRichStringCellValue() + "\""); break; } } }
/** * Looks for text in the cell that should be unicode, like α and provides the * unicode version of it. * *@param cell The cell to check for unicode values *@return translated to unicode */ public static Cell translateUnicodeValues(Cell cell) { String s = cell.getRichStringCellValue().getString(); boolean foundUnicode = false; String lowerCaseStr = s.toLowerCase(Locale.ROOT); for (UnicodeMapping entry : unicodeMappings) { String key = entry.entityName; if (lowerCaseStr.contains(key)) { s = s.replaceAll(key, entry.resolvedValue); foundUnicode = true; } } if (foundUnicode) { cell.setCellValue(cell.getRow().getSheet().getWorkbook().getCreationHelper() .createRichTextString(s)); } return cell; }
return new CellValue(cell.getNumericCellValue()); case STRING: return new CellValue(cell.getRichStringCellValue().getString()); case BLANK: return null;
RichTextString rt = cell.getRichStringCellValue(); String[] lines = rt.getString().split("\\n"); for (String line : lines) {
return cell.getRichStringCellValue().getString();
for (Cell cell : row) { if(cell.getCellType() == CellType.STRING) { HSSFRichTextString rtr = (HSSFRichTextString)cell.getRichStringCellValue(); UnicodeString u = rtr.getRawUnicodeString();
private static int findRow(HSSFSheet sheet, String cellContent) { for (Row row : sheet) { for (Cell cell : row) { if (cell.getCellType() == Cell.CELL_TYPE_STRING) { if (cell.getRichStringCellValue().getString().trim().equals(cellContent)) { return row.getRowNum(); } } } } return 0; }
@Nullable public static RichTextString getCellValueRichText (@Nullable final Cell aCell) { return aCell == null ? null : aCell.getRichStringCellValue (); }
@Nullable public static RichTextString getCellValueRichText (@Nullable final Cell aCell) { return aCell == null ? null : aCell.getRichStringCellValue (); }
@SuppressWarnings({ "unchecked", "rawtypes" }) private static Object convertString(Cell cell, String emptyMarker, String nullMarker, Converter<?, ?> stringPreprocessor) { String content = cell.getRichStringCellValue().getString(); if (content != null) { if (content.equals(emptyMarker) || content.equals("'")) content = ""; if (content.equals(nullMarker)) content = null; } return (stringPreprocessor != null ? ((Converter) stringPreprocessor).convert(content) : content); }
/** * Checks if cell content matches. */ private void isCellContentMatches(Locator loc1, Locator loc2) { // TODO: check for null and non-rich-text cells String str1 = loc1.cell.getRichStringCellValue().getString(); String str2 = loc2.cell.getRichStringCellValue().getString(); if (!str1.equals(str2)) { addMessage(loc1,loc2,CELL_DATA_DOES_NOT_MATCH,str1,str2); } }
@SuppressWarnings({ "unchecked", "rawtypes" }) private static Object convertString(Cell cell, String emptyMarker, String nullMarker, Converter<?, ?> stringPreprocessor) { String content = cell.getRichStringCellValue().getString(); if (content != null) { if (content.equals(emptyMarker) || content.equals("'")) content = ""; if (content.equals(nullMarker)) content = null; } return (stringPreprocessor != null ? ((Converter) stringPreprocessor).convert(content) : content); }
private void handleStringCell(StringBuilder text, Cell cell) { String contents = cell.getRichStringCellValue().getString(); checkMaxTextSize(text, contents); text.append(contents); }
public static Object getValue2007(Cell cell, MirrorPropertyEntity property) { if (cell == null || property == null) { return null; } cell.setCellType(Cell.CELL_TYPE_STRING); Object value = StringUtils.trim(cell.getRichStringCellValue().getString()); return value; }
private String getStringValue(final Cell cell) { switch (cell.getCellType()) { case NUMERIC: return String.valueOf(cell.getNumericCellValue()); default: return cell.getRichStringCellValue().getString(); } }
private String getStringValue(final Cell cell) { switch (cell.getCellType()) { case NUMERIC: return String.valueOf(cell.getNumericCellValue()); default: return cell.getRichStringCellValue().getString(); } }
public String fetchStringField(int fieldNumber) { Cell cell = sheet.getRow(rowNumber).getCell(getColumnMapping(fieldNumber).getColumn(0).getPosition()); if (cell == null) { return null; } return cell.getRichStringCellValue().getString(); }
private static void replacePropertyInCell(Cell cell, String oldProperty, String newProperty) { if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING) { String cellValue = cell.getRichStringCellValue().getString(); String newValue = cellValue.replaceAll(oldProperty, newProperty); cell.setCellValue(cell.getSheet().getWorkbook().getCreationHelper().createRichTextString(newValue)); } }
public Formula parseCellFormula(){ if( cell.getPoiCell() != null && (cell.getPoiCell().getCellType() == org.apache.poi.ss.usermodel.Cell.CELL_TYPE_STRING)) { cell.setPoiCellValue( cell.getPoiCell().getRichStringCellValue().getString() ); if( cell.getPoiCellValue().startsWith(configuration.getStartFormulaToken()) && cell.getPoiCellValue().lastIndexOf(configuration.getEndFormulaToken()) > 0 ){ parseFormula(); } } return cell.getFormula(); }