// Create a new workbook Workbook workbook = new Workbook(); Workbook.setValueJsonSerializer(new CustomObjectJsonSerializer()); IWorksheet worksheet = workbook.getWorksheets().get(0); RadioButtonListCellType cellType = new RadioButtonListCellType(); cellType.setDirection(CellTypeDirection.Horizontal); cellType.setTextAlign(CellTypeTextAlign.Right); cellType.setIsFlowLayout(false); cellType.setMaxColumnCount(2); cellType.setMaxRowCount(1); cellType.setHorizontalSpacing(20); cellType.setVerticalSpacing(5); cellType.getItems().add(new SelectFieldItem("player1", new People(5, "Tom"))); cellType.getItems().add(new SelectFieldItem("player2", new People(5, "Jerry"))); cellType.getItems().add(new SelectFieldItem("player3", new People(6, "Mario"))); cellType.getItems().add(new SelectFieldItem("player4", new People(4, "Luigi"))); worksheet.getRange("A1").setRowHeight(40); worksheet.getRange("A1").setColumnWidth(25); worksheet.getRange("A1").setCellType(cellType); worksheet.getRange("A1").setValue(new People(6, "Mario")); //public class CustomObjectJsonSerializer implements IJsonSerializer { // Gson gson = new Gson(); // public final Object deserialize(String json) { // return this.json.fromJson(json, JsonElement.class); // } // // public final String serialize(Object value) { // return this.json.toJson(value); // } //} //public class People { // private int age; // private String name; // // public int getAge() { // return age; // } // // public void setAge(int age) { // this.age = age; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public People(int age, String name){ // this.age = age; // this.name = name; // } // // @Override // public boolean equals(Object obj){ // return obj instanceof com.grapecity.documents.excel.examples.features.spreadjsfeatures.celltype.People && age == ((com.grapecity.documents.excel.examples.features.spreadjsfeatures.celltype.People)obj).getAge() && name.equals(((com.grapecity.documents.excel.examples.features.spreadjsfeatures.celltype.People)obj).getName()); // } // // @Override // public int hashCode() { // int hashCode = 17; // // hashCode = 31 * hashCode + this.age; // hashCode = 31 * hashCode + (this.name == null ? 0 : this.name.hashCode()); // // return hashCode; // } //} // Save to a pdf file workbook.save("AddRadioButtonCellTypeCustomObject.pdf");