Combo box question

Hello: Im using Aspose.CELLS 4.4.3. I need to add a Combo Box and have it populated from data I retrieve from a web service call. I tried using this line to add the COMBO Box to the spreadsheet but I dont see it in the spreadsheet when i save it. Any idea what IM doing wrong?


Aspose.Cells.ComboBox comboBox = sheet.Shapes.AddComboBox(9, 0, 9, 0, 22, 100);

Thanks

Doug


Hi Doug,


Thank you for using Aspose products, and welcome to Aspose.Cells support forum.

I have used the following piece of code to create a ComboBox and set its data source while using the latest version of Aspose.Cells for .NET (Latest Version) . Attached is the resultant spreadsheet containing the ComboBox.

C#

DataTable table = new DataTable();
table.Columns.Add(“Field”, typeof(string));
table.Rows.Add(“Finance”);
table.Rows.Add(“Auto”);
table.Rows.Add(“Games”);
table.Rows.Add(“Groups”);
table.Rows.Add(“HotJobs”);
table.Rows.Add(“Maps”);
table.Rows.Add(“Mobile”);
table.Rows.Add(“Movies”);
table.Rows.Add(“Music”);
table.Rows.Add(“Shopping”);
table.Rows.Add(“Sports”);
table.Rows.Add(“Tech”);

Workbook book = new Workbook();
Worksheet sheet = book.Worksheets[0];
//Import Data to worksheet, this data will serve as source to ComoboBox
sheet.Cells.ImportDataTable(table, false, 0, 0, true);
//Add a new Worksheet to the Workbook object
sheet = book.Worksheets.Add(“Sheet2”);
//Add a ComboBox at any specified loaction while setting its size
ComboBox comboBox = sheet.Shapes.AddComboBox(9, 0, 9, 0, 22, 100);
//Set data source/data range for the ComboBox
comboBox.InputRange = “Sheet1!A2:A12”;
//Set SelectedIndex
comboBox.SelectedIndex = 0;
//[Optional]Set Worksheet having the data source to invisible
book.Worksheets[0].IsVisible = false;
//Save results
book.Save(myDir + “CustomComboBox.xlsx”);


Please give the above code snippet a try with your current version of Aspose.Cells for .NET API. In case the problem persists, we would strongly recommend you to upgrade the API to v8.0.0 (link shared above) because the presented scenario could be a bug in v4.4.3.

Please feel free to write back in case you have further questions for us.