当前路径:Classes/PHPExcel/Cell.php <?php /** * PHPExcel_Cell * * Copyright (c) 2006 - 2015 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category PHPExcel * @package PHPExcel_Cell * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version ##VERSION##, ##DATE## */ class PHPExcel_Cell { /** * Default range variable constant * * @var string */ const DEFAULT_RANGE = 'A1:A1'; /** * Value binder to use * * @var PHPExcel_Cell_IValueBinder */ private static $valueBinder; /** * Value of the cell * * @var mixed */ private $value; /** * Calculated value of the cell (used for caching) * This returns the value last calculated by MS Excel or whichever spreadsheet program was used to * create the original spreadsheet file. * Note that this value is not guaranteed to reflect the actual calculated value because it is * possible that auto-calculation was disabled in the original spreadsheet, and underlying data * values used by the formula have changed since it was last calculated. * * @var mixed */ private $calculatedValue; /** * Type of the cell data * * @var string */ private $dataType; /** * Parent worksheet * * @var PHPExcel_CachedObjectStorage_CacheBase */ private $parent; /** * Index to cellXf * * @var int */ private $xfIndex = 0; /** * Attributes of the formula * */ private $formulaAttributes; /** * Send notification to the cache controller * * @return void **/ public function notifyCacheController() { $this->parent->updateCacheData($this); return $this; } public function detach() { $this->parent = null; } public function attach(PHPExcel_CachedObjectStorage_CacheBase $parent) { $this->parent = $parent; } /** * Create a new Cell * * @param mixed $pValue * @param string $pDataType * @param PHPExcel_Worksheet $pSheet * @throws PHPExcel_Exception */ public function __construct($pValue = null, $pDataType = null, PHPExcel_Worksheet $pSheet = null) { // Initialise cell value $this->value = $pValue; // Set worksheet cache $this->parent = $pSheet->getCellCacheController(); // Set datatype? if ($pDataType !== null) { if ($pDataType == PHPExcel_Cell_DataType::TYPE_STRING2) { $pDataType = PHPExcel_Cell_DataType::TYPE_STRING; } $this->dataType = $pDataType; } elseif (!self::getValueBinder()->bindValue($this, $pValue)) { throw new PHPExcel_Exception("Value could not be bound to cell."); } } /** * Get cell coordinate column * * @return string */ public function getColumn() { return $this->parent->getCurrentColumn(); } /** * Get cell coordinate row * * @return int */ public function getRow() { return $this->parent->getCurrentRow(); } /** * Get cell coordinate * * @return string */ public function getCoordinate() { return $this->parent->getCurrentAddress(); } /** * Get cell value * * @return mixed */ public function getValue() { return $this->value; } /** * Get cell value with formatting * * @return string */ public function getFormattedValue() { return (string) PHPExcel_Style_NumberFormat::toFormattedString( $this->getCalculatedValue(), $this->getStyle() ->getNumberFormat()->getFormatCode() ); } /** * Set cell value * * Sets the value for a cell, automatically determining the datatype using the value binder * * @param mixed $pValue Value * @return PHPExcel_Cell * @throws PHPExcel_Exception */ public function setValue($pValue = null) { if (!self::getValueBinder()->bindValue($this, $pValue)) { throw new PHPExcel_Exception("Value could not be bound to cell."); } return $this; } /** * 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_NULL: $this->value = $pValue; break; case PHPExcel_Cell_DataType::TYPE_STRING2: $pDataType = PHPExcel_Cell_DataType::TYPE_STRING; // no break case PHPExcel_Cell_DataType::TYPE_STRING: // Synonym for string case PHPExcel_Cell_DataType::TYPE_INLINE: // Rich text $this->value = PHPExcel_Cell_DataType::checkString($pValue); break; case PHPExcel_Cell_DataType::TYPE_NUMERIC: $this->value = (float) $pValue; break; case PHPExcel_Cell_DataType::TYPE_FORMULA: $this->value = (string) $pValue; ...
完整源码文件,请先购买后再查看
相关源码
- JAVA+SPRINGBOOT心灵心理健康平台(心灵治愈交流平台)(含论文)源码2023-09-27
- JAVA+SPRINGBOOT+VUE工厂车间管理系统(含论文)源码2023-09-27
- JAVA_SSM+VUE校园二手物品交易平台(含论文)源码2023-09-27
- JAVA+SSM医院住院管理系统(含论文)源码2023-09-27
- JAVA VUE SSM教材管理系统(含论文、PPT)课程设计2023-09-27
- 基于SPRINGBOOT 旅游共享平台 + 论文2023-09-26
关于我们 | 顾问团队 | 发展历程 | 联系我们 | 源码上传
联系电话(Tel):4008-010-151(免长途)
地址:北京市海淀区大恒科技大厦五层 邮编:100080
Floor 5th,Daheng Building,Zhongguancun,Beijing,China,100080
51Aspx.com 版权所有 CopyRight © 2006-2023. 京ICP备09089570号 | 京公网安备11010702000869号
联系电话(Tel):4008-010-151(免长途)
地址:北京市海淀区大恒科技大厦五层 邮编:100080
Floor 5th,Daheng Building,Zhongguancun,Beijing,China,100080
51Aspx.com 版权所有 CopyRight © 2006-2023. 京ICP备09089570号 | 京公网安备11010702000869号