Skip to content

jx:protect

jx:protect applies Excel sheet protection to the output. Lock formulas, prevent structure changes, or allow editing only in specific unlocked cells. Essential for reports that are shared with end users who shouldn’t modify certain data.

jx:protect(lastCell="A1" password="secret")
jx:protect(lastCell="A1" password="secret" sheet="true" formatCells="false" insertRows="false")
AttributeRequiredDescription
lastCellYesBottom-right cell of the command area
passwordNoProtection password (empty = protection without password)
sheetNoProtect the entire sheet (default: true)
formatCellsNoAllow formatting cells (default: false)
formatColumnsNoAllow formatting columns (default: false)
formatRowsNoAllow formatting rows (default: false)
insertColumnsNoAllow inserting columns (default: false)
insertRowsNoAllow inserting rows (default: false)
insertHyperlinksNoAllow inserting hyperlinks (default: false)
deleteColumnsNoAllow deleting columns (default: false)
deleteRowsNoAllow deleting rows (default: false)
selectLockedCellsNoAllow selecting locked cells (default: true)
sortNoAllow sorting (default: false)
autoFilterNoAllow auto-filter (default: false)
pivotTablesNoAllow pivot table operations (default: false)

Use it when your generated reports are shared with non-technical users and you need to prevent accidental or intentional modification:

  • Lock formula cells in financial reports (users see results but can’t edit formulas)
  • Protect structure in audit reports (no row/column insertion or deletion)
  • Allow only specific cells for input (combine with unlocked cell formatting)
  • Prevent tampering with generated compliance or regulatory documents
Cell A1 comment:
jx:area(lastCell="D10")
jx:each(items="items" var="item" lastCell="D1")
jx:protect(lastCell="A1" password="report2024")

The entire output sheet is protected. Users can view and select cells but cannot edit anything. The password report2024 is required to unprotect.

jx:protect(lastCell="A1" password="secret" sort="true" autoFilter="true")

The sheet is protected but users can sort and filter data. Perfect for read-only reports that still need to be interactive.

jx:protect(lastCell="A1")

Light protection — prevents accidental edits but anyone can unprotect via the Review tab. Good for “don’t touch this” signals without enforcing it.

To allow editing specific cells while protecting everything else:

  1. In your template, select the input cells and set their format to “Unlocked” (Format Cells > Protection > uncheck Locked)
  2. Add jx:protect to the template

Protected cells stay locked; unlocked cells remain editable. This is the standard Excel pattern for form-style spreadsheets.

Create named ranges for formula references:

jx:definedName →