Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
selected column exported from gridview to excel ,excel header fore color with white and back color with blue but header under line is not applying to my excel sheet?please advice on this

VB.NET
GridView1.HeaderRow.ForeColor = Drawing.Color.White
GridView1.HeaderRow.BackColor = Drawing.Color.FromArgb(75, 130, 201)
GridView1.HeaderStyle.Font.Underline = True
 
GridView1.HeaderRow.Style.Add("text-decoration", "Underline")
For Each cell As TableCell In GridView1.HeaderRow.Cells
   cell.BackColor = GridView1.HeaderStyle.BackColor
   cell.ForeColor = GridView1.HeaderStyle.ForeColor
   GridView1.HeaderStyle.Font.Underline = True
   GridView1.HeaderRow.Cells(0).Style.Add("text-decoration", "Underline")
Next
 
For Each row As GridViewRow In GridView1.Rows
   For Each cell As TableCell In row.Cells
      If row.RowIndex Mod 2 = 0 Then
         row.BackColor = Drawing.Color.FromArgb(235, 235, 235)
         cell.BackColor = GridView1.AlternatingRowStyle.BackColor
      Else
         row.BackColor = Drawing.Color.FromArgb(211, 211, 211)
         cell.BackColor = GridView1.RowStyle.BackColor
      End If
      cell.CssClass = "textmode"
   Next
Next
GridView1.RenderControl(hw)

Dim style As String = "<style> .textmode { } </style>"
Response.Write(style)
Response.Output.Write(sw.ToString())
Response.Flush()
Response.[End]()
Posted
Updated 18-Feb-15 19:00pm
v3
Comments
Wendelius 19-Feb-15 0:33am    
Please post the relevant part of the code you have made
SathishRam 19-Feb-15 0:43am    
GridView1.HeaderRow.ForeColor = Drawing.Color.White
GridView1.HeaderRow.BackColor = Drawing.Color.FromArgb(75, 130, 201)
GridView1.HeaderStyle.Font.Underline = True

GridView1.HeaderRow.Style.Add("text-decoration", "Underline")
For Each cell As TableCell In GridView1.HeaderRow.Cells
cell.BackColor = GridView1.HeaderStyle.BackColor
cell.ForeColor = GridView1.HeaderStyle.ForeColor
GridView1.HeaderStyle.Font.Underline = True
GridView1.HeaderRow.Cells(0).Style.Add("text-decoration", "Underline")
Next

For Each row As GridViewRow In GridView1.Rows

For Each cell As TableCell In row.Cells
If row.RowIndex Mod 2 = 0 Then
row.BackColor = Drawing.Color.FromArgb(235, 235, 235)
cell.BackColor = GridView1.AlternatingRowStyle.BackColor
Else
row.BackColor = Drawing.Color.FromArgb(211, 211, 211)
cell.BackColor = GridView1.RowStyle.BackColor
End If
cell.CssClass = "textmode"
Next
Next
GridView1.RenderControl(hw)

Dim style As String = "<style> .textmode { } </style>"
Response.Write(style)
Response.Output.Write(sw.ToString())
Response.Flush()
Response.[End]()

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900