BorderType in Aspose cells

Hi all,

i want to set border for my cells.
i used

ws.Cells[0, 0].Style.Borders.SetStyle(Aspose.Cells.CellBorderType.Hair);

and result

but i want result

Please help me!!

Hi,

Please refer to the following code for your need:

Workbook workbook = new Workbook();
Cells cells = workbook.Worksheets[0].Cells;


//apply style to a range of cells.
Range range = cells.CreateRange(“B2”, “D4”);
Style stl = workbook.Styles[workbook.Styles.Add()];
stl.Borders[BorderType.TopBorder].LineStyle = CellBorderType.Hair;
stl.Borders[BorderType.TopBorder].Color = Color.Blue;
stl.Borders[BorderType.LeftBorder].LineStyle = CellBorderType.Hair;
stl.Borders[BorderType.LeftBorder].Color = Color.Blue;
stl.Borders[BorderType.BottomBorder].LineStyle = CellBorderType.Hair;
stl.Borders[BorderType.BottomBorder].Color = Color.Blue;
stl.Borders[BorderType.RightBorder].LineStyle = CellBorderType.Hair;
stl.Borders[BorderType.RightBorder].Color = Color.Blue;
StyleFlag flg = new StyleFlag();
flg.Borders = true;

range.ApplyStyle(stl, flg);


//Applying border to a single cell.
//Accessing the “A1” cell from the worksheet
Aspose.Cells.Cell cell = cells[“A1”];
//Adding some value to the “A1” cell
cell.PutValue(“Visit Aspose!”);
//Setting the line style of the top border
cell.Style.Borders[BorderType.TopBorder].LineStyle = CellBorderType.Hair;
//Setting the color of the top border
cell.Style.Borders[BorderType.TopBorder].Color = Color.Red;
//Setting the line style of the bottom border
cell.Style.Borders[BorderType.BottomBorder].LineStyle = CellBorderType.Hair;
//Setting the color of the bottom border
cell.Style.Borders[BorderType.BottomBorder].Color = Color.Green;
//Setting the line style of the left border
cell.Style.Borders[BorderType.LeftBorder].LineStyle = CellBorderType.Hair;
//Setting the color of the left border
cell.Style.Borders[BorderType.LeftBorder].Color = Color.Blue;
//Setting the line style of the right border
cell.Style.Borders[BorderType.RightBorder].LineStyle = CellBorderType.Hair;
//Setting the color of the right border
cell.Style.Borders[BorderType.RightBorder].Color = Color.Yellow;

workbook.Worksheets[0].AutoFitColumn(0);

workbook.Save(“e:\test\testingborders.xls”);


For further details, see the documents:
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/named-ranges.html
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/adding-borders-to-cells.html

Thank you.

Work good! ^^
Thanks so much