// Create a new workbook Workbook workbook = new Workbook(); IWorksheet ws = workbook.getWorksheets().get("Sheet1"); ws.getRange("A:A").setColumnWidthInPixel(28d); // No data binding ws.getRange("B2").setValue("List boxes support unbound mode. You can add items with code."); IListBox listBox1 = ws.getControls().addListBox(23.6, 32.8, 170, 80.9); listBox1.getItems().add(new ListBoxItem("Unbound Item 1")); listBox1.getItems().add(new ListBoxItem("Unbound Item 2")); listBox1.getItems().add(new ListBoxItem("Unbound Item 3")); listBox1.setSelectedIndex(0); // Items source binding ws.getRange("B10").setValue("You can also use data binding to set the item source and bind selected index."); ws.getRange("F11:F14").setValue(new Object[][] { { "Items"}, { "Item 1"}, { "Item 2"}, { "Item 3"} }); ws.getRange("G11:G12").setValue(new Object[][] { { "Value"}, { 1d} }); IListBox listBox2 = ws.getControls().addListBox(23.7, 153.7, 170, 80.30); listBox2.setItemsSourceRange(ws.getRange("F12:F14")); listBox2.setLinkedCell(ws.getRange("G12")); listBox2.setSelectedIndex(0); // Multi-select ws.getRange("B18").setValue("You can select multiple items if you change the selection mode."); IListBox listBox3 = ws.getControls().addListBox(24.1, 273.1, 170, 78.69); listBox3.getItems().add(new ListBoxItem("Multi-select Item 1")); listBox3.getItems().add(new ListBoxItem("Multi-select Item 2")); listBox3.getItems().add(new ListBoxItem("Multi-select Item 3")); listBox3.setSelectionMode(SelectionMode.Extended); listBox3.getSelectedItems().add(listBox3.getItems().get(0)); listBox3.getSelectedItems().add(listBox3.getItems().get(2)); // Save to an excel file workbook.save("ListBoxesBasicUsage.xlsx");