当前位置: 首页>>代码示例>>Java>>正文


Java HSSFCell.getCellType方法代码示例

本文整理汇总了Java中org.apache.poi.hssf.usermodel.HSSFCell.getCellType方法的典型用法代码示例。如果您正苦于以下问题:Java HSSFCell.getCellType方法的具体用法?Java HSSFCell.getCellType怎么用?Java HSSFCell.getCellType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.poi.hssf.usermodel.HSSFCell的用法示例。


在下文中一共展示了HSSFCell.getCellType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCellValue

import org.apache.poi.hssf.usermodel.HSSFCell; //导入方法依赖的package包/类
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 "";
	}
}
 
开发者ID:ken8271,项目名称:parrot,代码行数:17,代码来源:XlsParser.java

示例2: findMatchColumn

import org.apache.poi.hssf.usermodel.HSSFCell; //导入方法依赖的package包/类
public static Integer findMatchColumn(final HSSFRow row, final String str) {
    for (int colNum = row.getFirstCellNum(); colNum <= row.getLastCellNum(); colNum++) {
        final HSSFCell cell = row.getCell(colNum);

        if (cell == null) {
            continue;
        }

        if (cell.getCellType() != Cell.CELL_TYPE_STRING) {
            continue;
        }

        final HSSFRichTextString cellValue = cell.getRichStringCellValue();

        if (cellValue.getString().matches(str)) {
            return Integer.valueOf(colNum);
        }
    }

    return null;
}
 
开发者ID:roundrop,项目名称:ermasterr,代码行数:22,代码来源:POIUtils.java

示例3: getIntCellValue

import org.apache.poi.hssf.usermodel.HSSFCell; //导入方法依赖的package包/类
public static int getIntCellValue(HSSFSheet sheet, int r, int c) {
	HSSFRow row = sheet.getRow(r);
	if (row == null) {
		return 0;
	}
	HSSFCell cell = row.getCell(c);

	try {
		if (cell.getCellType() != HSSFCell.CELL_TYPE_NUMERIC) {
			return 0;
		}
	} catch (RuntimeException e) {
		System.err.println("Exception at sheet name:"
				+ sheet.getSheetName() + ", row:" + (r + 1) + ", col:"
				+ (c + 1));
		throw e;
	}

	return (int) cell.getNumericCellValue();
}
 
开发者ID:kozake,项目名称:ermaster-k,代码行数:21,代码来源:POIUtils.java

示例4: getCellValue

import org.apache.poi.hssf.usermodel.HSSFCell; //导入方法依赖的package包/类
/**
 * 获取EXCEL文件单元列值
 * 
 * @param row
 * @param point
 * @return
 */
private static String getCellValue(HSSFRow row, int point) {
	String reString = "";
	try {
		HSSFCell cell = row.getCell((short) point);
		if (cell.getCellType() == 1)
			reString = cell.getStringCellValue();
		else if (cell.getCellType() == 0) {
			reString = convert(cell.getNumericCellValue());
			BigDecimal bd = new BigDecimal(reString);
			reString = bd.toPlainString();
		} else {
			reString = "";
		}
		System.out.println(cell.getCellType() + ":" + cell.getCellFormula());
	} catch (Exception localException) {
	}
	return checkNull(reString);
}
 
开发者ID:fellyvon,项目名称:wasexport,代码行数:26,代码来源:ExcelUtil.java

示例5: reader

