# 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)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://xlswriter-docs.viest.me/english/protection.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
