Protected work book prompts for password when opened first time

Hi,

I've protected my workbook and worksheet using following functions.

private void ProtectWorkbook(String password, Workbook exlSheet, Template template)

{

if (template.IsProtected) {

exlSheet.Protect(ProtectionType.Structure, password);

}

}

private void AddProtection(Worksheet localSheet, TWorksheet sheet)

{

localSheet.Protection.IsDeletingColumnsAllowed = false;

localSheet.Protection.IsDeletingRowsAllowed = false;

localSheet.Protection.IsEditingContentsAllowed = true;

localSheet.Protection.IsEditingObjectsAllowed = false;

localSheet.Protection.IsEditingScenariosAllowed = false;

localSheet.Protection.IsFilteringAllowed = false;

localSheet.Protection.IsFormattingCellsAllowed = false;

localSheet.Protection.IsFormattingColumnsAllowed = false;

localSheet.Protection.IsFormattingRowsAllowed = false;

localSheet.Protection.IsInsertingColumnsAllowed = false;

localSheet.Protection.IsInsertingHyperlinksAllowed = false;

localSheet.Protection.IsInsertingRowsAllowed = false;

localSheet.Protection.IsSelectingLockedCellsAllowed = true;

localSheet.Protection.IsSortingAllowed = false;

localSheet.Protection.IsUsingPivotTablesAllowed = false;

localSheet.Protect(ProtectionType.All, this.WorkSheetPassword, null);

}

Problem is, when I open is for the first time; it shows a password prompt. How to supress that?

Regards, Vinay

User above code for the following protection types,

1. There are some columns on the worksheet which are not protected and some of them are. Have used Style.IsLocked property.

2. User should not be able to delete/add/update new cells, columns, change formatting etc however should be able to enter data in the sheet.

3. Anything except data entry should require password.

So, to achieve that; is the method adopted above correct? If, not; how do I get rid of the password prompt while opening the workbook?

Hi,

Well, if you are prompted a password when opening the workbook/excel file, the workbook surely has been encrypted or password protected. Please make sure that you do not encrypt/protect the workbook (e.g using Workbook.Password or Workbook.Settings.Password or Workbook.Protect() etc.) in your code.

We recommend you to see the following documents for protecting worksheets:
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/protecting-worksheets.html
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/advanced-protection-settings-since-excel-xp.html

Could you give us your input(if you have) + output files using your code you have mentioned.

Also, kindly protect your sheet with your desired formatting in MS Excel manually, save the file and post the saved file here, we want to check/compare which protection features you specify for your requirement.

Thank you.