Check .xls file is password protected

Hi There

Can we check excel file is either password protected or not.

if yes then , Can you give me little example for that.

Thanks in advance.

Hi,

Thank you for considering Aspose.

You can us Workbook.IsProtected property to check whether excel workbook is protected or not.

Aspose.Cells.Workbook workbook = new Aspose.Cells.Workbook();

workbook.Open("c:\\templatefile.xls");

if (workbook.IsProtected)

{

//here goes your code for protected file

}

Thank You & Best Regards,

but i am using:

workbook.Open("c:\\templatefile.xls");

if (workbook.IsProtected)

{

//here goes your code for protected file

}

but it return always false , it does not matter either .xls file is password protected or not

I am using this file which I m attaching,

password =“007”

Hi,

Thank you for considering Aspose.

Well, Aspose.Cells does not supported to check whether the file is open/modify protected( as your template file).Workbook.IsProtected is used to check whether workbook is protected using windows/structure lock options (Tool--> Protection --> Protect Workbook).

Thank You & Best Regards,

I now use this trick:

catch (CellsException e)
{
if (new Regex(@“Please\sprovide”).IsMatch(e.Message)) Response.Write(" Password protected file.");
}