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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Gridview to Excel Carriage Return

Status
Not open for further replies.

schwarem

Programmer
Apr 18, 2002
159
US
I am exporting a gridview to Excel using the code below. One of the columns contains line breaks. How do I export those line breaks to Excel? When I run the code each line break creates a new row.

Code:
            If gvResults.Rows.Count > 0 Then
                gvResults.AllowPaging = False
                gvResults.AllowSorting = False
                gvResults.Columns(0).Visible = False
                gvResults.Columns(13).Visible = True
                PopulateSearch("DateEntered DESC")
                PopulateResponseJustification()
                Dim Style As String = "<style>.text { mso-number-format:\@; } </style>"
                Dim tw As New StringWriter()
                Dim hw As New System.Web.UI.HtmlTextWriter(tw)
                Dim frm As HtmlForm = New HtmlForm()
                Response.ContentType = "application/vnd.ms-excel"
                Response.AddHeader("content-disposition", "attachment;filename=Export.xls")
                Response.Charset = ""
                EnableViewState = False
                Controls.Add(frm)
                frm.Controls.Add(gvResults)
                frm.RenderControl(hw)
                Response.Write(style)
                Response.Write(tw.ToString())
                Response.End()

                gvResults.AllowPaging = True
                gvResults.AllowSorting = True
                gvResults.Columns(0).Visible = True
                gvResults.Columns(13).Visible = False
                PopulateSearch("DateEntered DESC")
            End If
 
You could try replacing line breaks with their HTML equivilant


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
See the post I made in your previous thread (thread855-1321862) for an example.

As a side note, I notice that although you have asked a few questions on the forums here, you haven't marked any of the answers as valuable, and I can only see one or two acknowledgements of other peoples responses. If you are not getting the answers that you need read FAQ222-2244 to see how to ask better questions. If you are getting the answers you need see FAQ222-2244 to see how to acknowledge the answers given.

Paragraph 16 of the FAQ explains about this being a two-way forum, to give guidance on answering other peoples questions, as I also notice that you haven't yet made any posts in other peoples threads.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
The line breaks are currently <BR> if you use the HTML.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top