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.

Wed May 18, 2022 6:49 am

Hi Spire XLS!

Spire xls has been excellent with my requirement with uploading and reading the cell values of the excel file.

But I have noticed that when a cell has a formula, the Value2 reads the formula instead of the result of the formula.

I was wondering how can I get the value of the formula instead of the formula...

Reading the value of A11 using this script

var de = wks.Range["A11:A11"]

then on the excel file, on cell A11 =DigitalExecution!K2

The cell A11 is referencing cell K2 on the worksheet DigitalExecution

so when I read the file, my function fails when it try to convert to int the needed value. I was expecting an integer datatype to be passed on my model and then save in database


I also tried FormulaValue, but still the same output.
Attachments
Untitled.png
Untitled.png (8.3 KiB) Viewed 994 times

MonsurMon
 
Posts: 3
Joined: Thu Mar 10, 2022 7:07 am

Wed May 18, 2022 9:51 am

Hello,

Thanks for your inquiry.

Based on your description, I created a similar xlsx document to test. But FormulaValue can get the value of the formula (as in the screenshot).
D396799F-46F2-48e2-BBA9-0CF8B7F69156.png
D396799F-46F2-48e2-BBA9-0CF8B7F69156.png (39.68 KiB) Viewed 980 times

To help us investigate this further, could you please share your xlsx document with us? You can upload it here or send it to us via mail (support@e-iceblue.com).
Sincerely,
Andy
E-iceblue support team
User avatar

Andy.Zhou
 
Posts: 483
Joined: Mon Mar 29, 2021 3:03 am

Thu May 19, 2022 6:26 am

Hi Andy!

It seems that I have mismatch the datatype with the functions of spire xls...

I have used FormulaNumberValue, NumberValue, and FormulaStringValue for int, decimal and string datatypes..

it worked properly after that.

Thank you for giving me the idea!

MonsurMon
 
Posts: 3
Joined: Thu Mar 10, 2022 7:07 am

Fri May 20, 2022 8:27 am

Hello,

Glad to hear that you resolved the issue, if there is anything else we can do for you in the future, just feel free to contact!

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1261
Joined: Wed Apr 25, 2018 3:20 am

Return to Spire.XLS