[]
Use this interface to access, add, and enumerate worksheet form controls such as buttons, check boxes, labels, drop-down lists, and other supported control types. Controls can be retrieved by zero-based index or by name, and the collection can be iterated because it extends Iterable of IControl.
IControlCollection controls = worksheet.getControls();
IButton button = controls.addButton(20, 20, 100, 24);
button.setName("submitButton");
IControl control = controls.get("submitButton");
addButton(double left,
double top,
double width,
double height) IButton.addCheckBox(double left,
double top,
double width,
double height) ICheckBox.addDropDown(double left,
double top,
double width,
double height) IDropDown.addGroupBox(double left,
double top,
double width,
double height) IGroupBox.addLabel(double left,
double top,
double width,
double height) ILabel.addListBox(double left,
double top,
double width,
double height) IListBox.addOptionButton(double left,
double top,
double width,
double height) IOptionButton.addScrollBar(double left,
double top,
double width,
double height) IScrollBar.addSpinner(double left,
double top,
double width,
double height) ISpinner.voidclear()IControlCollection.get(int index) intgetCount()intforEach, iterator, spliteratorReturns the number of form controls currently contained in this collection.
IButton button = worksheet.getControls().addButton(20, 20, 100, 24);
IDropDown dropDown = worksheet.getControls().addDropDown(20, 60, 120, 24);
int count = worksheet.getControls().getCount();
Use this method to retrieve a control from the collection by its zero-based position.
IButton button = worksheet.getControls().addButton(20, 20, 100, 24);
button.setText("Submit");
IControl control = worksheet.getControls().get(0);
control.setLeft(40);
index - The zero-based index of the control to retrieve.IndexOutOfBoundsException - if index is less than 0 or greater than or equal to the number of controls in the collection.Returns the control whose name matches the specified name. Use IControl.setName(String) to assign a custom name before retrieving a control from the collection.
IButton button = worksheet.getControls().addButton(20, 20, 100, 24);
button.setName("submitButton");
IControl control = worksheet.getControls().get("submitButton");
name - The name of the control to retrieve.null if no control with that name exists.IButton. Creates a button control at the specified position and size in the worksheet's control collection.
IButton button = worksheet.getControls().addButton(20, 20, 100, 24);
button.setText("Submit");
left - The left margin of the button.top - The top margin of the button.width - The width of the button.height - The height of the button.IButton.IDropDown. Creates a drop-down form control at the specified position with the specified size on the worksheet. Use the returned control to add items, bind a linked cell, or set the selected item.
IDropDown dropDown = worksheet.getControls().addDropDown(20, 20, 120, 24);
dropDown.getItems().add(new DropDownItem("North"));
dropDown.getItems().add(new DropDownItem("South"));
dropDown.setSelectedIndex(0);
left - The left position of the control.top - The top position of the control.width - The width of the control.height - The height of the control.IDropDown.ICheckBox. Creates a check box form control in the worksheet at the specified position and size, and returns the created control for further configuration.
ICheckBox checkBox = worksheet.getControls().addCheckBox(54, 13.2, 64.2, 18);
checkBox.setText("Accept terms");
checkBox.setLinkedCell(worksheet.getRange("A1"));
left - The horizontal position of the check box.top - The vertical position of the check box.width - The width of the check box.height - The height of the check box.ICheckBox.ISpinner. Use this method to place a spinner form control on the worksheet and then configure its linked cell and range settings through the returned ISpinner.
ISpinner spinner = worksheet.getControls().addSpinner(20, 20, 18, 72);
spinner.setLinkedCell(worksheet.getRange("A1"));
spinner.setMin(0);
spinner.setMax(10);
spinner.setSmallChange(1);
left - The horizontal position of the spinner.top - The vertical position of the spinner.width - The width of the spinner.height - The height of the spinner.ISpinner.IListBox. Use the returned list box to add selectable items or link the control to a worksheet cell.
IListBox listBox = worksheet.getControls().addListBox(24.1, 273.1, 170, 78.69);
listBox.getItems().add(new ListBoxItem("North"));
listBox.getItems().add(new ListBoxItem("South"));
listBox.setSelectedIndex(0);
left - The left position of the list box.top - The top position of the list box.width - The width of the list box.height - The height of the list box.IListBox.IOptionButton. Creates an option button control at the specified location and size and returns the created control. Option buttons placed inside the bounds of the same IGroupBox participate in the same selection group; otherwise, they belong to the worksheet's default group.
IOptionButton optionButton = worksheet.getControls().addOptionButton(39.45, 67.1, 98, 15.6);
optionButton.setText("North");
optionButton.setLinkedCell(worksheet.getRange("A1"));
left - The left position of the option button.top - The top position of the option button.width - The width of the option button.height - The height of the option button.IOptionButton.IGroupBox. Creates a group box control at the specified location and size on the worksheet. A group box can be used to organize related controls, such as IOptionButton controls.
IGroupBox groupBox = worksheet.getControls().addGroupBox(29.75, 48.2, 136.5, 113.99);
groupBox.setText("Group 1");
left - The left coordinate of the group box.top - The top coordinate of the group box.width - The width of the group box.height - The height of the group box.IGroupBox.ILabel. Use this method to place a label control on the worksheet by specifying its position and size.
ILabel label = worksheet.getControls().addLabel(20, 20, 100, 24);
label.setText("Resolution");
left - The distance between the left edge of the worksheet and the label.top - The distance between the top edge of the worksheet and the label.width - The width of the label.height - The height of the label.IScrollBar. Creates a scroll bar control on the worksheet at the specified position and size, and returns the newly added control.
IScrollBar scrollBar = worksheet.getControls().addScrollBar(20, 20, 120, 18);
scrollBar.setMin(0);
scrollBar.setMax(10);
scrollBar.setLinkedCell(worksheet.getRange("A1"));
left - The distance from the left edge of the worksheet to the control.top - The distance from the top edge of the worksheet to the control.width - The width of the control.height - The height of the control.IScrollBar.Returns the zero-based position of the specified control in this collection.
IControlCollection controls = worksheet.getControls();
IButton button = controls.addButton(20, 20, 100, 24);
int index = controls.indexOf(button);
control - The control to find. If null, this method returns -1.-1.IControlCollection. After this method is called, the collection is empty.
IControlCollection controls = worksheet.getControls();
controls.addButton(20, 20, 100, 24);
controls.addCheckBox(54, 13.2, 64.2, 18);
controls.clear();