Pages

Friday 16 July 2010

DISP_E_OVERFLOW

When working with Interop Excel, is better to read values from a given cell by using mySheet.Range("A2").Value2 instead of mySeet.Range("A2").Value. This is because when a cell is not displaying the whole content, for instance "######" the property Value will throw the exception DISP_E_OVERFLOW, but when you are using Value2 you will get the actual value inside the cell rather than the value displayed on the screen.

2 comments:

  1. Actually you can't always use Value2 as is would corrupt Dates and Currencies (see https://msdn.microsoft.com/en-us/library/office/microsoft.office.interop.excel.range.value2(v=office.14).aspx), but thank you for the idea to look for "#####" cells!

    ReplyDelete