RadioButton setting value of Linkedcell does not work

Hello Team,

I am using code sample below from the aspose documentation.

// Add a radio button to the first sheet.
     		com.aspose.cells.RadioButton radio1 = (com.aspose.cells.RadioButton) filledWorksheet.getShapes()
     				.addShape(MsoDrawingType.RADIO_BUTTON, 3, 0, 12, 0, 20, 100);

     		// Set its text string.
     		radio1.setText("20-29");

     		// Make the radio button 3-D.
     		radio1.setShadow(true);

     		// Set the foreground color of the radio button.
     		radio1.getFill().setOneColorGradient(Color.getGreen(), 1, GradientStyleType.HORIZONTAL, 1);

     		// set the line style of the radio button.
     		radio1.getLine().setDashStyle(MsoLineStyle.THICK_THIN);

     		// Set the weight of the radio button.
     		radio1.getLine().setWeight(4);

     		// Set the line color of the radio button.
     		radio1.getLine().setOneColorGradient(Color.getBlue(), 1, GradientStyleType.HORIZONTAL, 1);

     		// Set the dash style of the radio button.
     		radio1.getLine().setDashStyle(MsoLineDashStyle.SOLID);
     		
     		Cell linkedCell = filledWorksheet.getCells().get("K3");
  			linkedCell.setValue(1);
  			
  			// Set A1 cell as a linked cell for the radio button.
     		radio1.setLinkedCell("K3");
     		try {
     			
				radio1.updateSelectedValue();

				
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}

But the Value of linked cell K3 is not set to 1. Rather it is set as 0 and the radio button is also not set.

Can you please let me know what I am doing wrong here?

Regards
Mukul

@mukulpurohit,

I tested your scenario/case using the following sample code and it works fine and as expected. The radio button is selected and K3 value is set 1.
e.g.
Sample code:

       Workbook workbook =  new Workbook();

       Worksheet filledWorksheet = workbook.getWorksheets().get(0);

       // Add a radio button to the first sheet.
       com.aspose.cells.RadioButton radio1 = (com.aspose.cells.RadioButton) filledWorksheet.getShapes()
               .addShape(MsoDrawingType.RADIO_BUTTON, 3, 0, 12, 0, 20, 100);

       // Set its text string.
       radio1.setText("20-29");

       // Make the radio button 3-D.
       radio1.setShadow(true);

       // Set the foreground color of the radio button.
       radio1.getFill().setOneColorGradient(com.aspose.cells.Color.getGreen(), 1, GradientStyleType.HORIZONTAL, 1);

       // set the line style of the radio button.
       radio1.getLine().setDashStyle(MsoLineStyle.THICK_THIN);

       // Set the weight of the radio button.
       radio1.getLine().setWeight(4);

       // Set the line color of the radio button.
       radio1.getLine().setOneColorGradient(com.aspose.cells.Color.getBlue(), 1, GradientStyleType.HORIZONTAL, 1);

       // Set the dash style of the radio button.
       radio1.getLine().setDashStyle(MsoLineDashStyle.SOLID);

       Cell linkedCell = filledWorksheet.getCells().get("K3");
       linkedCell.setValue(1);

       // Set A1 cell as a linked cell for the radio button.
       radio1.setLinkedCell("K3");
       radio1.updateSelectedValue();

       workbook.save("f:\\files\\out1.xlsx");

Please find attached the output XLSX file for your reference. Please note, when this radio button is unchecked, K3 value would be “0” which is right. But when it is checked, the K3 (linked cell) value would be “1” and rightly so.
out1.zip (6.9 KB)

Please try latest version of the API if you are not already using it. If you still find the issue, kindly zip and attach your sample files and paste complete (runnable) sample code (as above). We will check your issue soon.

Thank you @amjad.sahi for the update.

I was creating two option buttons and grouping them.
When we group the option buttons following code was not setting the value of the linked cell

   Cell linkedCell = filledWorksheet.getCells().get("K3");
   linkedCell.setValue(1);

   // Set A1 cell as a linked cell for the radio button.
   radio1.setLinkedCell("K3");
   radio1.updateSelectedValue()

But when I ungrouped the option buttons, the code above worked fine.

Thank you for your prompt response and update once again.
Thanks,
Mukul

@mukulpurohit,

Good to know that you have sorted it out. Please note, for a group, only one radio button could not selected. If you have further queries or issue, please write us back.