After Exporting to excel from gridview, how to change the forecolor of headerrow alone in excel

Posted by Oswaldlily under ASP.NET on 2/8/2013 | Points: 10 | Views : 1078 | Status : [Member] | Replies : 1
After Exporting to excel from gridview, how to change the forecolor of headerrow alone in excel




Responses

Posted by: Rimi1289 on: 2/9/2013 [Member] Starter | Points: 25

Up
0
Down
Hi,

You can either use auto formatting technique or you can do it you self from code behind.

For auto formatting the excel sheet check the below link

Do it your self from Code Behind

Imports Excel = Microsoft.Office.Interop.Excel


Dim xlWorkSheetToUpload As Excel.Worksheet
xlWorkSheetToUpload = xlAppToUpload.Sheets("Sheet1")

With xlWorkSheet
.Cells(1, 1).value = "Company Name"
.Cells(1, 1).FONT.NAME = "Calibri"
.Cells(1, 1).Font.Bold = True

.Cells(3, 1).value = "Date & Time:"
.Cells(3, 1).FONT.NAME = "Calibri"
.Cells(3, 3).value = Date.Now
.Cells(3, 3).FONT.NAME = "Calibri"
.Cells(3, 3).Font.Bold = True

' MERGE THE CELLS.
.Range("B3:C3").MergeCells = True
end with


Rimi

Oswaldlily, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response