抑制"数字存储为文本"在Excel VSTO警告使用C# [英] suppress "number stored as text" warning in Excel VSTO with C#

查看:346
本文介绍了抑制"数字存储为文本"在Excel VSTO警告使用C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在C#中的Excel VSTO项目。
。对于某些列,我已经设置了NumberFormat的使用

I am working in a Excel VSTO project with C#. For certain columns, I have set the NumberFormat to Text using

someCell.EntireColumn.NumberFormat = "@";



但是,当数字并恰巧在这些列,Excel中显示带有警告绿色箭头号码存储为文本。我想禁止这种警告消息。

But when numbers do happen to be in these columns, Excel shows a green arrow with warning "Number Stored as Text". I want to suppress this warning message.

我知道该怎么做,在Excel中:选项 - >公式 - >在错误检查规则,取消格式为文本,或者前面有撇号号码。是否有可能做到这一点在C#代码,只有某些单元格/区域?谢谢!

I know how to do that in Excel: Options -> Formulas -> in Error checking rules, uncheck "Numbers formatted as text or preceded by an apostrophe". Is it possible to do this in C# code, and only to certain cells/ranges? Thanks!

推荐答案

有(在VBA)

Dim c As Range

For Each c In Selection.Cells
    c.Errors(xlNumberAsText).Ignore = True
Next c

好像你不能满足全范围的一次 - 通过细胞

Seems like you can't address a whole range at once - have to loop through the cells

这篇关于抑制"数字存储为文本"在Excel VSTO警告使用C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