Workbook.Protect

Workbook.Protect method

Protects a workbook.

public void Protect(ProtectionType protectionType, string password)
ParameterTypeDescription
protectionTypeProtectionTypeProtection type.
passwordStringPassword to protect the workbook.

Examples

using System;
using Aspose.Cells;

namespace AsposeCellsExamples
{
    public class WorkbookMethodProtectWithProtectionTypeStringDemo
    {
        public static void Run()
        {
            Workbook wbk = new Workbook();
            wbk.Protect(ProtectionType.Structure, "password123");
            
            wbk.Save("protected_workbook.xlsx", SaveFormat.Xlsx);
            wbk.Dispose();
        }
    }
}

See Also