Add underline to Excel file created in vb.net?-VBForums
Results 1 to 4 of 4

Thread: Add underline to Excel file created in vb.net?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2000
    Posts
    1,444

    Question Add underline to Excel file created in vb.net?

    Hi Everyone,

    How do you draw a solid underline from one cell to another? I tried the last line below to do this but it only underlines each word. Is there a way to connect the line?

    Thanks!

    Code:
    xlWSheet.Range("A" & i.ToString).Value = "Local"
    xlWSheet.Range("B" & i.ToString).Value = "Name"
    xlWSheet.Range("C" & i.ToString).Value = "Reg Hours"
    xlWSheet.Range("D" & i.ToString).Value = "OT Hours"
    xlWSheet.Range("E" & i.ToString).Value = "DT Hours"
    xlWSheet.Range("F" & i.ToString).Value = "Total Hours"
    xlWSheet.Range("G" & i.ToString).Value = "Gross Wages"
    xlWSheet.Range("A" & i.ToString & ":G" & i.ToString).Font.Underline = True

  2. #2
    PowerPoster keystone_paul's Avatar
    Join Date
    Nov 2008
    Location
    UK
    Posts
    3,327

    Re: Add underline to Excel file created in vb.net?

    Do you not want to be setting the border style of the cell rather than an attribute of the font?

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2000
    Posts
    1,444

    Re: Add underline to Excel file created in vb.net?

    Actually I just saw that about the border style. So I need to draw a solid black line across the cells for the bottom to act as an underline all the way across. Do you know the code to do this?

    Thanks!

    Warren

  4. #4
    Super Moderator Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    11,920

    Re: Add underline to Excel file created in vb.net?

    Try this...

    vb Code:
    1. xlWSheet.Range("A" & i.ToString).Value = "Local"
    2. xlWSheet.Range("B" & i.ToString).Value = "Name"
    3. xlWSheet.Range("C" & i.ToString).Value = "Reg Hours"
    4. xlWSheet.Range("D" & i.ToString).Value = "OT Hours"
    5. xlWSheet.Range("E" & i.ToString).Value = "DT Hours"
    6. xlWSheet.Range("F" & i.ToString).Value = "Total Hours"
    7. xlWSheet.Range("G" & i.ToString).Value = "Gross Wages"
    8.  
    9. With xlWSheet.Range("A" & i.ToString & ":G" & i.ToString).Borders(xlEdgeBottom)
    10.     .LineStyle = xlContinuous
    11.     .Weight = xlThin
    12.     .ColorIndex = xlAutomatic
    13. End With
    The poster formerly known as koolsid
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved

    Microsoft MVP: 2011 - Till Date IMP Links : Acceptable Use Policy, FAQ

    MyGear:
    Sony VGN-FZ27G with a triple boot between (XP+Office 2003+VB6), (VISTA+Office 2007+VS2008) and (Win7+Office 2010+VS2010) || Sony VPCCB-45FN with a Win7+Office 2010+VS2010. VM: (XP+Office 2003+VB6), (VISTA+Office 2007+VS2008), (Win8+Office 2010+VS2012) || Mac Book Pro (10.6.8) with Office 2011

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.