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

Free Support Forum - aspose.com

How to Create a Vetical Inline Boredr To Range Of Cells

Hello Support,
How , i can create a Vertical Inline Border To Range of Cells.


Hi Mohit,

Thanks for your posting and using Aspose.Cells.

Please see the following code that explains how to apply border to range of cells. It applies a thin border with red color to all the cells in a range C2:E5.

Let us know if it is helpful for you. If you are looking something else, then please provide us your sample Excel file with your desired borders which you can create manually and post it here for our reference. We will look into it and help you asap.

I have also attached the output Excel file generated by this code and screenshot showing the output for your reference.


Workbook workbook = new Workbook();

Worksheet worksheet = workbook.Worksheets[0];

Range range = worksheet.Cells.CreateRange(“C2:E5”);

Style style = workbook.CreateStyle();

style.Borders[BorderType.LeftBorder].LineStyle = CellBorderType.Thin;

style.Borders[BorderType.LeftBorder].Color = Color.Red;

style.Borders[BorderType.RightBorder].LineStyle = CellBorderType.Thin;

style.Borders[BorderType.RightBorder].Color = Color.Red;

style.Borders[BorderType.TopBorder].LineStyle = CellBorderType.Thin;

style.Borders[BorderType.TopBorder].Color = Color.Red;

style.Borders[BorderType.BottomBorder].LineStyle = CellBorderType.Thin;

style.Borders[BorderType.BottomBorder].Color = Color.Red;

StyleFlag flag = new StyleFlag();

flag.Borders = true;

range.ApplyStyle(style, flag);

workbook.Save(“output.xlsx”, SaveFormat.Xlsx);