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..
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?
I use Excel’s data validation technique in a VSTO application myself. It obviously isn’t VSTO but it works well enough. There are some drawbacks like you can’t have multiple validations on the same cell (i.e. you have to know what your validating for)
You can directly use the excel’s functionality !!!
no need of any coding for that !!
instead of hard work go for the smart work …
Go to the cell where you want the validation to come
Menu ->> Data –> validation
Here you can directly use the various excel validation terms.
Which you can refer here or..