using IronXL;
WorkBook workBook = WorkBook.Load("sample.xlsx");
WorkSheet workSheet = workBook.DefaultWorkSheet;
// Open protected spreadsheet file
WorkBook protectedWorkBook = WorkBook.Load("sample.xlsx", "IronSoftware");
// Spreadsheet protection
// Set protection for spreadsheet file
workBook.Encrypt("IronSoftware");
// Remove protection for spreadsheet file. Original password is required.
workBook.Password = null;
workBook.Save();
// Worksheet protection
// Set protection for individual worksheet
workSheet.ProtectSheet("IronXL");
// Remove protection for particular worksheet. It works without password!
workSheet.UnprotectSheet();
workBook.Save();
Imports IronXL
Private workBook As WorkBook = WorkBook.Load("sample.xlsx")
Private workSheet As WorkSheet = workBook.DefaultWorkSheet
' Open protected spreadsheet file
Private protectedWorkBook As WorkBook = WorkBook.Load("sample.xlsx", "IronSoftware")
' Spreadsheet protection
' Set protection for spreadsheet file
workBook.Encrypt("IronSoftware")
' Remove protection for spreadsheet file. Original password is required.
workBook.Password = Nothing
workBook.Save()
' Worksheet protection
' Set protection for individual worksheet
workSheet.ProtectSheet("IronXL")
' Remove protection for particular worksheet. It works without password!
workSheet.UnprotectSheet()
workBook.Save()