Articles in this section
Category / Section

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

1 min 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)


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.ActiveGrid.ColumnWidths.SetHidden(1000, 1000, true);



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



Sample link:     WPF, WinRT, UWP

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