We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Get the selected value in the combobox linked cell not the selected index

Hi ,

I am using the following code for create a combobox in the excel, but I am getting the selected Index in the cell that is linked with the combobox.

I want the selected value to appear in the cell that is linked with the combobox.

Workbook workbook = new Workbook();
//Get the first worksheet.
Worksheet sheet = workbook.Worksheets[0];
//Adds a new combo box.
ComboBox comboBox = sheet.Shapes.AddComboBox(2, 0, 2, 0, 50, 50);
//Sets the linked cell;
comboBox.LinkedCell = "A1";
//Sets the input range.
comboBox.InputRange = "A2:A7";
//Saves the file.
workbook.Save(@"F:\FileTemp\dest.xls");

Please suggest the code for the same .

Regards

Tushar


This message was posted using Page2Forum from ComboBox Members - Aspose.Cells for .NET

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Well, Linked Cell returns the index of the selected value in the combobox. This feature is same as MS Excel. You may create a combobox manually in MS Excel and specify the linked cell as A1; the combobox’s selected index will be shown in the linked cell. If you know any work around or feature provided in MS Excel to show the selected value in linked cell, please share with us and we will check it to implement it in Aspose.Cells.

Thank You & Best Regards,


Hi,

Actually I am looking for the feature similar to Excel- drop down list ( used for data validation )

Please refer the following links for the same :

http://office.tizag.com/excelTutorial/exceldropdownlist.php
http://spreadsheets.about.com/od/datamanagementinexcel/qt/20071113_drpdwn.htm

Please suggest how can we implement the same in Aspose.


Regards
Tushar

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Please see the following sample code regarding dropdown list validation type.

// Create a workbook object.

Workbook workbook = new Workbook();

// Get the first worksheet.

Worksheet worksheet1 = workbook.Worksheets[0];

// Create a range in the worksheet.

Range range = worksheet1.Cells.CreateRange("E1", "E4");

// Name the range.

range.Name = "MyRange";

// Fill different cells with data in the range.

range[0, 0].PutValue("Blue");

range[1, 0].PutValue("Red");

range[2, 0].PutValue("Green");

range[3, 0].PutValue("Yellow");

// Get the validations collection.

Validations validations = worksheet1.Validations;

// Create a new validation to the validations list.

Validation validation = validations[validations.Add()];

// Set the validation type.

validation.Type = Aspose.Cells.ValidationType.List;

// Set the operator.

validation.Operator = OperatorType.None;

// Set the in cell drop down.

validation.InCellDropDown = true;

// Set the formula1.

validation.Formula1 = "=MyRange";

// Enable it to show error.

validation.ShowError = true;

// Set the alert type severity level.

validation.AlertStyle = ValidationAlertType.Stop;

// Set the error title.

validation.ErrorTitle = "Error";

// Set the error message.

validation.ErrorMessage = "Please select a color from the list";

// Specify the validation area.

CellArea area;

area.StartRow = 0;

area.EndRow = 4;

area.StartColumn = 0;

area.EndColumn = 0;

// Add the validation area.

validation.AreaList.Add(area);

// Save the excel file.

workbook.Save("d:\\validationtypelist.xls");

Thank You & Best Regards

Thanks for your reply, This solves our problem.

Regards

Tushar