Excel 2007 with C # get_Value always returns -2146826265

I have a small C # application that references a Microsoft Excel 12.0 object library. Among other things, it reads a value from an Excel cell. It reads this value from some old Excel files (.xls) and some 2007 files (.xlsx). The value is returned correctly for all .xls files, but I only get the following value for .xlsx files: -2146826265.

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

This is the line of code I'm using

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

Where ws is the current active sheet.

Thanks for any help you can offer.

+3
source share
1 answer

get_value . :

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

:

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

:

, #

+8

Source: https://habr.com/ru/post/1774561/


All Articles