當前位置: 首頁>>代碼示例>>Java>>正文


Java XSSFCell.getRawValue方法代碼示例

本文整理匯總了Java中org.apache.poi.xssf.usermodel.XSSFCell.getRawValue方法的典型用法代碼示例。如果您正苦於以下問題:Java XSSFCell.getRawValue方法的具體用法?Java XSSFCell.getRawValue怎麽用?Java XSSFCell.getRawValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.poi.xssf.usermodel.XSSFCell的用法示例。


在下文中一共展示了XSSFCell.getRawValue方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: extractContent

import org.apache.poi.xssf.usermodel.XSSFCell; //導入方法依賴的package包/類
private void extractContent(final StringBuilder buffy, final XSSFWorkbook document) {
    for (int i = 0; i < document.getNumberOfSheets(); i++) {
        final XSSFSheet sheet = document.getSheetAt(i);
        buffy.append(document.getSheetName(i)).append(' ');

        // Header(s), if present
        extractHeaderFooter(buffy, sheet.getFirstHeader());
        extractHeaderFooter(buffy, sheet.getOddHeader());
        extractHeaderFooter(buffy, sheet.getEvenHeader());

        // Rows and cells
        for (final Object rawR : sheet) {
            final Row row = (Row) rawR;
            for (final Iterator<Cell> ri = row.cellIterator(); ri.hasNext();) {
                final Cell cell = ri.next();

                if (cell.getCellType() == Cell.CELL_TYPE_FORMULA || cell.getCellType() == Cell.CELL_TYPE_STRING) {
                    buffy.append(cell.getRichStringCellValue().getString()).append(' ');
                } else {
                    final XSSFCell xc = (XSSFCell) cell;
                    final String rawValue = xc.getRawValue();
                    if (rawValue != null) {
                        buffy.append(rawValue).append(' ');
                    }

                }

                // Output the comment in the same cell as the content
                final Comment comment = cell.getCellComment();
                if (comment != null) {
                    buffy.append(comment.getString().getString()).append(' ');
                }
            }
        }

        // Finally footer(s), if present
        extractHeaderFooter(buffy, sheet.getFirstFooter());
        extractHeaderFooter(buffy, sheet.getOddFooter());
        extractHeaderFooter(buffy, sheet.getEvenFooter());
    }
}
 
開發者ID:huihoo,項目名稱:olat,代碼行數:42,代碼來源:ExcelOOXMLDocument.java

示例2: read

import org.apache.poi.xssf.usermodel.XSSFCell; //導入方法依賴的package包/類
@Override
public String read(XSSFCell cell) {
	String cellValue = "";
	switch (cell.getCellType()) {
	case Cell.CELL_TYPE_STRING:
		cellValue = readTypeString(cell);
		break;
	case Cell.CELL_TYPE_NUMERIC:
		cellValue = readTypeNumeric(cell);
		break;
	case Cell.CELL_TYPE_FORMULA:
		cellValue = readTypeFormula(cell);
		break;
	case Cell.CELL_TYPE_BOOLEAN:
		cellValue = String.valueOf(cell.getBooleanCellValue());
		break;
	case Cell.CELL_TYPE_BLANK:
		cellValue = "";
		break;
	case Cell.CELL_TYPE_ERROR:
		cellValue = cell.getErrorCellString();
		break;
	default:
		cellValue = cell.getRawValue();
		break;
	}
	return cellValue;
}
 
開發者ID:lucastanziano,項目名稱:JavaFX-Skeleton-DEPRECATED,代碼行數:29,代碼來源:BaseCellReader.java

示例3: getExcelReader

import org.apache.poi.xssf.usermodel.XSSFCell; //導入方法依賴的package包/類
public static List<Map<String, String>> getExcelReader() {
	
	String[] colName = { "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday" };
	
	List<Map<String, String>> list = new ArrayList<Map<String, String>>();
	
	try {
		
		FileInputStream fis = new FileInputStream("c:\\wdmFx\\db\\webtoonList1.xlsx");
		
		XSSFWorkbook workbook = new XSSFWorkbook(fis);
		
		// 시트 수 (첫번째에만 존재하므로 0을 준다)
		// 만약 각 시트를 읽기위해서는 FOR문을 한번더 돌려준다
		XSSFSheet sheet = workbook.getSheetAt(0);
		int rows = sheet.getPhysicalNumberOfRows();
		
		Map<String, String> map = null;

		for (int i = 0; i < rows; i++) {

			if (i != 0) {

				XSSFRow row = sheet.getRow(i); // 행을 읽는다

				String value = "";

				// 셀의 갯수를 실제 필드갯수로 지정.
				int cells = colName.length;

				map = new LinkedHashMap<String, String>();

				for (int j = 0; j < cells; j++) {

					XSSFCell cell = row.getCell(j); // 셀값을 읽는다

					if (cell != null) {
						switch (cell.getCellType()) {
						case XSSFCell.CELL_TYPE_FORMULA:
							if (!"".equals(cell.toString())) {
								value = cell.getCellFormula();
							}
							break;
						case XSSFCell.CELL_TYPE_NUMERIC:
							value = cell.getRawValue();
							break;
						case XSSFCell.CELL_TYPE_STRING:
							value = cell.getStringCellValue();
							break;
						case XSSFCell.CELL_TYPE_BLANK:
							value = "";
							break;
						case XSSFCell.CELL_TYPE_ERROR:
							value = cell.getErrorCellValue() + "";
							break;
						default:
							break;
						}

						map.put(colName[j], value);
					}

				} // end for

				if (map.get(colName[0]) != null)
					list.add(map);
				
			} // end for
			
		}
		
	} catch (IOException e) {
		e.printStackTrace();
	}

	return list;
}
 
開發者ID:kimyearho,項目名稱:WebtoonDownloadManager,代碼行數:78,代碼來源:ExcelReader.java

示例4: readTypeNumeric

import org.apache.poi.xssf.usermodel.XSSFCell; //導入方法依賴的package包/類
@Override
public String readTypeNumeric(XSSFCell cell) {		
	return cell.getRawValue();
}
 
開發者ID:lucastanziano,項目名稱:JavaFX-Skeleton-DEPRECATED,代碼行數:5,代碼來源:StringCellReader.java

示例5: readTypeFormula

import org.apache.poi.xssf.usermodel.XSSFCell; //導入方法依賴的package包/類
@Override
public String readTypeFormula(XSSFCell cell) {
	return cell.getRawValue();
}
 
開發者ID:lucastanziano,項目名稱:JavaFX-Skeleton-DEPRECATED,代碼行數:5,代碼來源:BaseCellReader.java


注:本文中的org.apache.poi.xssf.usermodel.XSSFCell.getRawValue方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。