troubleshooting Question

Excel Borders

Avatar of slightlyoff
slightlyoff asked on
Visual Basic.NET
10 Comments1 Solution1561 ViewsLast Modified:
Need some help with some borders.  I've been looking around for different ways to implement borders but I can't seem to get them to work.

Here's the code I'm using:
        Dim style6 As Excel.Style = xlWorkSheet.Application.ActiveWorkbook.Styles.Add("CellBord")
        style6.Borders(Excel.XlBordersIndex.xlEdgeTop).LineStyle = Excel.XlLineStyle.xlContinuous
        style6.Borders(Excel.XlBordersIndex.xlEdgeLeft).LineStyle = Excel.XlLineStyle.xlContinuous
        style6.Borders(Excel.XlBordersIndex.xlEdgeBottom).LineStyle = Excel.XlLineStyle.xlContinuous
        style6.Borders(Excel.XlBordersIndex.xlEdgeRight).LineStyle = Excel.XlLineStyle.xlContinuous
        style6.Borders(Excel.XlBordersIndex.xlEdgeTop).Weight = Excel.XlBorderWeight.xlThin
        style6.Borders(Excel.XlBordersIndex.xlEdgeLeft).Weight = Excel.XlBorderWeight.xlThin
        style6.Borders(Excel.XlBordersIndex.xlEdgeBottom).Weight = Excel.XlBorderWeight.xlThin
        style6.Borders(Excel.XlBordersIndex.xlEdgeRight).Weight = Excel.XlBorderWeight.xlThin

This is putting a right border on the cells (except the last one).  Here's how I use the style:

 xlWorkSheet.Cells(ro, 1) = itemView1.Items(sd).Text
                xlWorkSheet.Cells(ro, 1).Style = "CellBord"
                xlWorkSheet.Cells(ro, 2) = itemView1.Items(sd).SubItems(1).Text
                xlWorkSheet.Cells(ro, 2).Style = "CellBord"
                xlWorkSheet.Cells(ro, 3) = CDbl(itemView1.Items(sd).SubItems(2).Text)
                xlWorkSheet.Cells(ro, 3).Style = "CellBord"
                xlWorkSheet.Cells(ro, 4) = CDbl(itemView1.Items(sd).SubItems(3).Text)
                xlWorkSheet.Cells(ro, 4).Style = "CellBord"
                xlWorkSheet.Cells(ro, 5) = CDbl(itemView1.Items(sd).SubItems(4).Text)
                xlWorkSheet.Cells(ro, 5).Style = "CellBord"
                xlWorkSheet.Cells(ro, 6) = CDbl(itemView1.Items(sd).SubItems(5).Text)
                xlWorkSheet.Cells(ro, 6).Style = "CellBord"
                xlWorkSheet.Cells(ro, 7) = CDbl(itemView1.Items(sd).SubItems(6).Text)
                xlWorkSheet.Cells(ro, 7).Style = "CellBord"
                xlWorkSheet.Cells(ro, 8).Style = "FailText"
                xlWorkSheet.Cells(ro, 8) = itemView1.Items(i).SubItems(7).Text
                xlWorkSheet.Cells(ro, 8).Style = "CellBord"

Any suggestions?  Thanks for the help!

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 10 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 10 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros