DataValidation error with DataRange

Hi everyone,

I have a issue with the DataValidation property.
There is a ArgumentOutOfRangeException when the string is higher than 255 characters. So i want to set the possible values with a DataRange :

range = (IRange) sheet.Columns.GetValue(this.Column);

range.DataValidation.DataValidationRange = sheet.Range[1, 100, 32, 100];

It says that it's impossible to delete the element because it's not in the collection . . .

I tried with the FirstFormula too.

Thx


1 Reply

YG Yavanaarasi G Syncfusion Team April 21, 2008 01:19 PM UTC

Hi Kalkotue,

Thank you for your interest in Syncfusion products.

The "ArgumentOutOfRangeException" was thrown because the sum of all the strings greater than 256 characters. MS Excel has restriction of total 255 characters in the data validation formula, so summary strings length should be even less.

However you can use the following code snippets to set data validation for more [more than 256] characters by specifying the range address. But you can’t write more than 256 characters in the data validation formula. Please refer the following code snippet to achieve this.

[C#]

//Data validation to list the values in the first cell
IDataValidation validation = sheet.Range["A1"].DataValidation;
sheet.Range["A1"].Text = "Data validation list";
validation.FirstFormula = "$D$1:$D$8";
validation.AllowType = ExcelDataType.User;
validation.PromptBoxText = "Data Validation list";

Here is the sample for your reference:
http://websamples.syncfusion.com/samples/XlsIO.Web/6.2.0.39/73046/main.htm

Please take a look at the sample above and let me know if you have any other questions.

Regards,
G.Yavana



Loader.
Up arrow icon