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


Java CellType.BOOLEAN属性代码示例

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


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

示例1: getCellValue

/**
 * 获取单元格的值
 * 
 * @param cell
 * @return
 */
public static Object getCellValue(Cell cell) {
	Object cellValue = null;
	CellType cellType = cell.getCellTypeEnum();// CellType.forInt(cell.getCellType());
	if (cellType == CellType.STRING) {
		cellValue = cell.getStringCellValue();
	} else if (cellType == CellType.NUMERIC) {
		if (DateUtil.isCellDateFormatted(cell)) {
			cellValue = cell.getDateCellValue();
		} else {
			cellValue = cell.getNumericCellValue();
		}
	} else if (cellType == CellType.BOOLEAN) {
		cellValue = cell.getBooleanCellValue();
	} else if (cellType == CellType.FORMULA) {
		cellValue = cell.getCellFormula();
	} else if (cellType == CellType.BLANK) {
		cellValue = "";
	}
	return cellValue;
}
 
开发者ID:color-coding,项目名称:btulz.transforms,代码行数:26,代码来源:ExcelParser.java

示例2: getCellTypeEnum

/**
 * Return the cell type.
 *
 * @return the cell type
 * Will be renamed to <code>getCellType()</code> when we make the CellType enum transition in POI 4.0. See bug 59791.
 */
@Override
public CellType getCellTypeEnum() {
  if(contentsSupplier.getContent() == null || type == null) {
    return CellType.BLANK;
  } else if("n".equals(type)) {
    return CellType.NUMERIC;
  } else if("s".equals(type) || "inlineStr".equals(type)) {
    return CellType.STRING;
  } else if("str".equals(type)) {
    return CellType.FORMULA;
  } else if("b".equals(type)) {
    return CellType.BOOLEAN;
  } else if("e".equals(type)) {
    return CellType.ERROR;
  } else {
    throw new UnsupportedOperationException("Unsupported cell type '" + type + "'");
  }
}
 
开发者ID:monitorjbl,项目名称:excel-streaming-reader,代码行数:24,代码来源:StreamingCell.java

示例3: testGetCellTypeAsStr

@Test
public void testGetCellTypeAsStr() throws Exception {
	//
	ExpowCellLib cell = new ExpowCellLib(0, 0, CellType.STRING, "StringValue"); 
	assertEquals("CELL_TYPE_STRING", cell.getCellTypeAsStr());
	
	cell = new ExpowCellLib(0, 0, CellType.BLANK, ""); 
	assertEquals("CELL_TYPE_BLANK", cell.getCellTypeAsStr());

	cell = new ExpowCellLib(0, 0, CellType.BOOLEAN, "true"); 
	assertEquals("CELL_TYPE_BOOLEAN", cell.getCellTypeAsStr()); 

	cell = new ExpowCellLib(0, 0, CellType.ERROR, ""); 
	assertEquals("CELL_TYPE_ERROR", cell.getCellTypeAsStr());

	cell = new ExpowCellLib(0, 0, CellType.FORMULA, ""); 
	assertEquals("CELL_TYPE_FORMULA", cell.getCellTypeAsStr());
	
	cell = new ExpowCellLib(0, 0, CellType.NUMERIC, ""); 
	assertEquals("CELL_TYPE_NUMERIC", cell.getCellTypeAsStr());
}
 
开发者ID:nextreesoft,项目名称:expow,代码行数:21,代码来源:ExpowCellLibTest.java

示例4: getCachedFormulaResultTypeEnum

/**
 * Not supported
 */
@Override
public CellType getCachedFormulaResultTypeEnum() {
  if (type != null && "str".equals(type)) {
    if(contentsSupplier.getContent() == null || cachedFormulaResultType == null) {
      return CellType.BLANK;
    } else if("n".equals(cachedFormulaResultType)) {
      return CellType.NUMERIC;
    } else if("s".equals(cachedFormulaResultType) || "inlineStr".equals(cachedFormulaResultType)) {
      return CellType.STRING;
    } else if("str".equals(cachedFormulaResultType)) {
      return CellType.FORMULA;
    } else if("b".equals(cachedFormulaResultType)) {
      return CellType.BOOLEAN;
    } else if("e".equals(cachedFormulaResultType)) {
      return CellType.ERROR;
    } else {
      throw new UnsupportedOperationException("Unsupported cell type '" + cachedFormulaResultType + "'");
    }
  }
  else  {
    throw new IllegalStateException("Only formula cells have cached results");
  }
}
 
开发者ID:monitorjbl,项目名称:excel-streaming-reader,代码行数:26,代码来源:StreamingCell.java

示例5: copyCellByBlankSpace

/**
 * 复制单位格(空白行的复制,即只复制格式和固定文字,不填充数据)
 * 
 * @author      ZhengWei(HY)
 * @createDate  2017-07-03
 * @version     v1.0
 *
 * @param i_RTemplate      模板对象
 * @param i_TemplateCell   模板中的单元格对象
 * @param i_DataWorkbook   数据工作薄
 * @param i_DataCell       数据中的单元格对象
 * @param io_RSystemValue 系统变量信息
 * @param i_Datas          本行对应的数据
 * @param io_RValue        小计循环的迭代器
 * @return                 
 */
