当前位置: 首页>>代码示例>>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;未经允许,请勿转载。