Other API Samples C# logo

Password-Protected Files SpreadsheetGear API Sample

Description

SpreadsheetGear supports reading and writing encrypted workbooks with Agile Encryption used by Excel 2013 and later, including default SHA-512 encryption for workbooks.

Source Code

// First create an empty workbook set.
SpreadsheetGear.IWorkbookSet workbookSet = SpreadsheetGear.Factory.GetWorkbookSet();

// Now open password-protected file within this workbook set, specifying the password as the second argument.
SpreadsheetGear.IWorkbook workbook = workbookSet.Workbooks.Open(@"c:\path\to\workbook.xlsx", "MyPassword1234");