本文整理汇总了PHP中PHPExcel_Cell_DataType::checkErrorCode方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPExcel_Cell_DataType::checkErrorCode方法的具体用法?PHP PHPExcel_Cell_DataType::checkErrorCode怎么用?PHP PHPExcel_Cell_DataType::checkErrorCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPExcel_Cell_DataType
的用法示例。
在下文中一共展示了PHPExcel_Cell_DataType::checkErrorCode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setValueExplicit
/**
* Set the value for a cell, with the explicit data type passed to the method (bypassing any use of the value binder)
*
* @param mixed $pValue Value
* @param string $pDataType Explicit data type
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function setValueExplicit($pValue = NULL, $pDataType = PHPExcel_Cell_DataType::TYPE_STRING)
{
// set the value according to data type
switch ($pDataType) {
case PHPExcel_Cell_DataType::TYPE_STRING2:
$pDataType = PHPExcel_Cell_DataType::TYPE_STRING;
case PHPExcel_Cell_DataType::TYPE_STRING:
case PHPExcel_Cell_DataType::TYPE_NULL:
case PHPExcel_Cell_DataType::TYPE_INLINE:
$this->_value = PHPExcel_Cell_DataType::checkString($pValue);
break;
case PHPExcel_Cell_DataType::TYPE_NUMERIC:
$this->_value = (double) $pValue;
break;
case PHPExcel_Cell_DataType::TYPE_FORMULA:
$this->_value = (string) $pValue;
break;
case PHPExcel_Cell_DataType::TYPE_BOOL:
$this->_value = (bool) $pValue;
break;
case PHPExcel_Cell_DataType::TYPE_ERROR:
$this->_value = PHPExcel_Cell_DataType::checkErrorCode($pValue);
break;
default:
throw new PHPExcel_Exception('Invalid datatype: ' . $pDataType);
break;
}
// set the datatype
$this->_dataType = $pDataType;
return $this->notifyCacheController();
}
示例2: getCellValue
/**
* Get cell value
*
* Get the value for a specific data type
*
* @todo Check the actual usefulness of this method
*
* @param $value
* @param string $cellDataType
* @return bool|float|mixed|string
* @throws Exception
*/
public function getCellValue($value, $cellDataType = '')
{
if ($cellDataType == '') {
return $value;
}
switch ($cellDataType) {
case PHPExcel_Cell_DataType::TYPE_STRING2:
case PHPExcel_Cell_DataType::TYPE_STRING:
case PHPExcel_Cell_DataType::TYPE_NULL:
case PHPExcel_Cell_DataType::TYPE_INLINE:
return PHPExcel_Cell_DataType::checkString($value);
case PHPExcel_Cell_DataType::TYPE_NUMERIC:
return (double) $value;
case PHPExcel_Cell_DataType::TYPE_FORMULA:
return '=FORMULA(' . (string) $value . ')';
case PHPExcel_Cell_DataType::TYPE_BOOL:
return (bool) $value;
case PHPExcel_Cell_DataType::TYPE_ERROR:
return PHPExcel_Cell_DataType::checkErrorCode($value);
default:
throw new Exception('Invalid datatype: ' . $cellDataType);
break;
}
}