Excel 2007中从C#的get_value总是返回-2146826265 [英] Excel 2007 from C# get_Value always returns -2146826265

查看:1847
本文介绍了Excel 2007中从C#的get_value总是返回-2146826265的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小C#应用程序,它引用的Microsoft Excel 12.0对象库。除其他事项外,它读取Excel单元格的值。它读取一些旧的Excel(.xls的)文件这个值和2007年的一些文件格式(.xlsx)。该值回来妥善所有.xls文件,但我只得到的.xlsx文件为以下值:-2146826265

I have a small C# app that references the Microsoft Excel 12.0 Object Library. Among other things, it reads a value from an Excel cell. It reads this value from some older Excel (.xls) files and some 2007 files (.xlsx). The value comes back properly for all .xls files but I only get the following value for .xlsx files: -2146826265.

我读的单元格中包含一个简单的公式:= A1 + B1

The cell I'm reading contains a simple formula: "=A1+B1".

这是我使用

((Excel.Range)ws.Cells.get_Item(29, 17)).get_Value(null));



在哪里WS是当前活动工作表中。

Where ws is the current, active worksheet.

感谢你能提供任何帮助。

Thanks for any help you can offer.

推荐答案

该功能的get_value为他的错误消息返回整数。
清单如下:

The get_value function returns integer for his error message. Here is the list :

-2146826281 = #Div/0!
-2146826246 - #N/A
-2146826259 = #Name?
-2146826288 = #Null!
-2146826252 = #Num!
-2146826265 = #Ref!     <- yours !
-2146826273 = #Value!



这里是一个很好的文章:

And here is a very good article :

http://xldennis.wordpress.com/2006/11/22/dealing-with-cverr-values-in-net-%E2%80%93-part-i-the-problem/

从这个很好的答案:

如何知道如果一个单元有公式在C#中误差

这篇关于Excel 2007中从C#的get_value总是返回-2146826265的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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