NativeExcel for .Net Developer's Reference

IWorksheet.Protect Method

Protects a worksheet so that it cannot be modified.

Overload List

Protects a worksheet without using a password.

[Visual Basic] Sub Protect()
[C#] void Protect();
[C++] void Protect();
[JScript] function Protect();

Protects a worksheet with using a password.

[Visual Basic] Sub Protect(ByVal String)
[C#] void Protect(string);
[C++] void Protect(String*);
[JScript] function Protect(String);

Example

This example protects worksheet one.

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

See Also

IWorksheet Interface | NativeExcel Namespace | Unprotect Method