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


PHP PHPExcel::sheetNameExists方法代码示例

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


在下文中一共展示了PHPExcel::sheetNameExists方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setTitle

    /**
     * Set title
     *
     * @param string $pValue String containing the dimension of this worksheet
     * @param string $updateFormulaCellReferences boolean Flag indicating whether cell references in formulae should
     *        	be updated to reflect the new sheet name.
     *          This should be left as the default true, unless you are
     *          certain that no formula cells on any worksheet contain
     *          references to this worksheet
     * @return PHPExcel_Worksheet
     */
    public function setTitle($pValue = 'Worksheet', $updateFormulaCellReferences = true)
    {
        // Is this a 'rename' or not?
        if ($this->getTitle() == $pValue) {
            return $this;
        }

        // Syntax check
        self::_checkSheetTitle($pValue);

        // Old title
        $oldTitle = $this->getTitle();

        if ($this->_parent) {
            // Is there already such sheet name?
			if ($this->_parent->sheetNameExists($pValue)) {
                // Use name, but append with lowest possible integer

                if (PHPExcel_Shared_String::CountCharacters($pValue) > 29) {
                    $pValue = PHPExcel_Shared_String::Substring($pValue,0,29);
                }
                $i = 1;
				while ($this->_parent->sheetNameExists($pValue . ' ' . $i)) {
                    ++$i;
                    if ($i == 10) {
                        if (PHPExcel_Shared_String::CountCharacters($pValue) > 28) {
                            $pValue = PHPExcel_Shared_String::Substring($pValue,0,28);
                        }
                    } elseif ($i == 100) {
                        if (PHPExcel_Shared_String::CountCharacters($pValue) > 27) {
                            $pValue = PHPExcel_Shared_String::Substring($pValue,0,27);
                        }
                    }
                }

                $altTitle = $pValue . ' ' . $i;
                return $this->setTitle($altTitle,$updateFormulaCellReferences);
            }
        }

        // Set title
        $this->_title = $pValue;
        $this->_dirty = true;

        if ($this->_parent) {
            // New title
            $newTitle = $this->getTitle();
			PHPExcel_Calculation::getInstance($this->_parent)
			    ->renameCalculationCacheForWorksheet($oldTitle, $newTitle);
            if ($updateFormulaCellReferences)
				PHPExcel_ReferenceHelper::getInstance()->updateNamedFormulas($this->_parent, $oldTitle, $newTitle);
        }

        return $this;
    }
开发者ID:Rajagunasekaran,项目名称:BACKUP,代码行数:66,代码来源:Worksheet.php

示例2: getSheetByName

 /**
  * Gets a sheet by a loose name match unless
  * exactMatch is true. Returns a PHPExcel_Worksheet object
  * if a match is found, false if no match.
  * @param $name
  * @param bool|false $exactMatch
  * @return bool|\PHPExcel_Worksheet
  */
 private function getSheetByName($name, $exactMatch = false)
 {
     if ($exactMatch === false) {
         $name = strtolower($name);
         // determine a case insensitive match
         foreach ($this->workbook->getSheetNames() as $sheet) {
             if (strtolower($sheet) === $name) {
                 $use = $sheet;
                 break;
             }
         }
         if (!isset($use)) {
             return false;
         }
         $this->worksheet = $this->workbook->getSheetByName($use);
     } else {
         if ($this->workbook->sheetNameExists($name)) {
             $this->worksheet = $this->workbook->getSheetByName($name);
         } else {
             return false;
         }
     }
     return $this->worksheet;
 }
开发者ID:buphmin,项目名称:PHPExcelDataFiles,代码行数:32,代码来源:Container.php


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