> For the complete documentation index, see [llms.txt](https://xlswriter-docs.viest.me/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://xlswriter-docs.viest.me/english/protection.md).

# Sheet protection

Enable Excel's worksheet protection to prevent users from editing cells. Protection can be applied with or without a password, and can be selectively lifted on individual cells, rows, or columns by combining it with the `Format::unlocked()` style.

## Function Prototype

```php
protection(?string $password = null): self
```

### **string $password**

> Optional. The unlock password. When omitted the sheet is still protected, but anyone can unlock it from the Excel UI without a password prompt.

Topics:

* [Password protection](/english/protection/password.md)
* [Unlock cells](/english/protection/unlock.md)
