Here, we suppose you have written text in a cell of an Excel document. Now, you can add borders simply by setting the color and the line style with the sheet.Range["A1"].Borders.Color and sheet.Range["A1"].Borders.LineStyle methods. Something must be paid attention, sheet.Range["A1"].Borders method in Spire.XLS contains six borders:Four borders and two diagonals. You can delete the two diagonals by setting the sheet.Range["A1"].Borders[BordersLineType.DiagonalDown].LineStyle and sheet.Range["A1"].Borders[BordersLineType.DiagonalUp].LineStyle none.
Code of C# for adding excel borders :
01 using System.Drawing;
02 using Spire.Xls;
03
04 namespace ExtractText
05 {
06 class Program
07 {
08 static void Main(string[] args)
09 {
10 //Create a new workbook.
11 Workbook workbook = new Workbook();
12 Worksheet sheet = workbook.Worksheets[0];
13
14 //Write text in B2.
15 sheet.Range["B2"].Text = "Home page";
16
17 //Set the color of the six borders.
18 sheet.Range["B2"].Borders.Color = Color.Green;
19
20 //Set the line style of the borders.
21 sheet.Range["B2"].Borders.LineStyle = LineStyleType.Thick;
22
23 //Delete the diagonalDown border.
24 sheet.Range["B2"].Borders[BordersLineType.DiagonalDown].LineStyle = LineStyleType.None;
25
26 //Delete the DiagonalUp border.
27 sheet.Range["B2"].Borders[BordersLineType.DiagonalUp].LineStyle = LineStyleType.None;
28 sheet.AutoFitColumn(2);
29
30 //Save the file.
31 workbook.SaveToFile("Sample.xls");
32
33 //Launch the file.
34 System.Diagnostics.Process.Start("Sample.xls");
35 }
36 }
37 }
use vb.net code here:
http://www.e-iceblue.com/Knowledgebase/Spire.XLS/Program-Guide/how-to-use-csharp-or-vbnet-to-add-excel-borders.html
i could be the one