本文整理汇总了Java中org.apache.poi.xssf.usermodel.XSSFCell.CELL_TYPE_BOOLEAN属性的典型用法代码示例。如果您正苦于以下问题:Java XSSFCell.CELL_TYPE_BOOLEAN属性的具体用法?Java XSSFCell.CELL_TYPE_BOOLEAN怎么用?Java XSSFCell.CELL_TYPE_BOOLEAN使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.poi.xssf.usermodel.XSSFCell
的用法示例。
在下文中一共展示了XSSFCell.CELL_TYPE_BOOLEAN属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCellValue
/**
* Gets the cell value.
*
* @param cell the cell
* @return the cell value
*/
private String getCellValue( XSSFCell cell )
{
if (cell != null)
{
switch (cell.getCellType())
{
case XSSFCell.CELL_TYPE_BLANK:
return null;
case XSSFCell.CELL_TYPE_BOOLEAN:
return String.valueOf( cell.getBooleanCellValue() );
case XSSFCell.CELL_TYPE_NUMERIC:
return String.valueOf( ( int ) cell.getNumericCellValue() );
case XSSFCell.CELL_TYPE_STRING:
return cell.getRichStringCellValue().toString();
}
}
return null;
}
示例2: getCellValue
/**
* Gets the cell value.
*
* @param cell the cell
* @return the cell value
*/
private String getCellValue( XSSFCell cell )
{
if (cell != null)
{
switch (cell.getCellType())
{
case XSSFCell.CELL_TYPE_BLANK:
return null;
case XSSFCell.CELL_TYPE_BOOLEAN:
return String.valueOf( cell.getBooleanCellValue() );
case XSSFCell.CELL_TYPE_NUMERIC:
return String.valueOf( cell.getNumericCellValue() );
case XSSFCell.CELL_TYPE_STRING:
return cell.getRichStringCellValue().toString();
}
}
return null;
}
示例3: getCellValue
/**
* Gets the cell value.
*
* @param cell the cell
* @return the cell value
*/
private String getCellValue( XSSFCell cell )
{
if (cell != null)
{
switch (cell.getCellType())
{
case XSSFCell.CELL_TYPE_BLANK:
return null;
case XSSFCell.CELL_TYPE_BOOLEAN:
return String.valueOf( cell.getBooleanCellValue() );
case XSSFCell.CELL_TYPE_NUMERIC:
{
String useValue = String.valueOf( cell.getNumericCellValue() );
if ( useValue.endsWith( ".0" ) )
return useValue.split( "\\." )[0];
else
return useValue;
}
case XSSFCell.CELL_TYPE_STRING:
return cell.getRichStringCellValue().toString();
}
}
return null;
}
示例4: getCellValue
private String getCellValue( XSSFCell cell )
{
if (cell != null )
{
switch (cell.getCellType())
{
case XSSFCell.CELL_TYPE_BLANK:
return null;
case XSSFCell.CELL_TYPE_BOOLEAN:
return String.valueOf( cell.getBooleanCellValue() );
case XSSFCell.CELL_TYPE_NUMERIC:
return String.valueOf( cell.getNumericCellValue() );
case XSSFCell.CELL_TYPE_STRING:
return cell.getRichStringCellValue().toString();
}
}
return null;
}
示例5: stringValueOf
protected String stringValueOf(CellValue value) {
switch (value.getCellType()) {
case XSSFCell.CELL_TYPE_STRING:
return value.getStringValue();
case XSSFCell.CELL_TYPE_NUMERIC:
return String.valueOf(value.getNumberValue());
case XSSFCell.CELL_TYPE_BLANK:
return "";
case XSSFCell.CELL_TYPE_BOOLEAN:
return String.valueOf(value.getBooleanValue());
case XSSFCell.CELL_TYPE_ERROR:
return "error";
default:
return "unknown";
}
}
示例6: getStrCellVal
/**
* 获取单元格字符串值
*
* @param cell
* @return
*
*/
public static String getStrCellVal(XSSFCell cell) {
if (cell == null) {
// 如果参数对象为空,
// 则直接退出!
return null;
}
switch (cell.getCellType()) {
case XSSFCell.CELL_TYPE_STRING:
return cell.getStringCellValue();
case XSSFCell.CELL_TYPE_BOOLEAN:
return cell.getBooleanCellValue() ? "true" : "false";
default:
// 抛出异常
throw new XlsxTmplError(MessageFormat.format(
ERR_CELL_TYPE,
getSheetIndex(cell) + 1,
getSheetName(cell),
String.valueOf(cell.getRowIndex() + 1),
getColName(cell.getColumnIndex()),
String.class.getName(),
getCellTypeName(cell)
));
}
}
示例7: getCellTypeName
/**
* 获取单元格类型名称
*
* @param cell
* @return
*
*/
public static String getCellTypeName(XSSFCell cell) {
if (cell == null) {
return "null";
}
switch (cell.getCellType()) {
case XSSFCell.CELL_TYPE_BLANK: return "CELL_TYPE_BLANK";
case XSSFCell.CELL_TYPE_BOOLEAN: return "CELL_TYPE_BOOLEAN";
case XSSFCell.CELL_TYPE_ERROR: return "CELL_TYPE_ERROR";
case XSSFCell.CELL_TYPE_FORMULA: return "CELL_TYPE_FORMULA";
case XSSFCell.CELL_TYPE_NUMERIC: return "CELL_TYPE_NUMERIC";
case XSSFCell.CELL_TYPE_STRING: return "CELL_TYPE_STRING";
default: return "unknown";
}
}
示例8: cellValues2String
/**
* Get the value of the excel-cell as String.
*
* @param workbook
* workbook (excel) for evaluating cell formulas
* @param cell
* cell (excel)
*
* @return the value of the excel-cell as String
*/
static String cellValues2String(XSSFWorkbook workbook, XSSFCell cell) {
if (cell == null) {
return null;
}
switch (cell.getCellType()) {
case XSSFCell.CELL_TYPE_NUMERIC:
if (HSSFDateUtil.isCellDateFormatted(cell)) {
return new SimpleDateFormat(JExUnitConfig.getStringProperty(JExUnitConfig.ConfigKey.DATE_PATTERN))
.format(cell.getDateCellValue());
} else {
return String.valueOf(cell.getNumericCellValue());
}
case XSSFCell.CELL_TYPE_STRING:
return cell.getStringCellValue();
case XSSFCell.CELL_TYPE_FORMULA:
return evaluateCellFormula(workbook, cell);
case XSSFCell.CELL_TYPE_BLANK:
return cell.getStringCellValue();
case XSSFCell.CELL_TYPE_BOOLEAN:
return String.valueOf(cell.getBooleanCellValue());
case XSSFCell.CELL_TYPE_ERROR:
return String.valueOf(cell.getErrorCellValue());
}
return null;
}
示例9: getValue
private static String getValue(XSSFCell xssFCell) {
String str = null;
if(xssFCell == null){
return str;
}
if (xssFCell.getCellType() == XSSFCell.CELL_TYPE_BOOLEAN) {
str = String.valueOf(xssFCell.getBooleanCellValue());
} else if (xssFCell.getCellType() == XSSFCell.CELL_TYPE_NUMERIC) {
str = String.valueOf(new DecimalFormat("#").format(xssFCell.getNumericCellValue()));
} else {
str = String.valueOf(xssFCell.getStringCellValue());
}
return StringUtils.trim(str);
}
示例10: copyCell
/**
* @param oldCell
* @param newCell
* @param styleMap
*/
public static void copyCell(XSSFCell oldCell, XSSFCell newCell, Map<Integer, XSSFCellStyle> styleMap) {
if (styleMap != null) {
if (oldCell.getSheet().getWorkbook() == newCell.getSheet().getWorkbook()) {
newCell.setCellStyle(oldCell.getCellStyle());
} else {
int stHashCode = oldCell.getCellStyle().hashCode();
XSSFCellStyle newCellStyle = styleMap.get(stHashCode);
if (newCellStyle == null) {
newCellStyle = newCell.getSheet().getWorkbook().createCellStyle();
newCellStyle.cloneStyleFrom(oldCell.getCellStyle());
styleMap.put(stHashCode, newCellStyle);
}
newCell.setCellStyle(newCellStyle);
}
}
switch (oldCell.getCellType()) {
case XSSFCell.CELL_TYPE_STRING:
newCell.setCellValue(oldCell.getStringCellValue());
break;
case XSSFCell.CELL_TYPE_NUMERIC:
newCell.setCellValue(oldCell.getNumericCellValue());
break;
case XSSFCell.CELL_TYPE_BLANK:
newCell.setCellType(XSSFCell.CELL_TYPE_BLANK);
break;
case XSSFCell.CELL_TYPE_BOOLEAN:
newCell.setCellValue(oldCell.getBooleanCellValue());
break;
case XSSFCell.CELL_TYPE_ERROR:
newCell.setCellErrorValue(oldCell.getErrorCellValue());
break;
case XSSFCell.CELL_TYPE_FORMULA:
newCell.setCellFormula(oldCell.getCellFormula());
break;
default:
break;
}
}
示例11: getIntCellVal
/**
* 获取单元格整数值
*
* @param cell
* @return
*
*/
public static Integer getIntCellVal(XSSFCell cell) {
if (cell == null) {
// 如果参数对象为空,
// 则直接退出!
return null;
}
switch (cell.getCellType()) {
case XSSFCell.CELL_TYPE_NUMERIC:
return (int)cell.getNumericCellValue();
case XSSFCell.CELL_TYPE_STRING:
try {
return Integer.parseInt(cell.getStringCellValue());
} catch (Exception ex) {
// 抛出异常
throw new XlsxTmplError(MessageFormat.format(
BAD_CELL_FORMAT,
getSheetIndex(cell) + 1,
getSheetName(cell),
String.valueOf(cell.getRowIndex() + 1),
getColName(cell.getColumnIndex()),
ex.getMessage()
), ex);
}
case XSSFCell.CELL_TYPE_BOOLEAN:
return cell.getBooleanCellValue() ? 1 : 0;
default:
// 抛出异常
throw new XlsxTmplError(MessageFormat.format(
ERR_CELL_TYPE,
getSheetIndex(cell) + 1,
getSheetName(cell),
String.valueOf(cell.getRowIndex() + 1),
getColName(cell.getColumnIndex()),
Integer.class.getName(),
getCellTypeName(cell)
));
}
}
示例12: getLongCellVal
/**
* 获取单元格长整数值
*
* @param cell
* @return
*
*/
public static Long getLongCellVal(XSSFCell cell) {
if (cell == null) {
// 如果参数对象为空,
// 则直接退出!
return null;
}
switch (cell.getCellType()) {
case XSSFCell.CELL_TYPE_NUMERIC:
return (long)cell.getNumericCellValue();
case XSSFCell.CELL_TYPE_STRING:
try {
return Long.parseLong(cell.getStringCellValue());
} catch (Exception ex) {
// 抛出异常
throw new XlsxTmplError(MessageFormat.format(
BAD_CELL_FORMAT,
getSheetIndex(cell) + 1,
getSheetName(cell),
String.valueOf(cell.getRowIndex() + 1),
getColName(cell.getColumnIndex()),
ex.getMessage()
), ex);
}
case XSSFCell.CELL_TYPE_BOOLEAN:
return cell.getBooleanCellValue() ? 1L : 0L;
default:
// 抛出异常
throw new XlsxTmplError(MessageFormat.format(
ERR_CELL_TYPE,
getSheetIndex(cell) + 1,
getSheetName(cell),
String.valueOf(cell.getRowIndex() + 1),
getColName(cell.getColumnIndex()),
Long.class.getName(),
getCellTypeName(cell)
));
}
}
示例13: getShortCellVal
/**
* 获取单元格短整数值
*
* @param cell
* @return
*
*/
public static Short getShortCellVal(XSSFCell cell) {
if (cell == null) {
// 如果参数对象为空,
// 则直接退出!
return null;
}
switch (cell.getCellType()) {
case XSSFCell.CELL_TYPE_NUMERIC:
return (short)cell.getNumericCellValue();
case XSSFCell.CELL_TYPE_STRING:
try {
return Short.parseShort(cell.getStringCellValue());
} catch (Exception ex) {
// 抛出异常
throw new XlsxTmplError(MessageFormat.format(
BAD_CELL_FORMAT,
getSheetIndex(cell) + 1,
getSheetName(cell),
String.valueOf(cell.getRowIndex() + 1),
getColName(cell.getColumnIndex()),
ex.getMessage()
), ex);
}
case XSSFCell.CELL_TYPE_BOOLEAN:
return cell.getBooleanCellValue() ? (short)1 : (short)0;
default:
// 抛出异常
throw new XlsxTmplError(MessageFormat.format(
ERR_CELL_TYPE,
getSheetIndex(cell) + 1,
getSheetName(cell),
String.valueOf(cell.getRowIndex() + 1),
getColName(cell.getColumnIndex()),
Short.class.getName(),
getCellTypeName(cell)
));
}
}
示例14: getFloatCellVal
/**
* 获取单元格单精度数值
*
* @param cell
* @return
*
*/
public static Float getFloatCellVal(XSSFCell cell) {
if (cell == null) {
// 如果参数对象为空,
// 则直接退出!
return null;
}
switch (cell.getCellType()) {
case XSSFCell.CELL_TYPE_NUMERIC:
return (float)cell.getNumericCellValue();
case XSSFCell.CELL_TYPE_STRING:
try {
return Float.parseFloat(cell.getStringCellValue());
} catch (Exception ex) {
// 抛出异常
throw new XlsxTmplError(MessageFormat.format(
BAD_CELL_FORMAT,
getSheetIndex(cell) + 1,
getSheetName(cell),
String.valueOf(cell.getRowIndex() + 1),
getColName(cell.getColumnIndex()),
ex.getMessage()
), ex);
}
case XSSFCell.CELL_TYPE_BOOLEAN:
return cell.getBooleanCellValue() ? 1.0f : 0.0f;
default:
// 抛出异常
throw new XlsxTmplError(MessageFormat.format(
ERR_CELL_TYPE,
getSheetIndex(cell) + 1,
getSheetName(cell),
String.valueOf(cell.getRowIndex() + 1),
getColName(cell.getColumnIndex()),
Float.class.getName(),
getCellTypeName(cell)
));
}
}
示例15: getDoubleCellVal
/**
* 获取单元格双精度数值
*
* @param cell
* @return
*
*/
public static Double getDoubleCellVal(XSSFCell cell) {
if (cell == null) {
// 如果参数对象为空,
// 则直接退出!
return null;
}
switch (cell.getCellType()) {
case XSSFCell.CELL_TYPE_NUMERIC:
return (double)cell.getNumericCellValue();
case XSSFCell.CELL_TYPE_STRING:
try {
return Double.parseDouble(cell.getStringCellValue());
} catch (Exception ex) {
// 抛出异常
throw new XlsxTmplError(MessageFormat.format(
BAD_CELL_FORMAT,
getSheetIndex(cell) + 1,
getSheetName(cell),
String.valueOf(cell.getRowIndex() + 1),
getColName(cell.getColumnIndex()),
ex.getMessage()
), ex);
}
case XSSFCell.CELL_TYPE_BOOLEAN:
return cell.getBooleanCellValue() ? 1.0 : 0.0;
default:
// 抛出异常
throw new XlsxTmplError(MessageFormat.format(
ERR_CELL_TYPE,
getSheetIndex(cell) + 1,
getSheetName(cell),
String.valueOf(cell.getRowIndex() + 1),
getColName(cell.getColumnIndex()),
Double.class.getName(),
getCellTypeName(cell)
));
}
}