Is there a way to check cell value in excel (vsto)

Suppose I have some kind of value in an excel cell, its type can be any date, number or string and I want this cell to be type checked . Is there any way to do this? thanks in advance.

+6
c # excel vsto
source share
3 answers

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

+4
source share

I use Excel data validation technique in VSTO application myself. Obviously, this is not VSTO, but it works quite well. There are some drawbacks, for example, you cannot have multiple validations in the same cell (i.e. you need to know what you are checking for)

+1
source share

You can directly use excel functionality !!! no coding needed for this!

instead of hard work for clever work ...

In excel, go to the cell where you want the validation to pass

Menu → Data → Check

Here you can directly use the various excel validation conditions. What can you attribute here or ..

http://support.microsoft.com/kb/211485

Thanx Best Regards.

+1
source share

All Articles