本文整理了Java中org.apache.poi.ss.usermodel.Cell.getRichStringCellValue()
方法的一些代码示例,展示了Cell.getRichStringCellValue()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Cell.getRichStringCellValue()
方法的具体详情如下:
包路径:org.apache.poi.ss.usermodel.Cell
类名称:Cell
方法名:getRichStringCellValue
[英]Get the value of the cell as a XSSFRichTextString
For numeric cells we throw an exception. For blank cells we return an empty string. For formula cells we return the pre-calculated value if a string, otherwise an exception.
[中]以XSSFRichTextString形式获取单元格的值
对于数值单元格,我们抛出一个异常。对于空白单元格,我们返回一个空字符串。对于公式单元格,如果是字符串,则返回预先计算的值,否则返回异常。
代码示例来源:origin: org.apache.poi/poi-ooxml
private void handleStringCell(StringBuilder text, Cell cell) {
String contents = cell.getRichStringCellValue().getString();
checkMaxTextSize(text, contents);
text.append(contents);
}
代码示例来源:origin: stackoverflow.com
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;
}
}
}
代码示例来源:origin: org.apache.poi/poi
/**
* 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;
}
代码示例来源:origin: org.apache.poi/poi
return new CellValue(cell.getNumericCellValue());
case STRING:
return new CellValue(cell.getRichStringCellValue().getString());
case BLANK:
return null;
代码示例来源:origin: org.apache.poi/poi
RichTextString rt = cell.getRichStringCellValue();
String[] lines = rt.getString().split("\\n");
for (String line : lines) {
代码示例来源:origin: org.apache.poi/poi
return cell.getRichStringCellValue().getString();
代码示例来源:origin: org.apache.poi/poi
for (Cell cell : row) {
if(cell.getCellType() == CellType.STRING) {
HSSFRichTextString rtr = (HSSFRichTextString)cell.getRichStringCellValue();
UnicodeString u = rtr.getRawUnicodeString();
代码示例来源:origin: stackoverflow.com
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;
}
代码示例来源:origin: com.phloc/phloc-poi
@Nullable
public static RichTextString getCellValueRichText (@Nullable final Cell aCell)
{
return aCell == null ? null : aCell.getRichStringCellValue ();
}
代码示例来源:origin: com.helger/ph-poi
@Nullable
public static RichTextString getCellValueRichText (@Nullable final Cell aCell)
{
return aCell == null ? null : aCell.getRichStringCellValue ();
}
代码示例来源:origin: org.databene/databene-webdecs
@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);
}
代码示例来源:origin: org.apache.poi/poi-examples
/**
* 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);
}
}
代码示例来源:origin: org.databene/databene-formats
@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);
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi
private void handleStringCell(StringBuilder text, Cell cell) {
String contents = cell.getRichStringCellValue().getString();
checkMaxTextSize(text, contents);
text.append(contents);
}
代码示例来源:origin: com.github.mg365/mg-common
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;
}
代码示例来源:origin: com.namics.oss.java.tools/java-tools
private String getStringValue(final Cell cell) {
switch (cell.getCellType()) {
case NUMERIC:
return String.valueOf(cell.getNumericCellValue());
default:
return cell.getRichStringCellValue().getString();
}
}
代码示例来源:origin: com.namics.oss.java.tools/java-tools
private String getStringValue(final Cell cell) {
switch (cell.getCellType()) {
case NUMERIC:
return String.valueOf(cell.getNumericCellValue());
default:
return cell.getRichStringCellValue().getString();
}
}
代码示例来源:origin: org.datanucleus/datanucleus-excel
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();
}
代码示例来源:origin: net.sf.jxls/jxls-core
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));
}
}
代码示例来源:origin: net.sf.jxls/jxls-core
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();
}
内容来源于网络,如有侵权,请联系作者删除!