Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way for Validating cell value in excel (vsto)

Suppose i have some value in excel cell,its type may be anything date,numeric or string and i want that cell to be validated against its type... Is there any way of doing this ? thanks in advance..

like image 578
Smack Avatar asked Dec 29 '10 12:12

Smack


1 Answers

I assume you mean that you have contents in a cell, which could be either a date, a double, or a plain string, and that you want to assert what corresponding .NET type it is. I believe there is no direct way of doing this. One approach would be to retrieve the Value2 in the cell, and try to cast it to each of these types, starting from the most restrictive one, until the cast works - i.e. DateTime (DateTime.FromOADate), then double (Convert.ToDouble), then string - and then apply the validation rule that applies to the particular type you found.
I am not quite sure what you mean by validation, though, and what that would buy you. Once you know the type of the content, what would you do with it?

like image 184
Mathias Avatar answered Oct 23 '22 04:10

Mathias