TRY NEW VERSION

Try now New API BETA

Try out the new view and capabilities of the API documentation

START

AddProtectedRange

AddProtectedRange(sTitle, sDataRange) → { ApiProtectedRange | null }

Creates a protected range of the specified type from the selected data range of the current sheet.

Parameters:

Name Type Description
sTitle string

The title which will be displayed for the current protected range.

sDataRange string

The selected cell range which will be used to get the data for the protected range.

Returns:

Type
ApiProtectedRange | null

Example

Copy code
builder.CreateFile("xlsx");
var oWorksheet = Api.GetActiveSheet();
oWorksheet.GetRange("A1").SetValue("1");
oWorksheet.GetRange("B1").SetValue("2");
oWorksheet.GetRange("C1").SetValue("3");
oWorksheet.AddProtectedRange("Protected range", "A1:C1");
builder.SaveFile("xlsx", "AddProtectedRange.xlsx");
builder.CloseFile();

Resulting document