We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Trouble with "allow users to edit ranges"


I saw the post : I've got the same trouble when I save my document. Every cells that I allow users to edit ranges simply disappear. Since this post was written in 2005, maybe there is a fix in the new version ? I'm currently using Aspose.Cells for .NET v4.8.2.0.

I'm working in Societe Generale and we need this functionality to purchase the licence.

What I'm doing :

1. Creation of a template ProtectSheetTemplate.xlsm in which I only allow users to edit ranges (Columns D and E)

2. In my code I open the template and apply protection (I'm not using the Protect method)

This is my code:

Workbook workbook = new Workbook();

string templateFileName = Environment.CurrentDirectory + "\\ProtectSheetTemplate.xlsm";


Worksheet worksheet = workbook.Worksheets[0];

worksheet.Protection.Password = "test";

worksheet.Protection.IsFilteringAllowed = true;

worksheet.Protection.IsSelectingLockedCellsAllowed = true;

worksheet.Protection.IsSelectingUnlockedCellsAllowed = true;

worksheet.Protection.IsDeletingColumnsAllowed = false;

worksheet.Protection.IsDeletingRowsAllowed = false;

worksheet.Protection.IsEditingContentsAllowed = false;

worksheet.Protection.IsEditingObjectsAllowed = false;

worksheet.Protection.IsEditingScenariosAllowed = false;

worksheet.Protection.IsFormattingCellsAllowed = false;

worksheet.Protection.IsFormattingColumnsAllowed = false;

worksheet.Protection.IsFormattingRowsAllowed = false;

worksheet.Protection.IsInsertingColumnsAllowed = false;

worksheet.Protection.IsInsertingHyperlinksAllowed = false;

worksheet.Protection.IsInsertingRowsAllowed = false;

worksheet.Protection.IsSortingAllowed = false;

worksheet.Protection.IsUsingPivotTablesAllowed = false;

workbook.Save(Environment.CurrentDirectory + "\\ProtectSheet.xls", FileFormatType.ExcelXP);

Even if I only open the template and save the file with another name, all the edit ranges I previously allowed have simply disappeared in the output document.

My template is in attach file:

Thanks for your response.

This message was posted using Page2Forum (attachment) from
Advanced Protection Settings since Excel XP - Aspose.Cells for .NET


Thanks for providing us the template file with sample code.

After an initial test, I found the issue as you have described.

I have logged your issue into our issue tracking system with an issue id: CELLSNET-14969. We will figure it out soon.

Thank you.


We have supported the "allow users to edit ranges" feature for your need. Please try the attached version.

Kindly consult the following code, it will work fine with your template file:

Workbook book = new Workbook();
Worksheet sheet = book.Worksheets[0];
AllowEditRanges allowRanges = sheet.AllowEditRanges;
AllowEditRange range;
if (allowRanges.Count > 0)
range = allowRanges[0];
Console.Write(" " + range.CellArea.StartRow + "," + range.CellArea.StartColumn + ","
+ range.CellArea.EndRow + "," + range.CellArea.EndColumn);

int idx = allowRanges.Add("r2", 1, 1, 3, 3);
range = allowRanges[idx];
range.Password = "1";


Thank you