Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Mon May 06, 2019 6:14 pm

I cannot get the value of a formula using the .formulavalue method, using vb.net

I have the codes like

Code: Select all
worksheet.Range("c6").FormulaR1C1 = R[-3]C - R[-2]C


later I used

Code: Select all
if worksheet.range("c6").FormulaValue >=0 then
...
end if


If doesn't work. It used to work when I was using the Microsoft Office app. Anything I missed?

patrick551
 
Posts: 8
Joined: Mon Dec 17, 2018 6:46 pm

Tue May 07, 2019 7:04 am

Hi,

Thanks for your inquiry.
After adding a formula, actually, the formula will not be calculated automatically, that's the reason for your issue. Please calculate it before getting the FormulaValue. Please refer to the following code. If there is any question, please provide your full code for further investigation.
Code: Select all
'calculate all values
workbook.CalculateAllValue()
if worksheet.range("c6").FormulaValue >=0 then
...
end if

Sincerely,
Nancy
E-iceblue support team
User avatar

nancy.yang
 
Posts: 184
Joined: Wed Apr 03, 2019 2:33 am

Thu May 09, 2019 12:34 pm

Hi,

How is your issue now? Could you please give us some feedback at your convenience? Thanks in advance.

Sincerely,
Nancy
E-iceblue support team
User avatar

nancy.yang
 
Posts: 184
Joined: Wed Apr 03, 2019 2:33 am

Return to Spire.XLS