Articles in this section
Category / Section

How to avoid exception while setting more number of characters in WPF Spreadsheet?

3 mins read

Maximum number of characters accepted in ListOfValues property for DataValidation is 256 (as per MS Excel). If the array list which is assigned to ListOfValues property holds more than 256 characters, then it may lead to an exception. 

This issue can be resolved by assigning the list of values to the unused ranges in Spreadsheet and refer that range as validation range(DataRange)

C#

 
string[] values = new string[] 
   {
        "A sample text in Spreadsheet1",
       "A sample text in Spreadsheet2",
       "A sample text in Spreadsheet3",
       "A sample text in Spreadsheet4",
       "A sample text in Spreadsheet5"
       "A sample text in Spreadsheet6", 
       "A sample text in Spreadsheet7",
       "A sample text in Spreadsheet8",
       "A sample text in Spreadsheet9",
       "A sample text in Spreadsheet10",
       "A sample text in Spreadsheet11",
       "A sample text in Spreadsheet12",
       "A sample text in Spreadsheet13"
     };
 
//Setting the values to unused range,
for (int i = 0, j = 500; i < values.Length; i++, j++)
  spreadsheet.ActiveSheet[j, 1000].Value = values[i];
 
//Setting the data validation to Cell A3,
var validation = spreadsheet.ActiveSheet.Range["A3"].DataValidation;
IRange valueRange = spreadsheet.ActiveSheet[500, 1000, 500 + values.Length - 1, 1000];
validation.DataRange = valueRange;
 
//Hiding the unused range,
spreadsheet.ActiveSheet.HideColumn(1000);
spreadsheet.ActiveGrid.ColumnWidths.SetHidden(1000, 1000, true);
 

 

Note:

you can assign the array list of values to an unused range and hide that range.

 

 

Sample link:     WPF, WinRT, UWP


Conclusion

I hope you enjoyed learning about how to avoid exception while setting more number of characters in Spreadsheet.


You can refer to our WPF Spreadsheet feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our WPF Spreadsheet example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied