code: private function writePassword()
      {
          // Exit unless sheet protection and password have been specified
          if (!$this->phpSheet->getProtection()->getSheet() || !$this->phpSheet->getProtection()->getPassword()) {
              return;
          }
  
          $record = 0x0013; // Record identifier
          $length = 0x0002; // Bytes to follow
  
          $wPassword = hexdec($this->phpSheet->getProtection()->getPassword()); // Encoded password
  
          $header = pack('vv', $record, $length);
          $data = pack('v', $wPassword);
  
          $this->append($header . $data);
      }
docs: Write the worksheet PASSWORD record.