本文整理汇总了Java中org.apache.poi.hssf.usermodel.HSSFCell.getCachedFormulaResultType方法的典型用法代码示例。如果您正苦于以下问题:Java HSSFCell.getCachedFormulaResultType方法的具体用法?Java HSSFCell.getCachedFormulaResultType怎么用?Java HSSFCell.getCachedFormulaResultType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.poi.hssf.usermodel.HSSFCell
的用法示例。
在下文中一共展示了HSSFCell.getCachedFormulaResultType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFormulaValue
import org.apache.poi.hssf.usermodel.HSSFCell; //导入方法依赖的package包/类
/**
* Get the formula value from a cell
*
* @param myCell
* @return
* @throws Exception
*/
private static String getFormulaValue(HSSFCell myCell) throws Exception {
String cellData = "";
if (myCell.getCachedFormulaResultType() == HSSFCell.CELL_TYPE_STRING || myCell.getCellType() == HSSFCell.CELL_TYPE_BOOLEAN) {
cellData += myCell.getRichStringCellValue() + CVS_SEPERATOR_CHAR;
} else if (myCell.getCachedFormulaResultType() == HSSFCell.CELL_TYPE_NUMERIC) {
cellData += getNumericValue(myCell) + CVS_SEPERATOR_CHAR;
}
return cellData;
}
示例2: isTextEmpty
import org.apache.poi.hssf.usermodel.HSSFCell; //导入方法依赖的package包/类
protected boolean isTextEmpty( HSSFCell cell )
{
final String value;
switch ( cell.getCellType() )
{
case HSSFCell.CELL_TYPE_STRING:
// XXX: enrich
value = cell.getRichStringCellValue().getString();
break;
case HSSFCell.CELL_TYPE_FORMULA:
switch ( cell.getCachedFormulaResultType() )
{
case HSSFCell.CELL_TYPE_STRING:
HSSFRichTextString str = cell.getRichStringCellValue();
if ( str == null || str.length() <= 0 )
return false;
value = str.toString();
break;
case HSSFCell.CELL_TYPE_NUMERIC:
HSSFCellStyle style = cell.getCellStyle();
if ( style == null )
{
return false;
}
value = ( _formatter.formatRawCellContents(
cell.getNumericCellValue(), style.getDataFormat(),
style.getDataFormatString() ) );
break;
case HSSFCell.CELL_TYPE_BOOLEAN:
value = String.valueOf( cell.getBooleanCellValue() );
break;
case HSSFCell.CELL_TYPE_ERROR:
value = ErrorEval.getText( cell.getErrorCellValue() );
break;
default:
value = ExcelToHtmlUtils.EMPTY;
break;
}
break;
case HSSFCell.CELL_TYPE_BLANK:
value = ExcelToHtmlUtils.EMPTY;
break;
case HSSFCell.CELL_TYPE_NUMERIC:
value = _formatter.formatCellValue( cell );
break;
case HSSFCell.CELL_TYPE_BOOLEAN:
value = String.valueOf( cell.getBooleanCellValue() );
break;
case HSSFCell.CELL_TYPE_ERROR:
value = ErrorEval.getText( cell.getErrorCellValue() );
break;
default:
return true;
}
return ExcelToHtmlUtils.isEmpty( value );
}