import org.apache.poi.hssf.usermodel.HSSFCell; //导入方法依赖的package包/类
public static void reader(String filePath) {
	try {
		POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(filePath));
		HSSFWorkbook wb = new HSSFWorkbook(fs);
		HSSFSheet sheet = wb.getSheetAt(0);
		HSSFRow row = sheet.getRow(3);
		HSSFCell cell = row.getCell((short) 0);
		int type = cell.getCellType();
		String msg = getCellStringValue(cell);
		System.out.println(type + ":" + msg);
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
开发者ID:wkeyuan,项目名称:DWSurvey,代码行数:15,代码来源:ReadExcelUtil.java

示例6: findColumn

import org.apache.poi.hssf.usermodel.HSSFCell; //导入方法依赖的package包/类
public static Integer findColumn(final HSSFRow row, final String str) {
    for (int colNum = row.getFirstCellNum(); colNum <= row.getLastCellNum(); colNum++) {
        final HSSFCell cell = row.getCell(colNum);

        if (cell == null) {
            continue;
        }

        if (cell.getCellType() == Cell.CELL_TYPE_STRING) {
            final HSSFRichTextString cellValue = cell.getRichStringCellValue();

            if (str.equals(cellValue.getString())) {
                return Integer.valueOf(colNum);
            }
        }
    }

    return null;
}
 
开发者ID:roundrop,项目名称:ermasterr,代码行数:20,代码来源:POIUtils.java

示例7: getIntCellValue

import org.apache.poi.hssf.usermodel.HSSFCell; //导入方法依赖的package包/类
public static int getIntCellValue(final HSSFSheet sheet, final int r, final int c) {
    final HSSFRow row = sheet.getRow(r);
    if (row == null) {
        return 0;
    }
    final HSSFCell cell = row.getCell(c);

    try {
        if (cell.getCellType() != Cell.CELL_TYPE_NUMERIC) {
            return 0;
        }
    } catch (final RuntimeException e) {
        System.err.println("Exception at sheet name:" + sheet.getSheetName() + ", row:" + (r + 1) + ", col:" + (c + 1));
        throw e;
    }

    return (int) cell.getNumericCellValue();
}
 
开发者ID:roundrop,项目名称:ermasterr,代码行数:19,代码来源:POIUtils.java

示例8: findColumn

import org.apache.poi.hssf.usermodel.HSSFCell; //导入方法依赖的package包/类
public static Integer findColumn(HSSFRow row, String str) {
	for (int colNum = row.getFirstCellNum(); colNum <= row.getLastCellNum(); colNum++) {
		HSSFCell cell = row.getCell(colNum);

		if (cell == null) {
			continue;
		}

		if (cell.getCellType() == HSSFCell.CELL_TYPE_STRING) {
			HSSFRichTextString cellValue = cell.getRichStringCellValue();

			if (str.equals(cellValue.getString())) {
				return Integer.valueOf(colNum);
			}
		}
	}

	return null;
}
 
开发者ID:kozake,项目名称:ermaster-k,代码行数:20,代码来源:POIUtils.java

示例9: findMatchColumn

import org.apache.poi.hssf.usermodel.HSSFCell; //导入方法依赖的package包/类
public static Integer findMatchColumn(HSSFRow row, String str) {
	for (int colNum = row.getFirstCellNum(); colNum <= row.getLastCellNum(); colNum++) {
		HSSFCell cell = row.getCell(colNum);

		if (cell == null) {
			continue;
		}

		if (cell.getCellType() != HSSFCell.CELL_TYPE_STRING) {
			continue;
		}

		HSSFRichTextString cellValue = cell.getRichStringCellValue();

		if (cellValue.getString().matches(str)) {
			return Integer.valueOf(colNum);
		}
	}

	return null;
}
 
开发者ID:kozake,项目名称:ermaster-k,代码行数:22,代码来源:POIUtils.java

示例10: fromHSSFRowtoCSV

import org.apache.poi.hssf.usermodel.HSSFCell; //导入方法依赖的package包/类
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();

}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:26,代码来源:SpreadsheetUploadBean.java

示例11: getCellData

import org.apache.poi.hssf.usermodel.HSSFCell; //导入方法依赖的package包/类
/**
 * Get cell value based on the excel column data type
 *
 * @param myCell
 * @return
 */
private static String getCellData(HSSFCell myCell) throws Exception {
    String cellData = "";
    if (myCell == null) {
        cellData += CVS_SEPERATOR_CHAR;;
    } else {
        switch (myCell.getCellType()) {
            case HSSFCell.CELL_TYPE_STRING:
            case HSSFCell.CELL_TYPE_BOOLEAN:
                cellData += myCell.getRichStringCellValue() + CVS_SEPERATOR_CHAR;
                break;
            case HSSFCell.CELL_TYPE_NUMERIC:
                cellData += getNumericValue(myCell);
                break;
            case HSSFCell.CELL_TYPE_FORMULA:
                cellData += getFormulaValue(myCell);
            default:
                cellData += CVS_SEPERATOR_CHAR;
                ;
        }
    }
    return cellData;
}
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:29,代码来源:ReportModel.java

示例12: manageInteger

import org.apache.poi.hssf.usermodel.HSSFCell; //导入方法依赖的package包/类
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;
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:21,代码来源:GeneralXLSImporter.java

示例13: getValueFromCell

import org.apache.poi.hssf.usermodel.HSSFCell; //导入方法依赖的package包/类
/**
 * <b>描述:</b> 从单元格中获取到的数据
 * @param cell	单元格对应的HSSFCell对象
 * @return Object 从单元格中获取到的数据
 */
private Object getValueFromCell(HSSFCell cell){
	if(cell==null)return "";
	switch(cell.getCellType()){
		case HSSFCell.CELL_TYPE_BOOLEAN:
			return cell.getBooleanCellValue();
		case HSSFCell.CELL_TYPE_NUMERIC:
			return cell.getNumericCellValue();
		case HSSFCell.CELL_TYPE_FORMULA:
			return cell.getCellFormula();
		case HSSFCell.CELL_TYPE_STRING:
			return cell.getRichStringCellValue().toString();
		default:
			return cell.getRichStringCellValue().toString();
	}
	
}
 
开发者ID:uiguard,项目名称:uiguard,代码行数:22,代码来源:DataProviderHelper.java

示例14: manageBigInteger

import org.apache.poi.hssf.usermodel.HSSFCell; //导入方法依赖的package包/类
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;
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:21,代码来源:GeneralXLSImporter.java

示例15: manageBoolean

import org.apache.poi.hssf.usermodel.HSSFCell; //导入方法依赖的package包/类
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;
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:22,代码来源:GeneralXLSImporter.java


注:本文中的org.apache.poi.hssf.usermodel.HSSFCell.getCellType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。