suppress "number stored as text" warning in Excel VSTO with C#

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

someCell.EntireColumn.NumberFormat = "@";

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.

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!

在这里输入图像描述


There's (in 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

链接地址: http://www.djcxy.com/p/67840.html

上一篇: 使用注册表检测安装的MS Office是32位还是64位

下一篇: 在Excel VSTO中用C#压缩“存储为文本的数字”警告