I’m trying to set the borders of a range selection.
My code looks like this :
Aspose.Excel.Range range = sheet.Cells.CreateRange(“A1”,"A10);
range.Style.Borders[BorderType.BottomBorder].LineStyle = CellBorderType.Thin;
But, it seems that range.Style.Borders is null : I get a null pointer exception.
It works ok when I set a single cell border type.
Where am I wrong ?
Please refer to http://www.aspose.com/Products/Aspose.Excel/Api/Aspose.Excel.Range.Style.html and http://www.aspose.com/Products/Aspose.Excel/Api/Aspose.Excel.Range.SetOutlineBorder.html.
If you want to set the outline border of a range, please user SetOutlineBorder method. If you want to set borders for each cell of a range, please try the following code:
int styleIndex = excel.Styles.Add();
Aspose.Excel.Style style = excel.Styles[styleIndex];
style.Borders[BorderType.BottomBorder].LineStyle = CellBorderType.Thin;
range.Style = style;