
-----------------------------------
asteffes
Mon Jul 17, 2006 8:12 am

Datagrid output to excel: only displays in white ...?
-----------------------------------
I am populating a datagrid and outputting it to excel. Everything worked well last night, but today excel only displays the content in font color white, which is impossible to see.

The data is all there but invisible. I am unable to change any type of properties within excel to have the font color change. I have tried changing every attribute on the datagrid that I can think of, and I have also outputted to just a plain generic auto-generate columns datagrid with the same effect.

When i change the response.type from excel to html the datagrid displays fine in black print.

Any tips on how to change this output would be great, we're trying to get this to go live today.

Thanks!


Here is my HTML Code





	
		TimeReport
		
		
		
		
		
	
	
		
			
		
	






Here is the VB code:

Private Sub Page_Load()
  Response.Clear()
            Response.ContentType = "application/vnd.ms-excel"
            Response.Charset = ""

            Dim dsExport As DataSet = getReportData(dateselect1, dateselect2)
            dataGrid.DataSource = dsExport
            dataGrid.DataBind()
          
         
    End Sub


    Private Function getReportData(ByVal d1 As Date, ByVal d2 As Date) As DataSet
        Dim strConnection As String
        Dim sqlCmd As SqlCommand
        Dim ds As New DataSet
        Dim da As SqlDataAdapter

        ' Dim sqlRetrieve As SqlCommand
        Dim sqlConn As SqlConnection
        Dim intTestCount As Integer
        Try

            'connection string from Web Config
            strConnection = ConfigurationSettings.AppSettings("ConnectionString")
            sqlConn = New SqlConnection(strConnection)
            sqlCmd = New SqlCommand("TimeTracker_ReportGenerate1", sqlConn)
            sqlCmd.CommandType = CommandType.StoredProcedure
                sqlCmd.Parameters.Add("@dtDateRange1", d1)
                sqlCmd.Parameters.Add("@dtDateRange2", d2)

            sqlConn.Open()

            da = New SqlDataAdapter(sqlCmd)
            da.Fill(ds)

        Catch ex As Exception
            Response.Write(ex.ToString & "")

        Finally
            sqlConn.Close()
        End Try

        Return (ds)

    End Function

