KJ - sorry, I forgot to mention that.
I'm doing it by the content-type header & rendering control in-line.
Here's a good bit of the code:
Private Sub RenderGrid()
Dim sFile As String = Session("User") & "-" & Label2.Text
sFile = sFile.Replace("/", "-")
If DataGrid1.Visib le = True Then
ClearControls(D ataGrid1)
End If
If GridView1.Visib le = True Then
ClearControls(G ridView1)
End If
Select Case Session("bc")
Case "Excel"
Response.Conten tType = "applicatio n/vnd.ms-excel"
Response.Append Header("content-disposition",
"attachment ; filename=" & sFile & ".xls")
Case "Word"
Response.Conten tType = "applicatio n/vnd.ms-word"
Response.Append Header("content-disposition",
"attachment ; filename=" & sFile & ".doc")
End Select
' Remove the charset from the Content-Type header.
Response.Charse t = ""
' Turn off the view state.
Me.EnableViewSt ate = False
Dim tw As New System.IO.Strin gWriter
Dim hw As New System.Web.UI.H tmlTextWriter(t w)
Label2.RenderCo ntrol(hw)
hw.Write(("<br> "))
Label1.RenderCo ntrol(hw)
' Get the HTML for the control.
If DataGrid1.Visib le = True Then
DataGrid1.Rende rControl(hw)
End If
If GridView1.Visib le = True Then
GridView1.Rende rControl(hw)
End If
' Write the HTML back to the browser.
Response.Write( tw.ToString())
' End the response.
Response.End()
End Sub
BC
KJ wrote:
Can you tell us how you are exporting to Excel - are you doing it by setting
the Content-Type header and rendering the control inline, or some other
method?
"Blasting Cap" <go****@christi an.netwrote in message
news:%2******** **********@TK2M SFTNGP04.phx.gb l...
>I have an app that gives a user an option to pull an online report into
Excel.
I have the rows formatted in a couple different colors, with a grey header
& footer.
No matter what colors the alternating (and regular) rows are between the
header & footer, they come out an off-white color.
Is there a way to programatically set the colors of cells when they're
exported to excel?
Second question - on the row above the header in the export page, I put
out a confidentiality message. Is there a way to have the background of
that cell a different color other than white? I want to do something to
highlight it or something, to make it stand out somewhat versus the rest
of the report.
Thanks,
BC