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!

Line Breaks when Exporting to Word

Status
Not open for further replies.

woetech

Programmer
Mar 13, 2009
26
US
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 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):
Code:
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

Thanks for your help.

I'm here to help. :)
 
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. :)

I'm here to help. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top