Formatting Exel using datagrid

moumona

New member
Joined
Aug 28, 2006
Messages
3
Programming Experience
Beginner
I want to format the output which is execel. I need to change the font style and back ground colors fo the first row. Can someone help me with this please?
I tried playing around with the data grid and data set but no results.

This is my code:

VB.NET:
Private Sub Convert(ByVal ds As DataSet, ByVal sParams As String, ByVal response As HttpResponse)
		'first let's clean up the response.object
		response.Clear()
		response.Charset = ""

		'set the response mime type for excel
		response.ContentType = "application/vnd.ms-excel"

		'output report title and search parameters
        response.Write("<table border='0' align='left'><tr><td style='color:white;text-align:center' colspan='12' bgColor='#3366FF'><b>classic Rpt</b></td></tr>")
        response.Write("<tr><td colspan='8'><b>" & sParams & "<b></td></tr></table><p>")

		'create a string writer
		Dim stringWrite As New System.IO.StringWriter()

		'create an htmltextwriter which uses the stringwriter
		Dim htmlWrite As New System.Web.UI.HtmlTextWriter(stringWrite)

		'instantiate a datagrid
        Dim dg As New DataGrid()
        
        'set the datagrid datasource to the dataset passed in
        dg.DataSource = ds.Tables(0)

        'bind the datagrid
        dg.DataBind()


        'tell the datagrid to render itself to our htmltextwriter
        dg.RenderControl(htmlWrite)

        'all that's left is to output the html
        response.Write(stringWrite.ToString)
        response.End()
    End Sub

Thnx in advance
 
Back
Top