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,463

    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,463

    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
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    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
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

Posting Permissions

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



Click Here to Expand Forum to Full Width