Hi there. I am dealing with a cell that has the following formula and info:
Hi Stephen,
Thanks for your posting and using Aspose.Cells.
After calling Workbook.CalculateFormula(), you should be able to read the calculated field correctly. Please download and try the latest version: Aspose.Cells
for .NET v8.6.1.2 and see if it makes any difference.
If your problem still occurs, then please provide us your source excel file as well as sample code replicating the issue with the latest version. It will help us investigate the issue at our end and we will fix it asap. Thanks for your cooperation.
Hi Shakeel I tested the cell here on my side and noticed the formula is the cause to this issue.
Hi,
Thanks for your issue description and using Aspose.Cells.
We have tested this issue with the following sample code using the latest version: Aspose.Cells
for .NET v8.6.1.2 with the attached source excel file. If you check the source excel file, you will see the cell E6 contains your formula and its value is 100. And if you change the value of B16 to 222, the cell E6 value becomes 289 which is exactly the same calculated by Aspose.Cells.
Please see the following code and its console output for a reference.
C#
String filePath = “D:\Downloads\book1.xlsx”;
Workbook workbook = new Workbook(filePath);
Worksheet worksheet = workbook.Worksheets[0];
//Enter some value in B16 to calculate the new value of the E6
worksheet.Cells[“B16”].PutValue(222);
//Now calculate the formulas
workbook.CalculateFormula();
//Check the calculated value of cell E6, 289 means it is correct
Cell cell = worksheet.Cells[“E6”];
Console.WriteLine("Cell Formula: " + cell.Formula);
Console.WriteLine("Cell Value: " + cell.StringValue);
Console Output:
Cell Formula: =IF($B$8>=MAX($B$26:$B$65),0,$B$12+$B$16+$B$21+$B$18+$B$22)
Cell Value: 289
Hello, looks like when i use Workbook.CalculateFormula(true); it zeros out. If i remove that section of code my excel data comes back as expected. Odd
Hi,
Thanks for your posting and using Aspose.Cells.
Please provide us your sample console application project replicating this issue so that we could investigate it at our end and provide you a correct sample code or a fix. Thanks for your cooperation.