code: private function writeProtectedRanges(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet)
      {
          if (count($pSheet->getProtectedCells()) > 0) {
              // protectedRanges
              $objWriter->startElement('protectedRanges');
  
              // Loop protectedRanges
              foreach ($pSheet->getProtectedCells() as $protectedCell => $passwordHash) {
                  // protectedRange
                  $objWriter->startElement('protectedRange');
                  $objWriter->writeAttribute('name', 'p' . md5($protectedCell));
                  $objWriter->writeAttribute('sqref', $protectedCell);
                  if (!empty($passwordHash)) {
                      $objWriter->writeAttribute('password', $passwordHash);
                  }
                  $objWriter->endElement();
              }
  
              $objWriter->endElement();
          }
      }
docs: Write ProtectedRanges.
  
  @param XMLWriter $objWriter XML Writer
  @param PhpspreadsheetWorksheet $pSheet Worksheet