Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Removing Character returns from data field Post Reply Post New Topic
Author Message
Baratier
Newbie
Newbie


Joined: 13 Apr 2012
Location: Ecuador
Online Status: Offline
Posts: 5
Quote Baratier Replybullet Topic: Removing Character returns from data field
     Posted: 19 Mar 2013 at 10:18am
Hi,
I searched the forums but I didn't find a solution that worked for my situation.
 
I have data field that has character returns entered randomly in the field. the report is meant to collect the data and export it as a CSV file. However the character returns are askewing the columns in the csv file.
 
I tried using the Replace (data_field, chrw(13), "")  function, When I open the exported CSV file, it still shows the field in two lines.
 
You assistance is appreciated.


Edited by Baratier - 19 Mar 2013 at 10:20am
IP IP Logged
iSing
Newbie
Newbie


Joined: 12 Mar 2013
Online Status: Offline
Posts: 22
Quote iSing Replybullet Posted: 20 Mar 2013 at 8:03pm
Hi
 
Weird, I've just used this as a reply somewhere else too
 
I had to split a text field into separate substrings as I needed to manipuplate each string separately.
Here's what I used (as I couldn't use an array). 
 
 
//1.  Split the string into substrings at each carriage return - each substring contains a single line of the original string. 
//2.  Only display the third substring, eg the third line of the original string
//3.  replace the line feed at the beginning of this substring with a blank character
//(otherwise detail appears on second line of field)
//4.  trim the left most character of the substring, so that it appears at the top of the field.
//Step 4 BEGIN - trim the leftmost character of the second substring you've created
ServiceRequest := trimleft (
//Step 3 BEGIN - replace the line feed at the beginning of the substring with a blank character
Replace (
//Step 1  BEGIN - If there are more than 3 carriage returns (eg 3 lines or more) split the string into substrings
if ubound(split({RFSStepPlusCost.strComments},Chr(13))) >= 3 then
//Step 2 BEGIN & END  - only display the third substring
split({RFSStepPlusCost.strComments},Chr(13))[3] else "not recorded"
//Step 1 end
//Step 3 end
, chr(10) ," " )
//Step 4 end
);
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 21 Mar 2013 at 9:32am

Actually, you will have to replace both chr(13) AND chr(10).  Generally, a "new line" is either Line Feed (chr(10)), which is usually seen in various flavors of Unix/Linux, or Carriaged Return/Line Feed (chr(13) + chr(10)) in Windows.  Crystal will interpret either as a "new line" when exporting to CSV.

 
-Dell
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum