Output to Excel - White Cell Background.

  • Thread starter Thread starter iforsyth
  • Start date Start date
I

iforsyth

I'm doing a query against a database table and outputting to Excel via
Response.ContentEncoding and Response.ContentType.

Something like the code below where dg is a DataGrid control.

Response.Clear()
Response.ContentType = "application/vnd.ms-excel"
Response.ContentEncoding = System.Text.Encoding.UTF8
dg.DataSource = objDR
dg.DataBind()
dg.RenderControl(hw)
strTW = tw.ToString()
Response.Write(strTW)
Response.Flush()
Response.Close()

Everything works fine and the query output generates in Excel, but I
get this icky white background in all of the cells on the sheet. Is
there a way to retain the Excel regular, transparent background?
 
You can create a <table> tag to format the output. Excel will interpret
whatever you put it in.
 
Back
Top