# Calculate formula issue for &amp;quot;=-INDIRECT(...)&amp;quot;

Hi Aspose team,

I attached an excel file with 2 formulas (the 2nd one is the negation of the 1st formula; 2nd formula = minus 1st formula):

1st) =INDIRECT("‘Sheet1’!G2")
2nd) =-INDIRECT("‘Sheet1’!G2")

where G2 = 5.

Step 1: Let’s define an Aspose.Cells.Workbook variable with the attached excel file:
var excelDocument = new Workbook(“TestFiles\input.xlsx”);

Step 2: Lets apply CalculateFormula() method for the excelDocument created in Step1:
excelDocument.CalculateFormula();

Step 3: Let’s see the results for the each Aspose.Cell from excelDocument:
foreach (Cell cell in excelDocument.Worksheets.Cells)
{
Console.WriteLine(“Cell with coordinates [{0}, {1}] has value={2}; StringValue={3} and DisplayStrinValue={4}”, cell.Row, cell.Column, cell.Value, cell.StringValue, cell.DisplayStringValue);
}

After the Step 3, we’ll notice that the 2nd formula (with red) is calculated wrong, having the cell.value=#VALUE! (DisplayStringValue and StringValue are, also, equal to #VALUE!, not to -5 as expected). The 1st formula (with green) is calculated correct, having cell.Value=5.

I attached also a Demo Project (in C#) which is reproducing the issue described above.

P.S.:
The internal defect related to this issue has id 27722 (the information is just for my colleagues, not for Aspose).

Vitalie Semenciuc
Senior Software Developer
IBM Romania

Hi,

Thanks for your posting and using Aspose.Cells.

for .NET v8.5.0.4
it gives correct results.

I have shown the console output of your sample code for your reference which looks good.

Console Output:
Cell with coordinates [1, 6] has value=5; StringValue=5 and DisplayStrinValue=5
Cell with coordinates [2, 3] has value=5; StringValue=5 and DisplayStrinValue=5
Cell with coordinates [5, 3] has value=-5; StringValue=-5 and DisplayStrinValue=-5

Hi,

Thank you, Shakeel. In my Demo project I have used 8.3.2.1
We’ll update the Aspose.Cells to 8.5.0.4.

Best regards,

Vitalie Semenciuc
Senior Software Developer
IBM Romania

Hi Vitalie,

Thanks for your posting and using Aspose.Cells.