ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now!
  #1  
Old February 3rd, 2004, 03:58 AM
aldo_valerio aldo_valerio is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 3 aldo_valerio User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question HTML <BR> Generates Multiple Rows in Excel

CF v5, Excel 2000. I'm generating Excel output using the Internet Explorer Excel add-in. I create an HTML table and use the <CFCONTENT TYPE="application/vnd.ms-excel"> tag. My output is mainly text, retrieved from SQL Server, with embedded carriage returns+line feeds (ascii 13+10). I use REPLACE to convert ascii 13+10 to an HTML <BR> tag: #Replace("#getSelection.Supplier_Address#","#CRLF#","<br>","ALL")#. If I view my output in straight HTML, it displays multiple lines (separated by <BR>) within one <TD> cell. When I add my CFCONTENT tag to generate Excel, it displays a separate row for each <BR>, and thus separate cells. I would like to have the carriage returns embedded in my text in a single cell, like in the HTML output. Anyone know how to do this with just straight CF and Excel; no 3rd party add-ins? I've thought of a solution with a CSV file (not tested yet) but I'm using some style properties such as colors, which would be lost if I generated a text file first.

Reply With Quote
  #2  
Old February 3rd, 2004, 08:43 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,627 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 8 m 55 sec
Reputation Power: 53
What about only doing the translation of CRLF to BR when the user is looking at it as HTML, but leave it as CRLF when they look at it as Excel? Would that give you the line breaks within the cell?

Reply With Quote
  #3  
Old February 3rd, 2004, 11:18 AM
aldo_valerio aldo_valerio is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 3 aldo_valerio User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Leaving the CRLF as is, just wraps the text as if those characters had been replaced by nothing. It seems like it's parsed by HTML first, which would ignore those characters.
I also tried <PRE></PRE> without replacing the CRLF. The result is that it creates separate rows, the same as replacing the CRLF with <BR>; but it also removes the font and the wrap on the <TD>.

Reply With Quote
  #4  
Old February 3rd, 2004, 12:18 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,627 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 8 m 55 sec
Reputation Power: 53
If you make some dummy output by hand that has the <br> tag in it, does that also produce the extra rows? If it does, it may just be the way Excel handles the HTML.

Reply With Quote
  #5  
Old February 4th, 2004, 05:15 AM
aldo_valerio aldo_valerio is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 3 aldo_valerio User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I tried it, and as suspected, the HTML <BR> are converted to separate Excel rows. Thanks for your help.

Reply With Quote
  #6  
Old August 5th, 2004, 02:31 PM
devshed00192 devshed00192 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 3 devshed00192 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
how to replace a carriage return to spaces

Hi there,

can anyone help me? How do i replace a carriage return to a space. And then insert a <br> after a number of chars?

So i always have the same chars on a row?
If you can help me replace the returns to <br> i will already be happy.

thx, greetz

Reply With Quote
  #7  
Old August 5th, 2004, 03:47 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,627 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 8 m 55 sec
Reputation Power: 53
Just use the replace() or rereplace() functions to replace the carriage return/line feed characters with a <br>.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian.
How to Post a Question in the Forums

Reply With Quote
  #8  
Old August 6th, 2004, 03:02 PM
devshed00192 devshed00192 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 3 devshed00192 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
yes but how to do this in exel

read last post of mine pls....

Reply With Quote
  #9  
Old August 6th, 2004, 03:47 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,627 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 8 m 55 sec
Reputation Power: 53
Uh, I'm not sure what you want me to tell you. Are you expecting me to write this code for you?

Before you output whatever it is you are outputting to Excel, first use the replace() or REReplace() function to replace carriage return/line feed combinations with a <br> tag. I would start by looking up these functions in the documentation.

Reply With Quote
  #10  
Old August 6th, 2004, 03:51 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,627 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 8 m 55 sec
Reputation Power: 53
Since I'm feeling generous, I looked this up by googling "ascii codes" and then using that information to replace the carriage return/line feed combos with <br>.

#replace( myExcelOutputVariable, '#chr(13)##chr(10)#', '<br>', 'all' )#

I suppose what I am getting at is that I'm here to help, but usually I don't just spit out code to solve people's problems. I expect others to at least try to look up the relevant functions and try to solve the problem themselves.

Reply With Quote
  #11  
Old August 8th, 2004, 12:06 PM
devshed00192 devshed00192 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 3 devshed00192 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
ok

Youre both right but since i only am into php i only asked you for a code that look for carriage returns in excel and replaces them for <br>. When i a searching the web for hours, i didnt find it and that why i asked.

The problem in when i copy text into a excel cell, and export it then to a .sql file, the transformation is not right. When there is a carriage return in the excel file, the .sql makes a new record.

Now i have to edit the xls and BACKSPACE every line. Thats much work.
Therefor i asked. And now i still dont know how to do it?

Reply With Quote
  #12  
Old August 8th, 2004, 03:21 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,627 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 8 m 55 sec
Reputation Power: 53
Wait, are you saying that you are not generating an HTML table and then sending that to the user via the browser? Are you saying that ALL you have to work with is the actual Excel file itself? If so, this is the first time you stated that and it would probably have been a good thing to note when asking for help!

Since Excel files are binary files, you can't simply replace carriage return/line feed combos with <br>. You'll need to look into options that let you modify the compiled Excel file directly. You might look at Apache POI. However, in this case I won't be able to provide code for you as this will require a throrugh reading of the POI documentation.

There are other options out there but I think you'll need to assess them one at a time. If you type in "coldfusion excel" into Google that should give you a good start.

Reply With Quote
  #13  
Old October 11th, 2004, 07:23 AM
theusser theusser is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 2 theusser User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I have the original Problem and could not yet find a solution:

by writing html - Tabel to excel using "Content-Type", "application/vnd.ms-excel", all <br> are converted to new cells, e.g.

html:
<tr><td>
cell 1 line 1<br>
cell 1 line 2<br>
</td><tr>
<tr><td>
cell 2
</td></tr>

is translated to the following 3 (!) cells:

A1 -> cell 1 line 1
A2 -> cell 1 line 2
A3 -> cell 2

Any idea, how to replace the <br> into Linefeed?

Thomas

Reply With Quote
  #14  
Old October 11th, 2004, 08:00 AM
theusser theusser is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 2 theusser User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally Posted by theusser

html:
<tr><td>
cell 1 line 1<br>
cell 1 line 2<br>
</td><tr>
<tr><td>
cell 2
</td></tr>

is translated to the following 3 (!) cells:

A1 -> cell 1 line 1
A2 -> cell 1 line 2
A3 -> cell 2

Any idea, how to replace the <br> into Linefeed?

Thomas


The solution I found is to add into a stylesheet:

br {mso-data-placement:same-cell;}


(thanks to google and: http://weblogs.asp.net/michu/archive/2004/06/15/155851.aspx ...)

Thomas

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > HTML <BR> Generates Multiple Rows in Excel


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump