本文整理汇总了Java中org.apache.poi.hssf.usermodel.HSSFCell.CELL_TYPE_BLANK属性的典型用法代码示例。如果您正苦于以下问题:Java HSSFCell.CELL_TYPE_BLANK属性的具体用法?Java HSSFCell.CELL_TYPE_BLANK怎么用?Java HSSFCell.CELL_TYPE_BLANK使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.poi.hssf.usermodel.HSSFCell
的用法示例。
在下文中一共展示了HSSFCell.CELL_TYPE_BLANK属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCellValue
private String getCellValue(HSSFCell cell){
if(cell == null) return "";
switch (cell.getCellType()) {
case HSSFCell.CELL_TYPE_STRING: return cell.getStringCellValue();
case HSSFCell.CELL_TYPE_BOOLEAN : return Boolean.toString(cell.getBooleanCellValue());
case HSSFCell.CELL_TYPE_NUMERIC :
if(HSSFDateUtil.isCellDateFormatted(cell))
return DateUtils.formatDateTime("yyyyMMdd", HSSFDateUtil.getJavaDate(cell.getNumericCellValue()));
else
return new BigDecimal(cell.getNumericCellValue()).toPlainString();
case HSSFCell.CELL_TYPE_FORMULA : return "";
case HSSFCell.CELL_TYPE_BLANK : return "";
default:return "";
}
}
示例2: fromHSSFRowtoCSV
private String fromHSSFRowtoCSV(HSSFRow row){
StringBuffer csvRow = new StringBuffer();
int l = row.getLastCellNum();
for (int i=0;i<l;i++){
HSSFCell cell = row.getCell((short)i);
String cellValue = "";
if (cell == null || cell.getCellType() == HSSFCell.CELL_TYPE_BLANK) {
cellValue = "";
} else if (cell.getCellType()== HSSFCell.CELL_TYPE_STRING){
cellValue = "\"" + cell.getStringCellValue() + "\"";
} else if (cell.getCellType() == HSSFCell.CELL_TYPE_NUMERIC){
double value = cell.getNumericCellValue();
cellValue = getNumberFormat().format(value);
cellValue = "\"" + cellValue + "\"";
}
csvRow.append(cellValue);
if (i<l){
csvRow.append(getCsvDelimiter().toCharArray()[0]);
}
}
return csvRow.toString();
}
示例3: fromXSSFRowtoCSV
private String fromXSSFRowtoCSV(XSSFRow row){
StringBuffer csvRow = new StringBuffer();
int l = row.getLastCellNum();
for (int i=0;i<l;i++){
XSSFCell cell = row.getCell((short)i);
String cellValue = "";
if (cell == null || cell.getCellType() == HSSFCell.CELL_TYPE_BLANK) {
cellValue = "";
} else if (cell.getCellType()== HSSFCell.CELL_TYPE_STRING){
cellValue = "\"" + cell.getStringCellValue() + "\"";
} else if (cell.getCellType() == HSSFCell.CELL_TYPE_NUMERIC){
double value = cell.getNumericCellValue();
cellValue = getNumberFormat().format(value);
cellValue = "\"" + cellValue + "\"";
}
csvRow.append(cellValue);
if (i<l){
csvRow.append(getCsvDelimiter().toCharArray()[0]);
}
}
return csvRow.toString();
}
示例4: getCellValue
Object getCellValue(final Cell cell, final OneToOneAssociation otoa) {
final int cellType = cell.getCellType();
if(cellType == HSSFCell.CELL_TYPE_BLANK) {
return null;
}
final ObjectSpecification propertySpec = otoa.getSpecification();
Class<?> requiredType = propertySpec.getCorrespondingClass();
// value types
if(propertySpec.isValue()) {
return getCellValue(cell, requiredType);
}
// reference types
if(!propertySpec.isParentedOrFreeCollection()) {
return getCellComment(cell, requiredType);
}
return null;
}
示例5: manageInteger
private Integer manageInteger(PreparedStatement ps, PreparedStatement psUpdate, int lfdCol, HSSFCell cell) throws SQLException {
Integer result = null;
if (cell == null || cell.getCellType() == HSSFCell.CELL_TYPE_BLANK) {
} else if (cell.getCellType() == HSSFCell.CELL_TYPE_STRING) {
if (cell.getStringCellValue().trim().length() > 0) {
result = new Integer(cell.getStringCellValue());
if (ps != null) ps.setInt(lfdCol, result);
if (psUpdate != null) psUpdate.setInt(lfdCol, result);
return result;
}
} else {
result = new Integer((int) cell.getNumericCellValue());
if (ps != null) ps.setInt(lfdCol, result);
if (psUpdate != null) psUpdate.setInt(lfdCol, result);
return result;
}
if (ps != null) ps.setNull(lfdCol, java.sql.Types.INTEGER);
if (psUpdate != null) psUpdate.setNull(lfdCol, java.sql.Types.INTEGER);
return result;
}
示例6: manageBigInteger
private Long manageBigInteger(PreparedStatement ps, PreparedStatement psUpdate, int lfdCol, HSSFCell cell) throws SQLException {
Long result = null;
if (cell == null || cell.getCellType() == HSSFCell.CELL_TYPE_BLANK) {
} else if (cell.getCellType() == HSSFCell.CELL_TYPE_STRING) {
if (cell.getStringCellValue().trim().length() > 0) {
result = new Long(cell.getStringCellValue());
if (ps != null) ps.setLong(lfdCol, result);
if (psUpdate != null) psUpdate.setLong(lfdCol, result);
return result;
}
} else {
result = new Long((long) cell.getNumericCellValue());
if (ps != null) ps.setLong(lfdCol, result);
if (psUpdate != null) psUpdate.setLong(lfdCol, result);
return result;
}
if (ps != null) ps.setNull(lfdCol, java.sql.Types.BIGINT);
if (psUpdate != null) psUpdate.setNull(lfdCol, java.sql.Types.BIGINT);
return result;
}
示例7: manageBoolean
private Boolean manageBoolean(PreparedStatement ps, PreparedStatement psUpdate, int lfdCol, HSSFCell cell) throws SQLException {
Boolean result = null;
if (cell == null || cell.getCellType() == HSSFCell.CELL_TYPE_BLANK) {
if (ps != null) ps.setNull(lfdCol, java.sql.Types.BOOLEAN);
if (psUpdate != null) psUpdate.setNull(lfdCol, java.sql.Types.BOOLEAN);
} else if (cell.getCellType() == HSSFCell.CELL_TYPE_NUMERIC) {
result = cell.getNumericCellValue() != 0;
if (ps != null) ps.setBoolean(lfdCol, result);
if (psUpdate != null) psUpdate.setBoolean(lfdCol, result);
} else if (cell.getCellType() == HSSFCell.CELL_TYPE_STRING) {
result = cell.getStringCellValue().equalsIgnoreCase("true");
if (ps != null) ps.setBoolean(lfdCol, result);
if (psUpdate != null) psUpdate.setBoolean(lfdCol, result);
} else {
result = cell.getBooleanCellValue();
if (ps != null) ps.setBoolean(lfdCol, result);
if (psUpdate != null) psUpdate.setBoolean(lfdCol, result);
}
//ps.setNull(lfdCol, java.sql.Types.BOOLEAN);
return result;
}
示例8: getCellStringValue
public static String getCellStringValue(HSSFCell cell) {
String cellValue = "";
switch (cell.getCellType()) {
case HSSFCell.CELL_TYPE_STRING:
cellValue = cell.getStringCellValue();
if (cellValue.trim().equals("") || cellValue.trim().length() <= 0) {
cellValue = " ";
}
break;
case HSSFCell.CELL_TYPE_NUMERIC:
// cellValue = String.valueOf(cell.getNumericCellValue());
DecimalFormat formatter = new DecimalFormat("######");
cellValue = formatter.format(cell.getNumericCellValue());
break;
case HSSFCell.CELL_TYPE_FORMULA:
cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
cellValue = String.valueOf(cell.getNumericCellValue());
break;
case HSSFCell.CELL_TYPE_BLANK:
cellValue = " ";
break;
case HSSFCell.CELL_TYPE_BOOLEAN:
break;
case HSSFCell.CELL_TYPE_ERROR:
break;
default:
break;
}
return cellValue;
}
示例9: copyCell
/**
* @param oldCell
* @param newCell
* @param styleMap
*/
public static void copyCell(HSSFCell oldCell, HSSFCell newCell, Map<Integer, HSSFCellStyle> styleMap) {
if (styleMap != null) {
if (oldCell.getSheet().getWorkbook() == newCell.getSheet().getWorkbook()) {
newCell.setCellStyle(oldCell.getCellStyle());
} else {
int stHashCode = oldCell.getCellStyle().hashCode();
HSSFCellStyle 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 HSSFCell.CELL_TYPE_STRING:
newCell.setCellValue(oldCell.getStringCellValue());
break;
case HSSFCell.CELL_TYPE_NUMERIC:
newCell.setCellValue(oldCell.getNumericCellValue());
break;
case HSSFCell.CELL_TYPE_BLANK:
newCell.setCellType(HSSFCell.CELL_TYPE_BLANK);
break;
case HSSFCell.CELL_TYPE_BOOLEAN:
newCell.setCellValue(oldCell.getBooleanCellValue());
break;
case HSSFCell.CELL_TYPE_ERROR:
newCell.setCellErrorValue(oldCell.getErrorCellValue());
break;
case HSSFCell.CELL_TYPE_FORMULA:
newCell.setCellFormula(oldCell.getCellFormula());
break;
default:
break;
}
}
示例10: getCellData
@SuppressWarnings("null")
public static String getCellData(String reqValue, HSSFSheet reqSheet,
int rowIndex, HashMap<String, Object> inputHashTable)
throws IOException {
HSSFCell reqCell = null;
Object actualvalue = null;
String req = "";
DataFormatter fmt = new DataFormatter();
if (inputHashTable.isEmpty() == true) {
inputHashTable = getValueFromHashMap(reqSheet);
}
HSSFRow rowActual = reqSheet.getRow(rowIndex);
if (inputHashTable.get(reqValue) == null) {
report.setStrMessage("Column " + reqValue
+ " not Found. Please Check input Sheet");
pauseFun("Column " + reqValue
+ " not Found. Please Check input Sheet");
} else {
actualvalue = inputHashTable.get(reqValue);// rowHeader.getCell(colIndex).toString();
if (actualvalue != null) {
int colIndex = Integer.parseInt(actualvalue.toString());
reqCell = rowActual.getCell(colIndex);
if (reqCell == null) {
System.out.println(reqValue + " is Null");
} else {
int type = reqCell.getCellType();
switch (type) {
case HSSFCell.CELL_TYPE_BLANK:
req = "";
break;
case HSSFCell.CELL_TYPE_NUMERIC:
req = fmt.formatCellValue(reqCell);
break;
case HSSFCell.CELL_TYPE_STRING:
req = reqCell.getStringCellValue();
break;
case HSSFCell.CELL_TYPE_BOOLEAN:
req = Boolean.toString(reqCell.getBooleanCellValue());
break;
case HSSFCell.CELL_TYPE_ERROR:
req = "error";
break;
case HSSFCell.CELL_TYPE_FORMULA:
req = reqCell.getCellFormula();
break;
}
}
}
else {
req = reqCell.getStringCellValue();
System.out.println("null");
}
}
return req;
}
示例11: getCellString
private Object getCellString(HSSFCell cell) {
// TODO Auto-generated method stub
Object result = null;
if (cell != null) {
// 单元格类型:Numeric:0,String:1,Formula:2,Blank:3,Boolean:4,Error:5
int cellType = cell.getCellType();
switch (cellType) {
case HSSFCell.CELL_TYPE_STRING:
result = cell.getRichStringCellValue().getString();
break;
case HSSFCell.CELL_TYPE_NUMERIC:
result = cell.getNumericCellValue();
break;
case HSSFCell.CELL_TYPE_FORMULA:
result = cell.getNumericCellValue();
break;
case HSSFCell.CELL_TYPE_BOOLEAN:
result = cell.getBooleanCellValue();
break;
case HSSFCell.CELL_TYPE_BLANK:
result = null;
break;
case HSSFCell.CELL_TYPE_ERROR:
result = null;
break;
default:
System.out.println("枚举了所有类型");
break;
}
}
return result;
}
示例12: getHSSFCellValue
public String getHSSFCellValue(HSSFCell cell) {
String value = "";
switch (cell.getCellType()) {
case HSSFCell.CELL_TYPE_NUMERIC:
if (HSSFDateUtil.isCellDateFormatted(cell)) {
value = HSSFDateUtil.getJavaDate(cell.getNumericCellValue())
.toString();
} else {
value = String.valueOf(cell.getNumericCellValue());
}
break;
case HSSFCell.CELL_TYPE_STRING:
value = cell.getRichStringCellValue().toString();
break;
case HSSFCell.CELL_TYPE_FORMULA:
value = String.valueOf(cell.getNumericCellValue());
if (value.equals("NaN")) {
value = cell.getRichStringCellValue().toString();
}
break;
case HSSFCell.CELL_TYPE_BOOLEAN:
value = "" + cell.getBooleanCellValue();
break;
case HSSFCell.CELL_TYPE_BLANK:
value = "";
break;
case HSSFCell.CELL_TYPE_ERROR:
value = "";
break;
default:
value = cell.getRichStringCellValue().toString();
}
return value;
}
示例13: getCellValue
public static String getCellValue(HSSFCell cell) {
String value = "";
if (cell==null)
return "";
switch (cell.getCellType()) {
case HSSFCell.CELL_TYPE_STRING:
value = cell.getStringCellValue();
break;
case HSSFCell.CELL_TYPE_NUMERIC:
double tp=Double.valueOf(cell.getNumericCellValue());
value=String.format("%.2f", tp);
break;
case HSSFCell.CELL_TYPE_FORMULA:
value = cell.getCellFormula();
break;
case HSSFCell.CELL_TYPE_ERROR:
value = String.valueOf(cell.getErrorCellValue());
break;
case HSSFCell.CELL_TYPE_BOOLEAN:
value = String.valueOf(cell.getBooleanCellValue());
break;
case HSSFCell.CELL_TYPE_BLANK:
value = "";
break;
default:
break;
}
return value;
}
示例14: getCellValue2
public static String getCellValue2(HSSFCell cell) {
String value = "";
if (cell==null)
return "";
switch (cell.getCellType()) {
case HSSFCell.CELL_TYPE_STRING:
value = cell.getStringCellValue();
break;
case HSSFCell.CELL_TYPE_NUMERIC:
double tp=Double.valueOf(cell.getNumericCellValue());
value=String.format("%.0f", tp);
break;
case HSSFCell.CELL_TYPE_FORMULA:
value = cell.getCellFormula();
break;
case HSSFCell.CELL_TYPE_ERROR:
value = String.valueOf(cell.getErrorCellValue());
break;
case HSSFCell.CELL_TYPE_BOOLEAN:
value = String.valueOf(cell.getBooleanCellValue());
break;
case HSSFCell.CELL_TYPE_BLANK:
value = "";
break;
default:
break;
}
return value;
}
示例15: manageDate
private Date manageDate(PreparedStatement ps, PreparedStatement psUpdate, int lfdCol, HSSFCell cell) throws SQLException {
Date result = null;
if (cell == null || cell.getCellType() == HSSFCell.CELL_TYPE_BLANK) {
} else if (cell.getCellType() == HSSFCell.CELL_TYPE_STRING) {
if (cell.getStringCellValue().trim().length() > 0) {
DateFormat formater = new SimpleDateFormat("yyyy-MM-dd"); // 2012-06-01 hh:mm:ss
java.util.Date parsedUtilDate;
try {
parsedUtilDate = formater.parse(cell.getStringCellValue());
result = new java.sql.Date(parsedUtilDate.getTime());
} catch (ParseException e) {
e.printStackTrace();
}
if (result != null) {
if (ps != null) ps.setDate(lfdCol, result);
if (psUpdate != null) psUpdate.setDate(lfdCol, result);
return result;
}
}
} else {
result = new Date(cell.getDateCellValue().getTime());
if (ps != null) ps.setDate(lfdCol, result);
if (psUpdate != null) psUpdate.setDate(lfdCol, result);
return result;
}
if (ps != null) ps.setNull(lfdCol, java.sql.Types.DATE);
if (psUpdate != null) psUpdate.setNull(lfdCol, java.sql.Types.DATE);
return result;
}