Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataGrid export to msWord appears as Excel

Status
Not open for further replies.

LizKayl

Programmer
Mar 2, 2004
13
US
I have a query result being read into an Excel document, but the users want it in word as well. When I try to send it to word, it continues to open in Excel.

Code:
Sub DataGridToWord(output As DataGrid, response As HttpResponse)        'clean up the response.object
    response.ContentType = "application/msword"

    response.redirect("fileWord.aspx")   
    '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)

    'tell the datagrid to render itself to our htmltextwriter
    response.write (output.RenderControl(htmlWrite))
    
    'output the html
    Response.Write(stringWrite.ToString)
End Sub
 
Nevermind. I found the problem. There was a typo in the redirect field.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top