Java Code Examples for org.apache.poi.hssf.usermodel.HSSFCell#getRichStringCellValue()

The following examples show how to use org.apache.poi.hssf.usermodel.HSSFCell#getRichStringCellValue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: POIUtils.java    From ermasterr with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 2
Source File: POIUtils.java    From ermasterr with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 3
Source File: POIUtils.java    From ermasterr with Apache License 2.0 6 votes vote down vote up
public static CellLocation findCell(final HSSFSheet sheet, final String str, final int colNum) {
    for (int rowNum = sheet.getFirstRowNum(); rowNum < sheet.getLastRowNum() + 1; rowNum++) {
        final HSSFRow row = sheet.getRow(rowNum);
        if (row == null) {
            continue;
        }

        final HSSFCell cell = row.getCell(colNum);

        if (cell == null) {
            continue;
        }
        final HSSFRichTextString cellValue = cell.getRichStringCellValue();

        if (!Check.isEmpty(cellValue.getString())) {
            if (cellValue.getString().equals(str)) {
                return new CellLocation(rowNum, (short) colNum);
            }
        }
    }

    return null;
}
 
Example 4
Source File: POIUtils.java    From ermasterr with Apache License 2.0 6 votes vote down vote up
public static String getCellValue(final HSSFSheet sheet, final int r, final int c) {
    final HSSFRow row = sheet.getRow(r);

    if (row == null) {
        return null;
    }

    final HSSFCell cell = row.getCell(c);

    if (cell == null) {
        return null;
    }

    final HSSFRichTextString cellValue = cell.getRichStringCellValue();

    return cellValue.toString();
}
 
Example 5
Source File: POIUtils.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 6
Source File: POIUtils.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 7
Source File: POIUtils.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
public static CellLocation findCell(HSSFSheet sheet, String str, int colNum) {
	for (int rowNum = sheet.getFirstRowNum(); rowNum < sheet
			.getLastRowNum() + 1; rowNum++) {
		HSSFRow row = sheet.getRow(rowNum);
		if (row == null) {
			continue;
		}

		HSSFCell cell = row.getCell(colNum);

		if (cell == null) {
			continue;
		}
		HSSFRichTextString cellValue = cell.getRichStringCellValue();

		if (!Check.isEmpty(cellValue.getString())) {
			if (cellValue.getString().equals(str)) {
				return new CellLocation(rowNum, (short) colNum);
			}
		}
	}

	return null;
}
 
Example 8
Source File: POIUtils.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
public static String getCellValue(HSSFSheet sheet, int r, int c) {
	HSSFRow row = sheet.getRow(r);
	
	if (row == null) {
		return null;
	}
	
	HSSFCell cell = row.getCell(c);
	
	if (cell == null) {
		return null;
	}
	
	HSSFRichTextString cellValue = cell.getRichStringCellValue();

	return cellValue.toString();
}
 
Example 9
Source File: POIUtils.java    From ermasterr with Apache License 2.0 5 votes vote down vote up
public static String getCellValue(final HSSFSheet sheet, final CellLocation location) {
    final HSSFRow row = sheet.getRow(location.r);
    final HSSFCell cell = row.getCell(location.c);

    final HSSFRichTextString cellValue = cell.getRichStringCellValue();

    return cellValue.toString();
}
 
Example 10
Source File: POIUtils.java    From ermaster-b with Apache License 2.0 5 votes vote down vote up
public static String getCellValue(HSSFSheet sheet, CellLocation location) {
	HSSFRow row = sheet.getRow(location.r);
	HSSFCell cell = row.getCell(location.c);

	HSSFRichTextString cellValue = cell.getRichStringCellValue();

	return cellValue.toString();
}