Access the value of Excel cells and not the formel in the cell

58 Views Asked by At

I hope I will have the chance to find an appriate solution for my problem here .I'm trying to import the data from an excel file in my c# program, I don't know why but I can't see the value at that specified position. I can only see the code at this particular cell . May be something like C3*$B$2-$F$2. I'm using the nuget Spire.XLS

Please I need help

I have tried to read the value in different ways but without succeed.

1

There are 1 best solutions below

0
Dheeraj Malik On

If you want to read the calculated values of formulas, you will need to use the FormulaValue property. Here is a simple example:

//Load an Excel file
Workbook workbook = new Workbook();
workbook.LoadFromFile("Formulas.xlsx");

//Get the first worksheet
Worksheet sheet = workbook.Worksheets[0];
//Read the calculated value of the formula in Cell B1
string calculatedValue = sheet.Range["B1"].FormulaValue.ToString();