NativeExcel for .Net Developer's Reference

IWorksheet.ProtectMethod

Protects a worksheet so that it cannot be modified.

Overload List

Protects a worksheet without using a password.

[Visual Basic] SubProtect()
[C#] voidProtect();
[C++] voidProtect();
[JScript] functionProtect();

Protects a worksheet with using a password.

[Visual Basic] SubProtect(ByValString)
[C#] voidProtect(string);
[C++] voidProtect(String*);
[JScript] functionProtect(String);

Example

This example protects worksheet one.

[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 | Unprotect Method