Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Mon Oct 10, 2016 1:07 pm

Yes, fantastic.

Ok, how can I check if a workbook has a password? i.e. if there is a password I want to open it with my password.... however if there is no password then I do not want to continue processing.

Regards,
Steve

stExceL
 
Posts: 8
Joined: Tue Mar 24, 2015 4:46 pm

Tue Oct 11, 2016 3:12 am

Dear Steve,

Thanks for your feedback.
Now there is a way catching the exception to check if a workbook has a password. Please load the workbook without password(workBook.LoadFromFile("HasPassword.xlsx")), and then it will throw an exception, if the exception content is "Workbook is protected and password wasn't specified", it means the workbook has password.
Also, we have added the new feature to directly check if a workbook has a password. Once it is done, we will inform you.
Sorry for inconvenience caused.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Wed Nov 09, 2016 7:37 am

Dear Steve,

Thanks for your waiting.
Now the new feature is done, you can directly check if a workbook has a password. Welcome to test Spire.XLS Pack Hotfix Version:7.11.13.
Sample code for your reference.
Code: Select all
Workbook workbook = new Workbook();
bool havepwd = workbook.IsPasswordProtected(inputFile);


Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Thu Dec 01, 2016 4:53 am

I have a password protected workbook in an Excel 2003 formatted .xls and I'm still getting the same error about wrong password. I know I have the right password because I can open the workbook up and unprotect it with the same password, but trying the code you mention with the OpenPassword option isn't working.

Please help!
Jason

logicspeak
 
Posts: 1
Joined: Thu Dec 01, 2016 4:21 am

Thu Dec 01, 2016 6:34 am

Dear Jason,

Thanks for your inquiry.
Did you use the latest Spire.XLS Pack Hotfix Version:7.11.13 ? If the issue still exists with the version, please provide us the file and the password for investigation.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Mon Jan 09, 2017 3:42 am

Hi,

We do an adjustment for the method, change it to static method in Spire.XLS Pack Hotfix Version:7.11.34.
Here is code for your reference.
Code: Select all
Spire.Xls.Workbook.IsPasswordProtected(inputfile);

If there is any question, welcome to get it back to us.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Return to Spire.XLS