开发者

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..开发者_如何学Python. 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 ...

In excel, 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..

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

Thanx Regards.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