Beispiel #1
0
 /**
  * Write a DEFINEDNAME record for BIFF8 using explicit binary formula data
  *
  * @param    string        $name            The name in UTF-8
  * @param    string        $formulaData    The binary formula data
  * @param    string        $sheetIndex        1-based sheet index the defined name applies to. 0 = global
  * @param    boolean        $isBuiltIn        Built-in name?
  * @return    string    Complete binary record data
  */
 private function writeDefinedNameBiff8($name, $formulaData, $sheetIndex = 0, $isBuiltIn = false)
 {
     $record = 0x18;
     // option flags
     $options = $isBuiltIn ? 0x20 : 0x0;
     // length of the name, character count
     $nlen = \PHPExcel\Shared\StringHelper::countCharacters($name);
     // name with stripped length field
     $name = substr(\PHPExcel\Shared\StringHelper::UTF8toBIFF8UnicodeLong($name), 2);
     // size of the formula (in bytes)
     $sz = strlen($formulaData);
     // combine the parts
     $data = pack('vCCvvvCCCC', $options, 0, $nlen, $sz, 0, $sheetIndex, 0, 0, 0, 0) . $name . $formulaData;
     $length = strlen($data);
     $header = pack('vv', $record, $length);
     return $header . $data;
 }
Beispiel #2
0
 /**
  * SEARCHINSENSITIVE
  *
  * @param    string    $needle        The string to look for
  * @param    string    $haystack    The string in which to look
  * @param    int        $offset        Offset within $haystack
  * @return    string
  */
 public static function SEARCHINSENSITIVE($needle, $haystack, $offset = 1)
 {
     $needle = Functions::flattenSingleValue($needle);
     $haystack = Functions::flattenSingleValue($haystack);
     $offset = Functions::flattenSingleValue($offset);
     if (!is_bool($needle)) {
         if (is_bool($haystack)) {
             $haystack = $haystack ? \PHPExcel\Calculation::getTRUE() : \PHPExcel\Calculation::getFALSE();
         }
         if ($offset > 0 && \PHPExcel\Shared\StringHelper::countCharacters($haystack) > $offset) {
             if (\PHPExcel\Shared\StringHelper::countCharacters($needle) == 0) {
                 return $offset;
             }
             if (function_exists('mb_stripos')) {
                 $pos = mb_stripos($haystack, $needle, --$offset, 'UTF-8');
             } else {
                 $pos = stripos($haystack, $needle, --$offset);
             }
             if ($pos !== false) {
                 return ++$pos;
             }
         }
     }
     return Functions::VALUE();
 }
Beispiel #3
0
 /**
  * Used to write internal reference hyperlinks such as "Sheet1!A1".
  *
  * @access private
  * @see writeUrl()
  * @param integer $row1   Start row
  * @param integer $col1   Start column
  * @param integer $row2   End row
  * @param integer $col2   End column
  * @param string  $url    URL string
  * @return integer
  */
 public function writeUrlInternal($row1, $col1, $row2, $col2, $url)
 {
     $record = 0x1b8;
     // Record identifier
     $length = 0x0;
     // Bytes to follow
     // Strip URL type
     $url = preg_replace('/^internal:/', '', $url);
     // Pack the undocumented parts of the hyperlink stream
     $unknown1 = pack("H*", "D0C9EA79F9BACE118C8200AA004BA90B02000000");
     // Pack the option flags
     $options = pack("V", 0x8);
     // Convert the URL type and to a null terminated wchar string
     $url .= "";
     // character count
     $url_len = \PHPExcel\Shared\StringHelper::countCharacters($url);
     $url_len = pack('V', $url_len);
     $url = \PHPExcel\Shared\StringHelper::convertEncoding($url, 'UTF-16LE', 'UTF-8');
     // Calculate the data length
     $length = 0x24 + strlen($url);
     // Pack the header data
     $header = pack("vv", $record, $length);
     $data = pack("vvvv", $row1, $row2, $col1, $col2);
     // Write the packed data
     $this->append($header . $data . $unknown1 . $options . $url_len . $url);
     return 0;
 }