Table of Contents

Method Protect

Namespace
DocWright.Spreadsheet
Assembly
DocWright.Spreadsheet.dll

Protect(XlsxSheetProtection?, string?)

Protects the sheet as Excel's Protect Sheet does: what it allows, and a password hashed as Excel hashes it (SHA-512, a random 16-byte salt, 100,000 spins) or none. A protection the sheet already has is replaced.

public void Protect(XlsxSheetProtection? options = null, string? password = null)

Parameters

options XlsxSheetProtection

What the protected sheet allows; null for Excel's defaults (selecting cells only).

password string

The password that unprotects it, or null for none.

Remarks

Protection is a flag for Excel's interface, not security; the password is not kept.

Exceptions

InvalidOperationException

The sheet is not a worksheet.

ArgumentException

The password is empty or holds a character a part cannot store.