Free Support Forum - aspose.com

Validation - Dependent validation list

I’m trying to build dependent drop down lists. You can find a how to (in Excel) here.

While creating these lists plus giving them names is not a problem, creating the validation is. Here is the code. (Feel free to format it. Somehow I was not capable to do so.)

var validation = validations[validations.Add(new CellArea() { StartRow = dropdownRowIndex, EndRow = worksheet.Cells.MaxDataRow, StartColumn = dropdownColumnIndex, EndColumn = dropdownColumnIndex })]; validation.Type = ValidationType.List; validation.InCellDropDown = true; validation.Formula1 = ListName;

ListName is the holding the name of the list object, which I’ve create before. When I’m opening the Excel document and expand the dropdown list, the name of the list is shown but not the values of the list object.

So what am I doing wrong? Am I using the wrong way to apply the valid value list?

@DHN,

Thanks for your query.

Please send us a complete compilable/runnable project along with the output generated using Aspose.Cells. Also send us an Excel file which is generated using MS Excel and contains validations as you want. It will help us to compare the program output with the desired output and provide our feedback.

@ahsaniqbalsidiqui,

I think the issue lies in the fact, that the range name cannot be used as validation list.

I’ve created a sample excel to show what the goal is.

20180827_Aspose_IndirectDropDown_Sample.zip (8.5 KB)

@DHN,

Thank you for providing the sample Excel file. We have understood the problem but we need your sample code too, from which you sent us excerpt in the first post. It will help us to review the code and provide our feedback. Please send us your complete simplified program which is runnable and can be executed here without any error for our analysis.

You may have a look at the code in the following link for your reference:

List Data Validation

@DHN,

In addition to my last reply, please try to set the formula with ‘=’ to reference to the defined Name:

validation.Formula1 = "=" + ListName;

Without ‘=’, the string will be taken as plain text value.

Please let us know your feedback.