1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Line Breaks when Exporting to Word

Discussion in 'C#' started by LittlBUGer, Dec 10, 2012.

  1. #1
    Hello,

    I've made a simple website for someone to use to be able to enter/update and review data in a database. I have everything working, even a printer friendly page and exporting to PDF without issue. It's the exporting to Word that's causing problems in only one area: when there's a multi-line Label with <br/> inserted for proper HTML formatting. I've scoured the internet and have tried many 'fixes' to no avail.

    I have a few labels filled with data from a database that was inserted with multi-line text from a textbox. Everything shows up fine, and like I said, it exports to the printer friendly page and to PDF fine with the proper line breaks/formatting. But Word refuses to see them. Any suggestions?

    Here's my code for my export function (VB.NET):
    
    Try
    	Response.Clear()
    	Response.Buffer = True
    	Response.AddHeader("content-disposition", "attachment;filename=" & fileName)
    	Response.ContentEncoding = System.Text.Encoding.UTF8
    	Response.ContentType = "application/ms-word"
    	Response.Charset = "UTF-8"
    	Response.BinaryWrite(System.Text.Encoding.UTF8.GetPreamble)
    	Dim oStringWriter As New StringWriter()
    	Dim oHtmlTextWriter As New HtmlTextWriter(oStringWriter)
    	'pnlDetails.RenderControl(oHtmlTextWriter)
    	'PrepareControlForExport(divDetails)
    	divDetails.RenderControl(oHtmlTextWriter)
    	Response.Output.Write(oStringWriter.ToString)
    	Response.Flush()
    Catch ex As Exception
    	lblErrors.Visible = True
    	Elmah.ErrorSignal.FromCurrentContext.Raise(ex)
    Finally
    	Response.End()
    End Try 
    
    Code (markup):
    Thanks for your help.
     
    LittlBUGer, Dec 10, 2012 IP
  2. LittlBUGer

    LittlBUGer Peon

    Messages:
    306
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Sorry all, never mind. It was my own dang fault. I've gotten so used to using LibreOffice on my own machine that I forget sometimes that it's not really Microsoft Office. I just found out that my exporting to Word is working fine as if the file is actually opened in MS Word, everything displays correctly. Strange that LibreOffice doesn't quite show it right, but oh well, it's 'fixed', for now. :)
     
    LittlBUGer, Dec 10, 2012 IP