By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,870 Members | 1,212 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,870 IT Pros & Developers. It's quick & easy.

Using line breaks in text

P: n/a
We have VS2005 ASP.NET 2.0 application that needs to have each paragraph
separated by a line break. I have added "<br />" into the text column (SQL
2000) and it works fine when displaying on a web page (GridView). However,
when I export the to Excel it creates separate rows for each line break, but
I don't want that. Does anyone have a solution? Thanks.

David
Oct 18 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
You could simply do a replace on the text field to replace the linebreak
with either nothing, or a carriage return. I forget which delimiter Excel
will interpret as the need for a new row so you may have to experiment. You
could do something like .Replace("<br />","") to replace it with nothing
(this is of course used when pulling the data from the database. If you
can't do it at this stage, ie: if you're binding directly to a datareader,
you could have SQL Server do the replacement for you before it gets passed
out to the reader. If I remember correclty, SQL Server does have string
replacement functions.

--
Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006

"David" <dl*****@lifetimeinc.comwrote in message
news:Oe**************@TK2MSFTNGP04.phx.gbl...
We have VS2005 ASP.NET 2.0 application that needs to have each paragraph
separated by a line break. I have added "<br />" into the text column
(SQL 2000) and it works fine when displaying on a web page (GridView).
However, when I export the to Excel it creates separate rows for each line
break, but I don't want that. Does anyone have a solution? Thanks.

David

Oct 18 '06 #2

P: n/a
Leave the original Line breaks in the database. These are not really part of
the text (data), but part of the UI-specific formatting. Your ASP.Net app
should replace these with "<br />" during execution.

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Shooter
http://unclechutney.blogspot.com

A man, a plan, a canal, a palindrome that has.. oh, never mind.

"David" <dl*****@lifetimeinc.comwrote in message
news:Oe**************@TK2MSFTNGP04.phx.gbl...
We have VS2005 ASP.NET 2.0 application that needs to have each paragraph
separated by a line break. I have added "<br />" into the text column
(SQL 2000) and it works fine when displaying on a web page (GridView).
However, when I export the to Excel it creates separate rows for each line
break, but I don't want that. Does anyone have a solution? Thanks.

David

Oct 18 '06 #3

P: n/a
You are a genius! I just put code into RowDataBound and did the replacement
when sending to Excel. It seems to work fine and with the "<br />" still in
there, the web pages show what I want. The only downside is that the Excel
field does not have line breaks. Below is my VB code doing the replace.
Does it look ok to you?

strnote = strnote.Replace("<br />", vbCrLf)

David

"Kevin Spencer" <sp**@uce.govwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
Leave the original Line breaks in the database. These are not really part
of the text (data), but part of the UI-specific formatting. Your ASP.Net
app should replace these with "<br />" during execution.

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Shooter
http://unclechutney.blogspot.com

A man, a plan, a canal, a palindrome that has.. oh, never mind.

"David" <dl*****@lifetimeinc.comwrote in message
news:Oe**************@TK2MSFTNGP04.phx.gbl...
>We have VS2005 ASP.NET 2.0 application that needs to have each paragraph
separated by a line break. I have added "<br />" into the text column
(SQL 2000) and it works fine when displaying on a web page (GridView).
However, when I export the to Excel it creates separate rows for each
line break, but I don't want that. Does anyone have a solution? Thanks.

David


Oct 18 '06 #4

P: n/a
Looks fine to me, David. Except that I would simply store the native data
(no HTML markup) in the database. This way, the data is not linked in any
way to any user interface, and it is the responsibility of the interface to
do any transforming.

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Shooter
http://unclechutney.blogspot.com

A man, a plan, a canal, a palindrome that has.. oh, never mind.

"David" <dl*****@lifetimeinc.comwrote in message
news:uM**************@TK2MSFTNGP04.phx.gbl...
You are a genius! I just put code into RowDataBound and did the
replacement when sending to Excel. It seems to work fine and with the
"<br />" still in there, the web pages show what I want. The only
downside is that the Excel field does not have line breaks. Below is my
VB code doing the replace. Does it look ok to you?

strnote = strnote.Replace("<br />", vbCrLf)

David

"Kevin Spencer" <sp**@uce.govwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>Leave the original Line breaks in the database. These are not really part
of the text (data), but part of the UI-specific formatting. Your ASP.Net
app should replace these with "<br />" during execution.

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Shooter
http://unclechutney.blogspot.com

A man, a plan, a canal, a palindrome that has.. oh, never mind.

"David" <dl*****@lifetimeinc.comwrote in message
news:Oe**************@TK2MSFTNGP04.phx.gbl...
>>We have VS2005 ASP.NET 2.0 application that needs to have each paragraph
separated by a line break. I have added "<br />" into the text column
(SQL 2000) and it works fine when displaying on a web page (GridView).
However, when I export the to Excel it creates separate rows for each
line break, but I don't want that. Does anyone have a solution? Thanks.

David



Oct 18 '06 #5

P: n/a
Kevin,
Good point. What exactly would you store in the database to represent CrLf?
Thanks.
David
"Kevin Spencer" <sp**@uce.govwrote in message
news:OC**************@TK2MSFTNGP02.phx.gbl...
Looks fine to me, David. Except that I would simply store the native data
(no HTML markup) in the database. This way, the data is not linked in any
way to any user interface, and it is the responsibility of the interface
to do any transforming.

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Shooter
http://unclechutney.blogspot.com

A man, a plan, a canal, a palindrome that has.. oh, never mind.

"David" <dl*****@lifetimeinc.comwrote in message
news:uM**************@TK2MSFTNGP04.phx.gbl...
>You are a genius! I just put code into RowDataBound and did the
replacement when sending to Excel. It seems to work fine and with the
"<br />" still in there, the web pages show what I want. The only
downside is that the Excel field does not have line breaks. Below is my
VB code doing the replace. Does it look ok to you?

strnote = strnote.Replace("<br />", vbCrLf)

David

"Kevin Spencer" <sp**@uce.govwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>>Leave the original Line breaks in the database. These are not really
part of the text (data), but part of the UI-specific formatting. Your
ASP.Net app should replace these with "<br />" during execution.

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Shooter
http://unclechutney.blogspot.com

A man, a plan, a canal, a palindrome that has.. oh, never mind.

"David" <dl*****@lifetimeinc.comwrote in message
news:Oe**************@TK2MSFTNGP04.phx.gbl...
We have VS2005 ASP.NET 2.0 application that needs to have each
paragraph separated by a line break. I have added "<br />" into the
text column (SQL 2000) and it works fine when displaying on a web page
(GridView). However, when I export the to Excel it creates separate
rows for each line break, but I don't want that. Does anyone have a
solution? Thanks.

David



Oct 18 '06 #6

P: n/a
As he said earlier

Leave the original Line breaks (CrLf) in the database...

Your ASP.Net app should replace these with "<br />" during execution.

(You must code for this.)
David wrote:
Kevin,
Good point. What exactly would you store in the database to represent CrLf?
Thanks.
David
"Kevin Spencer" <sp**@uce.govwrote in message
news:OC**************@TK2MSFTNGP02.phx.gbl...
Looks fine to me, David. Except that I would simply store the native data
(no HTML markup) in the database. This way, the data is not linked in any
way to any user interface, and it is the responsibility of the interface
to do any transforming.

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Shooter
http://unclechutney.blogspot.com

A man, a plan, a canal, a palindrome that has.. oh, never mind.

"David" <dl*****@lifetimeinc.comwrote in message
news:uM**************@TK2MSFTNGP04.phx.gbl...
You are a genius! I just put code into RowDataBound and did the
replacement when sending to Excel. It seems to work fine and with the
"<br />" still in there, the web pages show what I want. The only
downside is that the Excel field does not have line breaks. Below is my
VB code doing the replace. Does it look ok to you?

strnote = strnote.Replace("<br />", vbCrLf)

David

"Kevin Spencer" <sp**@uce.govwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
Leave the original Line breaks in the database. These are not really
part of the text (data), but part of the UI-specific formatting. Your
ASP.Net app should replace these with "<br />" during execution.

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Shooter
http://unclechutney.blogspot.com

A man, a plan, a canal, a palindrome that has.. oh, never mind.

"David" <dl*****@lifetimeinc.comwrote in message
news:Oe**************@TK2MSFTNGP04.phx.gbl...
We have VS2005 ASP.NET 2.0 application that needs to have each
paragraph separated by a line break. I have added "<br />" into the
text column (SQL 2000) and it works fine when displaying on a web page
(GridView). However, when I export the to Excel it creates separate
rows for each line break, but I don't want that. Does anyone have a
solution? Thanks.

David


Oct 19 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.