code: private function writeDefinedNameBiff8($name, $formulaData, $sheetIndex = 0, $isBuiltIn = false)
      {
          $record = 0x0018;
  
          // option flags
          $options = $isBuiltIn ? 0x20 : 0x00;
  
          // length of the name, character count
          $nlen = StringHelper::countCharacters($name);
  
          // name with stripped length field
          $name = substr(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;
      }
docs: 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 int $sheetIndex 1-based sheet index the defined name applies to. 0 = global
  @param bool $isBuiltIn Built-in name?
  
  @return string Complete binary record data