NativeExcel2 for .Net Developer's Reference

IWorksheet.ProtectMethod(String)

Protects a worksheet with using a password.

[Visual Basic]
SubProtect(_
ByValPasswordAsString_
)
[C#]
voidProtect(
stringPassword
);
[C++]
voidProtect(
String*Password
);
[JScript]
functionProtect(
StringPassword
);

Parameters

Password
A string that specifies a case-sensitive password for the worksheet. If this argument is omitted, you can unprotect the worksheet without using a password. Otherwise, you must specify the password to unprotect the worksheet.

Example

This example protects worksheet one with password.

[C#]
book.Worksheets[1].Protect("Pass1234"); 
[VisualBasic]
book.Worksheets(1).Protect("Pass1234")
[C++]
book->Worksheets->Item[1]->Protect(S"Pass1234");

See Also

IWorksheet Interface | NativeExcel Namespace | IWorksheet.Protect Overload List | Unprotect Method