本文整理汇总了PHP中PHPExcel_ReferenceHelper类的典型用法代码示例。如果您正苦于以下问题:PHP PHPExcel_ReferenceHelper类的具体用法?PHP PHPExcel_ReferenceHelper怎么用?PHP PHPExcel_ReferenceHelper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PHPExcel_ReferenceHelper类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getInstance
/**
* Get an instance of this class
*
* @return PHPExcel_ReferenceHelper
*/
public static function getInstance()
{
if (!isset(self::$_instance) || is_null(self::$_instance)) {
self::$_instance = new PHPExcel_ReferenceHelper();
}
return self::$_instance;
}
示例2: removeColumn
/**
* Remove a column, updating all possible related data
*
* @param int $pColumn Remove starting with this one
* @param int $pNumCols Number of columns to remove
* @throws PHPExcel_Exception
* @return PHPExcel_Worksheet
*/
public function removeColumn($pColumn = 'A', $pNumCols = 1)
{
if (!is_numeric($pColumn)) {
$pColumn = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($pColumn) - 1 + $pNumCols);
$objReferenceHelper = PHPExcel_ReferenceHelper::getInstance();
$objReferenceHelper->insertNewBefore($pColumn . '1', -$pNumCols, 0, $this);
} else {
throw new PHPExcel_Exception("Column references should not be numeric.");
}
return $this;
}
示例3: load
//.........这里部分代码省略.........
} else {
$value = (bool) $c->v;
}
}
break;
case "inlineStr":
$value = $this->_parseRichText($c->is);
break;
case "e":
if (!isset($c->f)) {
$value = (string) $c->v;
} else {
$value = "={$c->f}";
}
break;
default:
if (!isset($c->f)) {
$value = (string) $c->v;
} else {
// Formula
$value = "={$c->f}";
$cellDataType = 'f';
// Shared formula?
if (isset($c->f['t']) && strtolower((string) $c->f['t']) == 'shared') {
$instance = (string) $c->f['si'];
if (!isset($sharedFormulas[(string) $c->f['si']])) {
$sharedFormulas[$instance] = array('master' => $r, 'formula' => $value);
} else {
$master = PHPExcel_Cell::coordinateFromString($sharedFormulas[$instance]['master']);
$current = PHPExcel_Cell::coordinateFromString($r);
$difference = array(0, 0);
$difference[0] = PHPExcel_Cell::columnIndexFromString($current[0]) - PHPExcel_Cell::columnIndexFromString($master[0]);
$difference[1] = $current[1] - $master[1];
$helper = PHPExcel_ReferenceHelper::getInstance();
$x = $helper->updateFormulaReferences($sharedFormulas[$instance]['formula'], 'A1', $difference[0], $difference[1]);
$value = $x;
}
}
}
break;
}
// Check for numeric values
if (is_numeric($value) && $cellDataType != 's') {
if ($value == (int) $value) {
$value = (int) $value;
} elseif ($value == (double) $value) {
$value = (double) $value;
} elseif ($value == (double) $value) {
$value = (double) $value;
}
}
// Rich text?
if ($value instanceof PHPExcel_RichText && $this->_readDataOnly) {
$value = $value->getPlainText();
}
// Assign value
if ($cellDataType != '') {
$docSheet->setCellValueExplicit($r, $value, $cellDataType);
} else {
$docSheet->setCellValue($r, $value);
}
// Style information?
if ($c["s"] && !$this->_readDataOnly) {
if (isset($styles[intval($c["s"])])) {
$this->_readStyle($docSheet->getStyle($r), $styles[intval($c["s"])]);
}
示例4: setName
/**
* Set name
*
* @param string $value
* @return PHPExcel_NamedRange
*/
public function setName($value = null)
{
if ($value !== null) {
// Old title
$oldTitle = $this->name;
// Re-attach
if ($this->worksheet !== null) {
$this->worksheet->getParent()->removeNamedRange($this->name, $this->worksheet);
}
$this->name = $value;
if ($this->worksheet !== null) {
$this->worksheet->getParent()->addNamedRange($this);
}
// New title
$newTitle = $this->name;
PHPExcel_ReferenceHelper::getInstance()->updateNamedFormulas($this->worksheet->getParent(), $oldTitle, $newTitle);
}
return $this;
}
示例5: __construct
/**
* Create a new PHPExcel_Reader_Excel2007 instance
*/
public function __construct()
{
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
$this->_referenceHelper = PHPExcel_ReferenceHelper::getInstance();
}
示例6: removeColumn
/**
* Remove a column, updating all possible related data
*
* @param string $pColumn Remove starting with this one
* @param int $pNumCols Number of columns to remove
* @throws PHPExcel_Exception
* @return PHPExcel_Worksheet
*/
public function removeColumn($pColumn = 'A', $pNumCols = 1)
{
if (!is_numeric($pColumn)) {
$highestColumn = $this->getHighestDataColumn();
$pColumn = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($pColumn) - 1 + $pNumCols);
$objReferenceHelper = PHPExcel_ReferenceHelper::getInstance();
$objReferenceHelper->insertNewBefore($pColumn . '1', -$pNumCols, 0, $this);
for ($c = 0; $c < $pNumCols; ++$c) {
$this->getCellCacheController()->removeColumn($highestColumn);
$highestColumn = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($highestColumn) - 2);
}
} else {
throw new PHPExcel_Exception("Column references should not be numeric.");
}
return $this;
}
示例7: _castToFormula
private function _castToFormula($c, $r, &$cellDataType, &$value, &$calculatedValue, &$sharedFormulas, $castBaseType) {
// echo '<font color="darkgreen">Formula</font><br />';
// echo '$c->f is '.$c->f.'<br />';
$cellDataType = 'f';
$value = "={$c->f}";
$calculatedValue = self::$castBaseType ( $c );
// Shared formula?
if (isset ( $c->f ['t'] ) && strtolower ( ( string ) $c->f ['t'] ) == 'shared') {
// echo '<font color="darkgreen">SHARED FORMULA</font><br />';
$instance = ( string ) $c->f ['si'];
// echo 'Instance ID = '.$instance.'<br />';
//
// echo 'Shared Formula Array:<pre>';
// print_r($sharedFormulas);
// echo '</pre>';
if (! isset ( $sharedFormulas [( string ) $c->f ['si']] )) {
// echo '<font color="darkgreen">SETTING NEW SHARED
// FORMULA</font><br />';
// echo 'Master is '.$r.'<br />';
// echo 'Formula is '.$value.'<br />';
$sharedFormulas [$instance] = array (
'master' => $r,
'formula' => $value
);
// echo 'New Shared Formula Array:<pre>';
// print_r($sharedFormulas);
// echo '</pre>';
} else {
// echo '<font color="darkgreen">GETTING SHARED
// FORMULA</font><br />';
// echo 'Master is '.$sharedFormulas[$instance]['master'].'<br
// />';
// echo 'Formula is '.$sharedFormulas[$instance]['formula'].'<br
// />';
$master = PHPExcel_Cell::coordinateFromString ( $sharedFormulas [$instance] ['master'] );
$current = PHPExcel_Cell::coordinateFromString ( $r );
$difference = array (
0,
0
);
$difference [0] = PHPExcel_Cell::columnIndexFromString ( $current [0] ) - PHPExcel_Cell::columnIndexFromString ( $master [0] );
$difference [1] = $current [1] - $master [1];
$value = $this->_referenceHelper->updateFormulaReferences ( $sharedFormulas [$instance] ['formula'], 'A1', $difference [0], $difference [1] );
// echo 'Adjusted Formula is '.$value.'<br />';
}
}
}
示例8: _castToFormula
private function _castToFormula($c, $r, &$cellDataType, &$value, &$calculatedValue, &$sharedFormulas, $castBaseType)
{
$cellDataType = 'f';
$value = "={$c->f}";
$calculatedValue = self::$castBaseType($c);
// Shared formula ?
if (isset($c->f['t']) && strtolower((string) $c->f['t']) == 'shared') {
$instance = (string) $c->f['si'];
if (!isset($sharedFormulas[(string) $c->f['si']])) {
$sharedFormulas[$instance] = array('master' => $r, 'formula' => $value);
} else {
$master = PHPExcel_Cell::coordinateFromString($sharedFormulas[$instance]['master']);
$current = PHPExcel_Cell::coordinateFromString($r);
$difference = array(0, 0);
$difference[0] = PHPExcel_Cell::columnIndexFromString($current[0]) - PHPExcel_Cell::columnIndexFromString($master[0]);
$difference[1] = $current[1] - $master[1];
$value = $this->_referenceHelper->updateFormulaReferences($sharedFormulas[$instance]['formula'], 'A1', $difference[0], $difference[1]);
}
}
}
示例9: castToFormula
private function castToFormula($c, $r, &$cellDataType, &$value, &$calculatedValue, &$sharedFormulas, $castBaseType)
{
// echo 'Formula', PHP_EOL;
// echo '$c->f is ', $c->f, PHP_EOL;
$cellDataType = 'f';
$value = "={$c->f}";
$calculatedValue = self::$castBaseType($c);
// Shared formula?
if (isset($c->f['t']) && strtolower((string) $c->f['t']) == 'shared') {
// echo 'SHARED FORMULA', PHP_EOL;
$instance = (string) $c->f['si'];
// echo 'Instance ID = ', $instance, PHP_EOL;
//
// echo 'Shared Formula Array:', PHP_EOL;
// print_r($sharedFormulas);
if (!isset($sharedFormulas[(string) $c->f['si']])) {
// echo 'SETTING NEW SHARED FORMULA', PHP_EOL;
// echo 'Master is ', $r, PHP_EOL;
// echo 'Formula is ', $value, PHP_EOL;
$sharedFormulas[$instance] = array('master' => $r, 'formula' => $value);
// echo 'New Shared Formula Array:', PHP_EOL;
// print_r($sharedFormulas);
} else {
// echo 'GETTING SHARED FORMULA', PHP_EOL;
// echo 'Master is ', $sharedFormulas[$instance]['master'], PHP_EOL;
// echo 'Formula is ', $sharedFormulas[$instance]['formula'], PHP_EOL;
$master = PHPExcel_Cell::coordinateFromString($sharedFormulas[$instance]['master']);
$current = PHPExcel_Cell::coordinateFromString($r);
$difference = array(0, 0);
$difference[0] = PHPExcel_Cell::columnIndexFromString($current[0]) - PHPExcel_Cell::columnIndexFromString($master[0]);
$difference[1] = $current[1] - $master[1];
$value = $this->referenceHelper->updateFormulaReferences($sharedFormulas[$instance]['formula'], 'A1', $difference[0], $difference[1]);
// echo 'Adjusted Formula is ', $value, PHP_EOL;
}
}
}