ApplyRowStyle - crashes/removes previous formatting

The following snippet crashes with a System.NullReferenceException at the line: ws.Cells.ApplyRowStyle(1, abold, sf);


Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook();
Aspose.Cells.Worksheet ws = wb.Worksheets[0];
Aspose.Cells.Style a1 = new Aspose.Cells.Style();
a1.Number = 7;
Aspose.Cells.Style aText = new Aspose.Cells.Style();
aText.HorizontalAlignment = Aspose.Cells.TextAlignmentType.Left;
Aspose.Cells.StyleFlag sf = new Aspose.Cells.StyleFlag();
sf.FontBold = true;
Aspose.Cells.Style abold = new Aspose.Cells.Style();
abold.Font.IsBold = true;
ws.Cells[0,0].PutValue(9.99M);
ws.Cells[0,0].SetStyle(a1);
ws.Cells[1,0].PutValue(9.99M);
ws.Cells[1,0].SetStyle(a1);
ws.Cells[1,1].PutValue(“Text”);
ws.Cells[1,1].SetStyle(aText);
// uncomment the next line and the ApplyRowStyle will not crash but it removes the formatting from [1,0]
// ws.Cells[1,1].SetStyle(abold, sf);
// Crashes here if the previous line is commented out
ws.Cells.ApplyRowStyle(1, abold, sf);
wb.Save(@"\tmp\test_rowstyle.xlsx");


Maybe I am using it incorrectly but the ApplyRowStyle is also removing the formatting from the 1,0 cell.

Hi Mark,

Thanks for your posting and using Aspose.Cells.

Please download and use the latest version: Aspose.Cells
for .NET v8.1.0.2
it should fix your issue.

I have tested your issue by running your code and it did not throw any exception. I have attached the output xlsx file generated by it for your reference.

Thanks, that seems to fix the issue I was dealing with.

Hi Mark,

Thanks for your feedback and using Aspose.Cells.

It is good to know that your issue is fixed with the latest version. Let us know if you encounter any other issue, we will be glad to look into it and help you further.