Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
200
Reading external Excel file
posted

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!

Parents
No Data
Reply
  • 29185
    Offline posted

    Hello, 

    Cells have a Value property. 

    eg.

    // 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

Children