Hey,
we imported an external Excel file into a Infragistics.Documents.Excel.Worksheet.
Some cells contains a dropdown list.
How can we get the linked elemnets (like ValueList) or set the Value not like text but as an index of the dropdownlist (DataValidationRule is null / Value Type is string)
Thanks for your help!
Hello,
You can retrieve the values in the dropdown list by using the GetValuesFormula by passing the cell address.
eg.
string[] allowedValues = { "Red", "Green", "Blue" };
// Create the dropdown list ruleListDataValidationRule dropdownRule = new ListDataValidationRule();dropdownRule.SetValues(allowedValues);
WorksheetCell cell = sheet.Rows[14].Cells[0];cell.DataValidationRule = dropdownRule;
var t = dropdownRule.GetValuesFormula("$A$14");
Hey Michael,
thanks for your answer.
Our problem is, that cells of the external Excel-File has a dropdown-list (in Excel / source like “=Kataloge!$B$2:$B$3”) but we could not get the allowed values by reading this external Excel-File with Infragistics ExcelEngine.
The Type of the Infragistics.Documents.Excel.WorksheetCell is string and this cell has no DataValidationRule.
Is there another opportunity to get the allowed values or the source value?
Cells have a Value property.
// Define allowed values string[] allowedValues = { "Red", "Green", "Blue" };
// Create the dropdown list rule ListDataValidationRule dropdownRule = new ListDataValidationRule(); dropdownRule.SetValues(allowedValues);
// Apply rule to cell A1 WorksheetCell cell = sheet.Rows[14].Cells[0]; cell.DataValidationRule = dropdownRule;
// Set the value to one of the allowed items cell.Value = "Green"; // This is valid and will pass validation