Cannot Insert / Delete when sheet is protected


#1

When the sheet is protected the insert / delete options are not working. I have a designer template with sheet protected and a range unproted for the user to enter data. It generates the workbook with sheet protected but the insert and delete rows menu options are disables even though i have set the options on.


#2

Could you please post your designer template here? Which version of Aspose.Cells are you using?


#3

I am using the designer and after merge i am copying teh work sheeet to another work book and streaming it to the browser. Let me know if I am missing something. I am using the latest aspose cells dll.


#4

I use the following code to test your file and don't find the problem.

Workbook workbook = new Workbook();
workbook.Open("d:\\test\\template.xls");

Workbook workbook2 = new Workbook();
workbook2.Worksheets[0].Copy(workbook.Worksheets[0]);
workbook2.Save("d:\\test\\abc.xls");

I attach the output file here.

Could you please post your output file here? If possible, could you also post your sample project here? Thank you.


#5

I see the problem in teh abc.xls you have attached.

In the template the sheet is protected with Insert row, Insert columns, delete row and delete column options. I am assuming the the user should be able to add rows in the range specified. But the insert and delete options are diabled. In the resulting output say in teh abc.xls if i un protect and protect the sheet again with insert row and insert column options. I meny is enabled and i could insert rows and columns.


#6

Now I understand what's the problem.

Allowing to insert/delete rows while the worksheet is protected is a feature after ExcelXP, so my sample test code should be changed to:

Workbook workbook = new Workbook();
workbook.Open("d:\\test\\template.xls");

Workbook workbook2 = new Workbook();
workbook2.Worksheets[0].Copy(workbook.Worksheets[0]);
workbook2.Save("d:\\test\\abc.xls", FileFormatType.ExcelXP);

When you save the file, please specify the file format as ExcelXP or Excel2003.


#7

Thanks a lot. That helped me a lot. I appreciate your tech support.