Set checkbox position to the center of the cell

i am using you code example for creating a checkbox

int checkboxInd = sheetRef.CheckBoxes.Add(rowIndex, colIndex, rowHeight, colWidht);

CheckBox checkBox = sheetRef.CheckBoxes[checkboxInd];

checkBox.Value = value;

now i would like to set the checkbox in the senter of the cell

thank

Hi,

Well, MS Excel does not provide any property/attribute to set the CheckBox in the center to the cell.

I think you may add the CheckBox and try to specify the Left position of the it to place it in the center of the cell.

E.g..,

//Instantiate a new Workbook.
Workbook excelbook = new Workbook();
excelbook.Worksheets[0].Cells.SetColumnWidth(5, 15);
//Add a checkbox to the first worksheet in the workbook.
int index = excelbook.Worksheets[0].CheckBoxes.Add(5, 5, excelbook.Worksheets[0].Cells.GetRowHeightPixel(5), excelbook.Worksheets[0].Cells.GetColumnWidthPixel(5));
//Get the checkbox object.
Aspose.Cells.CheckBox checkbox = excelbook.Worksheets[0].CheckBoxes[index];
//Set its text string.
checkbox.Text = "Click it!";
//Put a value into B1 cell.
excelbook.Worksheets[0].Cells["B1"].PutValue("LnkCell");
//Set B1 cell as a linked cell for the checkbox.
checkbox.LinkedCell = "B1";
//Check the checkbox by default.
checkbox.Value = true;
checkbox.Placement = PlacementType.MoveAndSize;
checkbox.Left = 20;
//Save the excel file.
excelbook.Save("f:\\test\\checkboxes_test.xls");
Thank you.