GemBox.Spreadsheet is a .NET component that enables you to read, write, edit, convert, and print spreadsheet files from your .NET applications using one simple API.

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.

Screenshot
XLSX Encryption Screenshot

See the full code below, use Run Example to execute.

Upload your file(Drag files here)

Download a sample file

using GemBox.Spreadsheet;
using System.IO;

class Sample
{
    [STAThread]
    static void Main(string[] args)
    {
        // If using Professional version, put your serial key below.
        SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY");

        string inputPassword = "inpass";
        string outputPassword = "outpass";

        var ef = ExcelFile.Load("XlsxEncryption.xlsx", new XlsxLoadOptions() { Password = inputPassword });

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

Module Samples

    Sub Main()

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

        Dim inputPassword As String = "inpass"
        Dim outputPassword As String = "outpass"

        Dim ef = ExcelFile.Load("XlsxEncryption.xlsx", New XlsxLoadOptions With {.Password = inputPassword})
        ef.Save("XLSX Encryption.xlsx", New XlsxSaveOptions With {.Password = outputPassword})

    End Sub

End Module

Check next sample.