Setting Border Color throws exception

I am trying to set color of a border color, but when I do it and try to access it, it throws an exception

"An unhandled exception of type ‘System.NullReferenceException’ occurred in Aspose.Cells.dll
Aditional information: Object reference not set to an instance of an object"

Attached you can find a screenshot of the problem, and also a reproducer.
Please let me know if I am doing something wrong or if there is a bug in Aspose.Cell library.

Hi,

Thanks for your posting and using Aspose.Cells.

Please don’t use Style constructor but use Workbook.CreateStyle() method to create a Style object.

Please see the following correct code which works fine.

C#

Workbook wb = new Workbook();

var style = wb.CreateStyle();
var color = Color.Blue;
var initialColor = style.Borders[BorderType.TopBorder].Color;
style.Borders[BorderType.TopBorder].Color = color;
var lastColor = style.Borders[BorderType.TopBorder].Color;