當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。