Cell.GetDisplayStyle() set to 0 the value of another cell

Hi,

When calling GetDisplayStyle() method on custom formatted cell the value of the cell used in custom formatting condition is set to 0.
For reproducing the issue please use the attached Excel file and the following code:

var workbook = new Workbook(“test.xlsx”);

var sourceCell = workbook.Worksheets[0].Cells[“C3”];
var affectedCell = workbook.Worksheets[0].Cells[“E3”];

Console.WriteLine(“E3 Value Before: {0}”, affectedCell.Value);
sourceCell.GetDisplayStyle();
Console.WriteLine(“E3 Value After: {0}”, affectedCell.Value);

Regards,
Aurelian Iordache
Software Developer
IBM Romania

Hi Aurelian,

Thanks for your posting and using Aspose.Cells.

Please call Workbook.CalculateFormula() and then run your code, it will execute fine.

Here is the modified code for your reference.

C#


var workbook = new Workbook(“test.xlsx”);


workbook.CalculateFormula();


var sourceCell = workbook.Worksheets[0].Cells[“C3”];

var affectedCell = workbook.Worksheets[0].Cells[“E3”];


Console.WriteLine(“E3 Value Before: {0}”, affectedCell.Value);

sourceCell.GetDisplayStyle();

Console.WriteLine(“E3 Value After: {0}”, affectedCell.Value);