XLSX
Sheet Protection
Lock worksheets to restrict editing
Protecting a Worksheet
Protect a worksheet with a password and restrict user actions:
{
"worksheets": [
{
"name": "Protected",
"rows": [
{ "cells": [{ "value": "Quarter" }, { "value": "2023" }, { "value": "2024" }] },
{ "cells": [{ "value": "Q1" }, { "value": 100 }, { "value": 120 }] },
{ "cells": [{ "value": "Q2" }, { "value": 150 }, { "value": 170 }] }
],
"protection": {
"sheet": true,
"password": "secret",
"formatCells": false,
"insertRows": false,
"sort": false
}
}
]
}
{
name: "Protected",
rows: [
{ cells: [{ value: "Quarter" }, { value: "2023" }, { value: "2024" }] },
{ cells: [{ value: "Q1" }, { value: 100 }, { value: 120 }] },
{ cells: [{ value: "Q2" }, { value: 150 }, { value: 170 }] },
],
protection: {
sheet: true,
password: "secret",
formatCells: false,
insertRows: false,
sort: false,
},
}
Protection Options Reference
| Option | Type | Description |
|---|---|---|
sheet | boolean | Enable sheet protection |
password | string | Protection password |
objects | boolean | Protect objects |
scenarios | boolean | Protect scenarios |
formatCells | boolean | Allow formatting cells |
formatColumns | boolean | Allow formatting columns |
formatRows | boolean | Allow formatting rows |
insertColumns | boolean | Allow inserting columns |
insertRows | boolean | Allow inserting rows |
insertHyperlinks | boolean | Allow inserting hyperlinks |
deleteColumns | boolean | Allow deleting columns |
deleteRows | boolean | Allow deleting rows |
selectLockedCells | boolean | Allow selecting locked cells |
sort | boolean | Allow sorting |
autoFilter | boolean | Allow auto filter |
pivotTables | boolean | Allow pivot tables |
selectUnlockedCells | boolean | Allow selecting unlocked cells |