Example #1
0
 /**
  * Compare two strings in the same way as strcmp() except that lowercase come before uppercase letters
  * @param    string    $str1    First string value for the comparison
  * @param    string    $str2    Second string value for the comparison
  * @return   integer
  */
 private function strcmpLowercaseFirst($str1, $str2)
 {
     $inversedStr1 = Shared\StringHelper::strCaseReverse($str1);
     $inversedStr2 = Shared\StringHelper::strCaseReverse($str2);
     return strcmp($inversedStr1, $inversedStr2);
 }
Example #2
0
 /**
  * Define the code name of the sheet
  *
  * @param null|string Same rule as Title minus space not allowed (but, like Excel, change silently space to underscore)
  * @return objWorksheet
  * @throws Exception
  */
 public function setCodeName($pValue = null)
 {
     // Is this a 'rename' or not?
     if ($this->getCodeName() == $pValue) {
         return $this;
     }
     $pValue = str_replace(' ', '_', $pValue);
     //Excel does this automatically without flinching, we are doing the same
     // Syntax check
     // throw an exception if not valid
     self::checkSheetCodeName($pValue);
     // We use the same code that setTitle to find a valid codeName else not using a space (Excel don't like) but a '_'
     if ($this->getParent()) {
         // Is there already such sheet name?
         if ($this->getParent()->sheetCodeNameExists($pValue)) {
             // Use name, but append with lowest possible integer
             if (Shared\StringHelper::countCharacters($pValue) > 29) {
                 $pValue = Shared\StringHelper::substring($pValue, 0, 29);
             }
             $i = 1;
             while ($this->getParent()->sheetCodeNameExists($pValue . '_' . $i)) {
                 ++$i;
                 if ($i == 10) {
                     if (Shared\StringHelper::countCharacters($pValue) > 28) {
                         $pValue = Shared\StringHelper::substring($pValue, 0, 28);
                     }
                 } elseif ($i == 100) {
                     if (Shared\StringHelper::countCharacters($pValue) > 27) {
                         $pValue = Shared\StringHelper::substring($pValue, 0, 27);
                     }
                 }
             }
             $pValue = $pValue . '_' . $i;
             // ok, we have a valid name
             //codeName is'nt used in formula : no need to call for an update
             //return $this->setTitle($altTitle, $updateFormulaCellReferences);
         }
     }
     $this->codeName = $pValue;
     return $this;
 }