XLSX

工作表保护

锁定工作表,限制编辑操作

保护工作表

使用密码保护工作表并限制用户操作:

{
  "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
      }
    }
  ]
}

保护选项参考

选项类型说明
sheetboolean启用工作表保护
passwordstring保护密码
objectsboolean保护对象
scenariosboolean保护方案
formatCellsboolean允许格式化单元格
formatColumnsboolean允许格式化列
formatRowsboolean允许格式化行
insertColumnsboolean允许插入列
insertRowsboolean允许插入行
insertHyperlinksboolean允许插入超链接
deleteColumnsboolean允许删除列
deleteRowsboolean允许删除行
selectLockedCellsboolean允许选取锁定单元格
sortboolean允许排序
autoFilterboolean允许自动筛选
pivotTablesboolean允许数据透视表
selectUnlockedCellsboolean允许选取未锁定单元格
Copyright © 2026