Excel 2007中从C#的get_value总是返回-2146826265 [英] Excel 2007 from C# get_Value always returns -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 :
从这个很好的答案:
这篇关于Excel 2007中从C#的get_value总是返回-2146826265的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!