Bug: checkbox and linkedcell issue

Hi,


I am adding checkbox to a sheet using aspose api.


int index = localSheet.CheckBoxes.Add(localcell 17,30);
Aspose.Cells.Drawing.CheckBox checkBoxOption = localSheet.CheckBoxes[index];
checkBoxOption.Placement = Aspose.Cells.Drawing.PlacementType.MoveAndSize;
checkBoxOption.Text = String.Empty;
checkBoxOption.Left = 80;
checkBoxOption.Value = true;
checkBoxOption.LinkedCell = localcellSomeOffset.Name;

I have protected the cell in which checkbox resides and able to use the check box that is not linked to a different cell in the sheet. (click/unclick)

The moment I link a cell to checkbox, i am unable to use the checkbox, irrespective of whether the linked cell is protected or not. I am forced to unprotect the cell in which check box is present. This seems like a bug. I should be able to use the checkbox, if the linked cell is unprotected. Could you please check?

Aspose.NET cells v: 8.8.2

Hi,

Thanks for your posting and using Aspose.Cells.

We have tested this issue with the following sample code using the latest version: Aspose.Cells for .NET v8.8.2.10 and found, everything is working fine.

I have attached the sample excel file used in this code and output excel file generated by it for your reference.

If you check the sample excel file, you will see, all of its cells are protected except A1:B18 and checkbok inside the output excel file is working fine as expected.

C#

Workbook wb = new Workbook(“sample.xlsx”);

Worksheet localSheet = wb.Worksheets[0];

int index = localSheet.CheckBoxes.Add(5, 5, 20, 150);
Aspose.Cells.Drawing.CheckBox checkBoxOption = localSheet.CheckBoxes[index];
checkBoxOption.Placement = Aspose.Cells.Drawing.PlacementType.MoveAndSize;
checkBoxOption.Text = String.Empty;
checkBoxOption.Left = 80;
checkBoxOption.Value = true;
checkBoxOption.Text = “My Check Box”;
checkBoxOption.LinkedCell = “A1”;

wb.Save(“output.xlsx”);

Based on your example, you have protected the sheet manually. I have used the following code to protect. Does it still work?


mySheet.Protection.AllowDeletingColumn = false;
mySheet.Protection.AllowDeletingRow = false;
mySheet.Protection.AllowEditingContent = false;
mySheet.Protection.AllowEditingObject = false;
mySheet.Protection.AllowEditingScenario = false;
mySheet.Protection.AllowFiltering = true;
mySheet.Protection.AllowFormattingCell = false;
mySheet.Protection.AllowFormattingColumn = false;
mySheet.Protection.AllowFormattingRow = false;
mySheet.Protection.AllowInsertingColumn = false;
mySheet.Protection.AllowInsertingHyperlink = false;
mySheet.Protection.AllowInsertingRow = false;
mySheet.Protection.AllowSelectingLockedCell = true;
mySheet.Protection.AllowSorting = false;
mySheet.Protection.AllowUsingPivotTable = false;
mySheet.Protect(ProtectionType.All, this.WorkSheetPassword, “”);

Hi,

Thanks for your posting and using Aspose.Cells.

I have tested your issue with the following sample code which protects the worksheet programmatically and also adds the check box and found that the checkbox is working fine. I have attached the output excel file generated by the code for your reference.

I have also attached the Visual Studio 2008 Console Application Sample Project which generates the output excel file so that you could download it and run the given sample code at your end. If you are still having this issue, then please modify this sample project and submit it to us so that we could run it and replicate your issue.

Please note, the sample project uses the latest version:
Aspose.Cells for .NET v8.8.2.10.

C#

Workbook wb = new Workbook();

Worksheet localSheet = wb.Worksheets[0];

Worksheet mySheet = localSheet;

