Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
815
Cannot Get Value From A Cell Containing A Formula
posted

I have an excel spreadsheet that I am creating from scratch using the Infragistics.Excel library version 16.1.20161.2044. After I create the spreadsheet, the user can then recall values from the spreadsheet using the following code:

' get the workbook
Dim QuoteWB As Workbook = Workbook.Load("My_Workbook.xlsx")

' get the desired worksheet
Dim CensusWS As Worksheet = QuoteWB.Worksheets("Census")

' the formula for cell D4 looks something like this:
' =('Worksheet1'!C3+'Worksheet1'!D3)*12
Dim AnnualSalary As String = CensusWS.GetCell("D4").Value

The first worksheet in my workbook consists of raw values (no formulas). I am able to get values from this worksheet without any problems. All subsequent worksheets have formulas that are referencing the original worksheet. I am only able to get the value from a cell that does not contain a formula. Any cell that has plain text will work just fine, but as soon as I try to get the value from a cell that has a formula, I get the following error message:

System.InvalidCastException: Conversion from type 'ErrorValue' to type 'String' is not valid.

My goal is to get the value from a cell that contains a formula. I have implemented some complex formulas in the workbook and I need a way to retrieve the results.

Parents Reply Children
No Data