Excel Encryption for XLSX in C# and VB.NET

XLSX encryption enables you to securely protect the content of your Excel workbook (XLSX) from unwanted viewers.

Following example shows how to load encrypted XLSX file and how to save workbook as encrypted XLSX file in C# and VB.NET.

Input and output password should be specified in the appropriate text box. If password is empty, file won't be decrypted / encrypted.

XLSX file decrypted and encrypted with GemBox.Spreadsheet
Screenshot of XLSX file decrypted and encrypted with GemBox.Spreadsheet
Upload your file (Drag file here)
using GemBox.Spreadsheet;

class Program
{
    static void Main()
    {
        // If using Professional version, put your serial key below.
        SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY");

        var inputPassword = "%InputPassword%";
        var outputPassword = "%OutputPassword%";

        var workbook = ExcelFile.Load("%InputFileName%", new XlsxLoadOptions() { Password = inputPassword });

        workbook.Save("XLSX Encryption.xlsx", new XlsxSaveOptions() { Password = outputPassword });
    }
}
Imports GemBox.Spreadsheet

Module Program

    Sub Main()

        ' If using Professional version, put your serial key below.
        SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY")

        Dim inputPassword = "%InputPassword%"
        Dim outputPassword = "%OutputPassword%"

        Dim workbook = ExcelFile.Load("%InputFileName%", New XlsxLoadOptions With {.Password = inputPassword})

        workbook.Save("XLSX Encryption.xlsx", New XlsxSaveOptions With {.Password = outputPassword})
    End Sub
End Module

Want more?

Next example GitHub

Check the next example or select an example from the menu. You can also download our examples from the GitHub.


Like it?

Download Buy

If you want to try the GemBox.Spreadsheet yourself, you can download the free version. It delivers the same performance and set of features as the professional version, but with some operations limited. To remove the limitation, you need to purchase a license.