I would like to delete all checkboxes from worksheet one column, when I delete that columns data.
how should I do?
Thanks for your query.
Well, you may easily do that by ShapeCollection.RemoveAt() method. You may check the upper left column and/or lower right column values (by using relevant attributes) for the checkbox shape for your specified column. See the following sample code with the attached file for your reference, the code removes the check boxes in the C column:
e.g
Sample code:
string filePath = "e:\\test2\\Bk_checkbox12.xlsx";
Workbook workbook = new Workbook(filePath);
ShapeCollection shapes = workbook.Worksheets[0].Shapes;
for (int i = shapes.Count - 1; i >= 0; i--)
{
if (shapes[i] is Aspose.Cells.Drawing.CheckBox)
{
//If the checkbox is contained (starting drawn) in the C column.
if (shapes[i].UpperLeftColumn == 2)
{
shapes.RemoveAt(i);
}
}
}
workbook.Save(filePath + ".out1.xlsx");
Hope, this helps a bit.
files1.zip (6.7 KB)
Thanks, these codes can work well.
Good to know that the suggested code sorts out your issue 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.