We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Range.ApplyStyle Problem

I want to apply a style to a row.

Excel.Style sty = workBook.Styles[workBook.Styles.Add()];

sty.ForegroundColor = Color.FromArgb( 0, 128, 0 );

sty.Pattern = Excel.BackgroundType.Solid;

Excel.StyleFlag flag = new Excel.StyleFlag();

flag.CellShading = true;

flag.FontName = false;

flag.FontSize = false;

flag.FontColor = false;

flag.FontBold = false;

flag.FontItalic = false;

When I add the style to the entire Row (ws = worksheet):

ws.Cells.Rows[row].ApplyStyle( sty, flag );

It works perfectly. But when I create a range I get a "object not referenced to an instance of an object" problem

Excel.Range range = ws.Cells.CreateRange( row, 0, 1, columncount );

range.SetOutlineBorder( Aspose.Cells.BorderType.BottomBorder, Aspose.Cells.CellBorderType.Thick, Color.Black );

range.SetOutlineBorder( Aspose.Cells.BorderType.TopBorder, Aspose.Cells.CellBorderType.Thick, Color.Black );

range.ApplyStyle( sty, flag );

The borders are added perfectly. But when I try to add a style to that range I get the mentioned Error.


Which version do you use?

Please try this Aspose.Cells fix.