首页 > 解决方案 > 如何使用 google sheet api v4 获取 protectedRangeId?

问题描述

我的目标是使用updateProtectedRange端点来更新现有的受保护工作表。

我的问题是,我首先如何获得 protectedRangeId ?

到目前为止我有这个代码吗?

const p = <target-sheet>.getProtections(SpreadsheetApp.ProtectionType.SHEET)[0];

标签: google-apps-script

解决方案


在仔细阅读文档后,我发现使用Sheets.Spreadsheets.get方法的属性:

const sheets = Sheets.Spreadsheets.get(ss.getId()).sheets;

// here just the first sheet, and first range
const protectedRangeId = sheets[0].protectedRanges[0];


推荐阅读