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
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?
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
Re: Add underline to Excel file created in vb.net?
Try this...
vb 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"
With xlWSheet.Range("A" & i.ToString & ":G" & i.ToString).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With