Not able to protect cell

Hi,


I have attached file, cells are protected.

Aspose component does not respect it and I am able to set the cell.

It should throw the error.


Hi,


Thanks for the template file and details.

After an initial test, I observed the issue as you mentioned. I found Aspose.Cells does not respect the protected sheet and we can directly add/update data in the protected cells via code (Aspose.Cells APIs). The output file has the updated data (as per the code segment). In Ms Excel, we cannot straight away add/update data in the cells if the worksheet the protected, we got to first un-protect the sheet (password is “test”) and then can add/update data in the cells. I am using the template file (the first worksheet is protected in it) provided by you with the following sample code.
e.g
Sample code:

Workbook workbook = new Workbook(“e:\test2\sdsd.xlsx”);
Worksheet worksheet = workbook.Worksheets[0];
Cells cells = worksheet.Cells;
Cell aCell = worksheet.Cells[“A10”];
aCell.PutValue(“My test Data”);

workbook.Save(“e:\test2\out1.xlsx”);

I have logged a ticket with an id “CELLSNET-43554” for your issue. We will look into it soon.

Once we have any update on it, we will let you know here.

Thank you.

Thanks your for your quick reply.


Also can you make sure for Protected workbook.

I am able to add new worksheet too.

See attached file which is protected with workbook (pass is “test”)

It should throw error.

Hi,

Thanks for your posting and using Aspose.Cells.

We were able to observe this issue. Aspose.Cells is letting to add a new worksheet in a protected workbook.

We have logged this issue in our database for investigation. We will look into it and fix this issue. Once, the issue is resolved or we have some other update for you, we will let you know asap.

This issue has been logged as

  • CELLSNET-43555 - Aspose.Cells is letting to add a new worksheet in a protected workbook

Here is the sample code to test this issue. I have also attache the output excel file for a reference.

C#


string filePath = @“F:\Shak-Data-RW\Downloads\ppp.xlsx”;


Workbook workbook = new Workbook(filePath);


workbook.Worksheets.Add(“MySheet”);


workbook.Save(filePath + “.out.xlsx”);

Hi,

Thanks for using Aspose.Cells.

For your both issues, we are afraid, Aspose.Cells does not support this feature.

You can check them by yourself. Please see the following sample code for your reference.

C#


Workbook workbook = new Workbook(“e:\test2\sdsd.xlsx”);

Worksheet worksheet = workbook.Worksheets[0];

Cells cells = worksheet.Cells;

Cell aCell = worksheet.Cells[“A10”];

if (!(worksheet.IsProtected && aCell.GetStyle().IsLocked))

{

aCell.PutValue(“My test Data”);

}

if (!worksheet.IsProtected)

{

workbook.Worksheets.Add(“MySheet”);

}

workbook.Save(“e:\test2\out1.xlsx”);