Enum EncryptionType

EncryptionType enumeration

Encryption Type. Only used by excel2003. We will encrypt 2007/2010 workbook using SHA AES the same as Excel does, and this EncryptionType will be ignored.

public enum EncryptionType

Values

NameValueDescription
XOR0XOR encryption algorithm.
Compatible1Office 97/2000 compatible.
EnhancedCryptographicProviderV12Enhanced encryption.
StrongCryptographicProvider3Strong encryption algorithm.

Examples

[C#]

namespace Demos
{
    using Aspose.Cells;
    using System;

    public class EncryptionTypeDemo
    {
        public static void EncryptionTypeExample()
        {
            // Create a new workbook
            Workbook workbook = new Workbook();

            // Set encryption options for the workbook
            EncryptionType encryptionType = EncryptionType.EnhancedCryptographicProviderV1;
            int keyLength = 128; // Key length can be 40, 128, or 256 bits

            // Apply encryption settings
            workbook.SetEncryptionOptions(encryptionType, keyLength);

            // Protect the workbook with a password
            string password = "securePassword";
            workbook.Protect(ProtectionType.All, password);

            // Save the workbook
            workbook.Save("EncryptedWorkbook.xlsx");
            workbook.Save("EncryptedWorkbook.pdf");
        }
    }
}

See Also