Removing password protection from "Password protected" excel file

Hi,

I have a password protected excel file. My requirement is - To remove its password protection (basically unprotect) it using aspose.cells.

I tried following samples of code but none of them worked:-

1)
Workbook wBook = new Workbook();
wBook.Open(filePath + fileName, FileFormatType.Excel2003, _attachmentPassword);
wBook.Unprotect(_attachmentPassword);
wBook.Save(filePath + fileName, FileFormatType.Excel2003);


2)

Workbook wBook = new Workbook();
wBook.Open(filePath + fileName, FileFormatType.Excel2003, _attachmentPassword);
wBook.Unprotect(_attachmentPassword);

Kindly give me exact code which can help me in achieving my goal.

I am using Aspose.Cells for .NET ver 4.6.0.2

Regards,
Mayank

Hi,

If you want to remove the password with encryption settings from an excel file, please use Workbook.Decrypt() method. You can change your code a bit.

e.g

Workbook wBook = new Workbook();
wBook.Open(filePath + fileName, FileFormatType.Excel2003, _attachmentPassword);
wBook.Decrypt(_attachmentPassword);
wBook.Save(filePath + fileName, FileFormatType.Excel2003);

Thank you.