typed-xlsx
Workbook

Protection

Lock a workbook's structure, protect sheets, and choose which cells stay editable or hide their formulas.

Protection has three levels, and the cell level only works inside a protected sheet:

  1. 1WorkbookcreateWorkbook({ protection })locks the structure: no adding, removing or renaming sheets
  2. 2Sheet.sheet(name, { protection })makes locked cells read-only and hides hidden formulas
  3. 3Cellstyle: { protection }marks a cell as editable (locked: false) or its formula as hidden
kitchen-sink.xlsxOpen in playground
1
2
3
4
5
6
7
Editable Inputs, Locked Logic
Owner
Requested Budget
Approved Budget
Maya Chen
$42,000
$37,800
Noah Patel
$18,000
$16,200
Lena Ortiz
$12,000
$10,800
11 Protected Inputs
A protected sheet where only the input column is editable, from the kitchen-sink example.

Choose which cells stay editable

Every cell is locked by default. In a protected sheet, unlock the inputs people should fill in, and hide formulas you don't want shown in the formula bar:

import { 
createExcelSchema
,
createWorkbook
} from "typed-xlsx";
type
Renewal
= {
account
: string;
target
: number };
const
schema
=
createExcelSchema
<
Renewal
>()
.
column
("account", {
header
: "Account",
accessor
: "account" })
.
column
("target", {
header
: "Target ARR",
accessor
: "target",
style
: {
protection
: {
locked
: false } },
}) .
column
("uplift", {
header
: "Uplift",
formula
: ({
refs
}) =>
refs
.
column
("target").
mul
(0.08),
style
: {
protection
: {
hidden
: true } },
}) .
build
();
createWorkbook
()
.
sheet
("Renewals", {
protection
: {
password
: "ops",
selectLockedCells
: false } })
.
table
("renewals", {
schema
,
rows
: [{
account
: "Acme",
target
: 112000 }] });

Here people can only select and edit Target ARR; the Uplift formula is computed but not visible. To make the editable cells stand out, give unlocked cells a look with table defaults or the theme's cellUnlocked slot.

Sheet protection

protection: true protects the sheet with Excel's default permissions. An object sets a password and individual permissions:

import { 
createWorkbook
} from "typed-xlsx";
createWorkbook
().
sheet
("Data", {
protection
: {
password
: "sheet-secret",
selectUnlockedCells
: true,
selectLockedCells
: false,
sort
: true,
autoFilter
: true,
formatCells
: false,
insertRows
: false,
deleteRows
: false,
}, });

The streaming builder's .sheet() takes the same option.

Workbook protection

Workbook protection is about the tabs, not the cells:

import { 
createWorkbook
} from "typed-xlsx";
const
workbook
=
createWorkbook
({
protection
: {
password
: "workbook-secret",
structure
: true },
});
Excel's sheet passwords deter accidental edits; they are not encryption. Anyone with the file can remove them with common tools.

Conditional styles can't change protection: whether a cell is locked or hidden is always set through style.

Copyright © 2026 Cyprien Thao. Released under the MIT License.