You are here

public function PHPExcel_Cell::setValueExplicit in Loft Data Grids 6.2

Same name and namespace in other branches
  1. 7.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Cell.php \PHPExcel_Cell::setValueExplicit()

* Set the value for a cell, with the explicit data type passed to the method (bypassing any use of the value binder) * *

Parameters

mixed $pValue Value: * @param string $pDataType Explicit data type * @return PHPExcel_Cell * @throws PHPExcel_Exception

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Cell.php, line 225

Class

PHPExcel_Cell
PHPExcel_Cell

Code

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_NULL:
      $this->_value = $pValue;
      break;
    case PHPExcel_Cell_DataType::TYPE_STRING2:
      $pDataType = PHPExcel_Cell_DataType::TYPE_STRING;
    case PHPExcel_Cell_DataType::TYPE_STRING:
    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();
}