public final static void copyCellByBlankSpace(RTemplate i_RTemplate ,Cell i_TemplateCell ,RWorkbook i_DataWorkbook ,Cell i_DataCell ,RSystemValue io_RSystemValue)
{
    // 复制样式
    i_DataCell.setCellStyle(i_DataWorkbook.getCellStyle(i_RTemplate ,i_TemplateCell.getCellStyle().getIndex()));
    
    // 复制评论
    copyComment(i_RTemplate ,i_TemplateCell ,i_DataWorkbook ,i_DataCell);
    
    // 复制数据类型
    CellType v_CellType = i_TemplateCell.getCellTypeEnum();
    // i_DataCell.setCellType(v_CellType);  不能在此统一设置,原因是:下面代码对类型是有浮动的
    
    if ( v_CellType == CellType.NUMERIC ) 
    {
        i_DataCell.setCellType(v_CellType);
        
        if ( HSSFDateUtil.isCellDateFormatted(i_TemplateCell) ) 
        {
            i_DataCell.setCellValue(i_TemplateCell.getDateCellValue());
        } 
        else 
        {
            i_DataCell.setCellValue(i_TemplateCell.getNumericCellValue());
        }
    }
    else if ( v_CellType == CellType.STRING ) 
    {
        RichTextString v_TemplateRichText = i_TemplateCell.getRichStringCellValue();
        String         v_ValueName        = v_TemplateRichText.toString();
        
        if ( i_RTemplate.isExists(v_ValueName) )
        {
            i_DataCell.setCellType(v_CellType);
            i_DataCell.setCellValue("");
        }
        else 
        {
            i_DataCell.setCellType(v_CellType);
            copyRichTextStyle(i_RTemplate ,v_TemplateRichText ,i_DataWorkbook ,i_DataCell);
        }
    } 
    else if ( v_CellType == CellType.BOOLEAN ) 
    {
        i_DataCell.setCellType(v_CellType);
        i_DataCell.setCellValue(i_TemplateCell.getBooleanCellValue());
    } 
    else if ( v_CellType == CellType.FORMULA) 
    {
        i_DataCell.setCellType(v_CellType);
        i_DataCell.setCellFormula(i_TemplateCell.getCellFormula());
    } 
    else 
    {
        // Nothing.
        i_DataCell.setCellType(v_CellType);
    }
}
 
开发者ID:HY-ZhengWei,项目名称:hy.common.report,代码行数:73,代码来源:JavaToExcel.java

示例6: extractBlankValue

@Test
public void extractBlankValue() throws Exception {
    RowCellExtractor extractor = new RowCellExtractor(2, CellType.BOOLEAN);

    extractor.setRow(workbook.getSheet("sheet").getRow(0));
    assertEquals("true", extractor.extract());

    extractor.setRow(workbook.getSheet("sheet").getRow(1));
    thrown.expect(BlankCellException.class);
    thrown.expectMessage("Empty cell value");
    extractor.extract();
}
 
开发者ID:FutureCitiesCatapult,项目名称:TomboloDigitalConnector,代码行数:12,代码来源:RowCellExtractorTest.java

示例7: loadWorkbook

private void loadWorkbook(Workbook workbook) {
	String cellValue = null;
	for (int i = 0; i < workbook.getNumberOfSheets(); i++) {
		Sheet sheet = workbook.getSheetAt(i);
		System.out.println("sheet: " + workbook.getSheetName(i));
		// 有效值
		List<? extends DataValidation> dataValidations = sheet.getDataValidations();
		if (dataValidations != null && dataValidations.size() > 0) {
			System.out.println("data validations: ");
			for (DataValidation validation : dataValidations) {
				System.out.println(validation.toString());
			}
		}
		// 表格行
		for (Row row : sheet) {
			// 行单元格
			for (Cell cell : row) {
				cellValue = "";
				CellType cellType = cell.getCellTypeEnum();// CellType.forInt(cell.getCellType());
				if (cellType == CellType.STRING) {
					cellValue = cell.getRichStringCellValue().getString();
				} else if (cellType == CellType.NUMERIC) {
					if (DateUtil.isCellDateFormatted(cell)) {
						cellValue = String.valueOf(cell.getDateCellValue());
					} else {
						cellValue = String.valueOf(cell.getNumericCellValue());
					}
				} else if (cellType == CellType.BOOLEAN) {
					cellValue = String.valueOf(cell.getBooleanCellValue());
				} else if (cellType == CellType.FORMULA) {
					cellValue = String.valueOf(cell.getCellFormula());
				} else if (cellType == CellType.BLANK) {
					cellValue = String.valueOf(" ");
				}
				System.out.print(cellValue);
				System.out.print("  ");
			}
			System.out.println("");
		}
	}
}
 
开发者ID:color-coding,项目名称:btulz.transforms,代码行数:41,代码来源:testExcelTransformer.java


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