mySheet.Protection.AllowDeletingColumn = false;
mySheet.Protection.AllowDeletingRow = false;
mySheet.Protection.AllowEditingContent = false;
mySheet.Protection.AllowEditingObject = false;
mySheet.Protection.AllowEditingScenario = false;
mySheet.Protection.AllowFiltering = true;
mySheet.Protection.AllowFormattingCell = false;
mySheet.Protection.AllowFormattingColumn = false;
mySheet.Protection.AllowFormattingRow = false;
mySheet.Protection.AllowInsertingColumn = false;
mySheet.Protection.AllowInsertingHyperlink = false;
mySheet.Protection.AllowInsertingRow = false;
mySheet.Protection.AllowSelectingLockedCell = true;
mySheet.Protection.AllowSorting = false;
mySheet.Protection.AllowUsingPivotTable = false;
mySheet.Protect(ProtectionType.All, “”, “test”);

int index = localSheet.CheckBoxes.Add(5, 5, 20, 150);
Aspose.Cells.Drawing.CheckBox checkBoxOption = localSheet.CheckBoxes[index];
checkBoxOption.Placement = Aspose.Cells.Drawing.PlacementType.MoveAndSize;
checkBoxOption.Text = String.Empty;
checkBoxOption.Left = 80;
checkBoxOption.Value = true;
checkBoxOption.Text = “My Check Box”;
checkBoxOption.LinkedCell = “A1”;

wb.Save(“output.xlsx”);

Hi,

Thanks for using Aspose.Cells.

Please also add the following lines to make cell A1 (which is a linked cell of the check box) unprotected.

//Unlock the cell A1
Cell a1 = mySheet.Cells[“A1”];
Style s = a1.GetStyle();
s.IsLocked = false;
a1.SetStyle(s);

Here is a complete code. Changes are highlighted in red color. I have also attached the output excel file generated with this modified code for your reference.

C#

Workbook wb = new Workbook();

Worksheet localSheet = wb.Worksheets[0];

Worksheet mySheet = localSheet;

//Unlock the cell A1
Cell a1 = mySheet.Cells[“A1”];
Style s = a1.GetStyle();
s.IsLocked = false;
a1.SetStyle(s);

mySheet.Protection.AllowDeletingColumn = false;
mySheet.Protection.AllowDeletingRow = false;
mySheet.Protection.AllowEditingContent = false;
mySheet.Protection.AllowEditingObject = false;
mySheet.Protection.AllowEditingScenario = false;
mySheet.Protection.AllowFiltering = true;
mySheet.Protection.AllowFormattingCell = false;
mySheet.Protection.AllowFormattingColumn = false;
mySheet.Protection.AllowFormattingRow = false;
mySheet.Protection.AllowInsertingColumn = false;
mySheet.Protection.AllowInsertingHyperlink = false;
mySheet.Protection.AllowInsertingRow = false;
mySheet.Protection.AllowSelectingLockedCell = true;
mySheet.Protection.AllowSorting = false;
mySheet.Protection.AllowUsingPivotTable = false;
mySheet.Protect(ProtectionType.All, “”, “test”);

int index = localSheet.CheckBoxes.Add(5, 5, 20, 150);
Aspose.Cells.Drawing.CheckBox checkBoxOption = localSheet.CheckBoxes[index];
checkBoxOption.Placement = Aspose.Cells.Drawing.PlacementType.MoveAndSize;
checkBoxOption.Text = String.Empty;
checkBoxOption.Left = 80;
checkBoxOption.Value = true;
checkBoxOption.Text = “My Check Box”;
checkBoxOption.LinkedCell = “A1”;

wb.Save(“output.xlsx”);

Thanks for your quick turn around. Sorted the issue.

Hi,


Good to know that your issue is sorted out now. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.

Thank you.

checkbox.SetLockedProperty(Aspose.Cells.Drawing.ShapeLockType.Selection,false);

this is the simple way to change the locktype for any component :slight_smile:

Hi,

Thanks for your posting and using Aspose.Cells.

Please share your sample code for testing. Hopefully, it will help other users dealing with such issue. Have a good day.