ListDataValidationRule.Argument1 Property Length Causing Issue

1 Answer 16 Views
Top achievements
Rank 1
Nicholas asked on 02 Nov 2021, 03:26 PM


I am using the RadSpreadProcessing library to create Excel reports:

I'm using the DataValidation (i.e. ListDataValidationRule) to create dropdowns with a set of values:

Here's the issue I'm seeing:

I go to try to create a dropdown with the ListDataValidationRule object, but when my string length is >255 characters for the Argument1 property and I export out the report, I receive an error when trying to launch the exported file:

Sample code:

CellIndex dataValidationRuleCellIndex = new CellIndex(0, 0); ListDataValidationRuleContext context = new ListDataValidationRuleContext(worksheet, dataValidationRuleCellIndex); context.ErrorStyle = ErrorStyle.Stop; context.ErrorAlertTitle = "Wrong value"; context.ErrorAlertContent = "The entered value is not valid"; context.InCellDropdown = true;

context.IgnoreBlank= false;

// Insert string length is > 255 characters context.Argument1 = <INSERT STRING OF LENGTH > 255 CHARACTERS>; ListDataValidationRule rule = new ListDataValidationRule(context); worksheet.Cells[dataValidationRuleCellIndex].SetDataValidationRule(rule); 


Top achievements
Rank 1
commented on 02 Nov 2021, 03:29 PM

For example, string with 256 characters:

context.Argument1 = "B6 Drill Chuck Connection BFA 0060, B10 Drill Chuck Connection BFA 0100, B12 Drill Chuck Connection BFA 0120, B16 Drill Chuck Connection BFA 0160, B18 Drill Chuck Connection BFA 0180, B22 Drill Chuck Connection BFA 0220, B24 Drill Chuck Connection BFA 0240"

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 04 Nov 2021, 09:30 AM

Hi Nicholas,

Yes, that is a limitation that exists in Excel. I would suggest adding the data to cells and then referencing the range in the validation rule: 

ListDataValidationRuleContext context = new ListDataValidationRuleContext(worksheet, dataValidationRuleCellIndex);
context.ErrorStyle = ErrorStyle.Stop;
context.ErrorAlertTitle = "Wrong value";
context.ErrorAlertContent = "The entered value is not valid";
context.InCellDropdown = true;
context.IgnoreBlank = false;
for (int i = 0; i < 100; i++)
    worksheet.Cells[i, 1].SetValue("item" + i);

context.Argument1 = "=($B$1:$B$100)";

I hope this helps. Should you have any other questions do not hesitate to ask.

Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question