Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Many Columns Formatting Post Reply Post New Topic
Author Message
runner9037
Newbie
Newbie


Joined: 18 Dec 2012
Online Status: Offline
Posts: 3
Quote runner9037 Replybullet Topic: Many Columns Formatting
     Posted: 18 Dec 2012 at 9:55am

I don't know if this is possible, but I am formating a sub report with many columns. They don't fit across the entire subreport, and I am wondering if I can get the columns to wrap to the next row.  This is what I am looking for:

 
Customer ID    Order Number     Date Ordered    Price  
01                    Ord01                 1/1/2011           $400
02                    Ord02                 2/1/2011           $500
03                    Ord03                 2/1/2011           $400
04                    Ord04                 3/1/2011           $500
 
 
Customer ID    Material Ordered    Date Mat Ordered    Mat Price  
01                    Mat01                    1/10/2011                $10
02                    Mat02                    2/10/2011                $30
03                    Mat03                    2/10/2011                $40
04                    Mat04                    3/10/2011                $85
 
 
 
Customer ID    Country     Date Shipped    Manufacturing Cost
01                    USA           2/1/2011           $100
02                    USA           5/1/2011           $80
03                    UK             5/1/2011           $90
04                    UK             4/1/2011           $80
IP IP Logged
shanth
Groupie
Groupie


Joined: 06 Aug 2012
Location: United States
Online Status: Offline
Posts: 75
Quote shanth Replybullet Posted: 19 Dec 2012 at 4:48am
I dont think you can wrap them to next row in same sub-report, but you can create sub-reports for each block and place them in proper sections like Report Footers.
IP IP Logged
runner9037
Newbie
Newbie


Joined: 18 Dec 2012
Online Status: Offline
Posts: 3
Quote runner9037 Replybullet Posted: 19 Dec 2012 at 5:22pm

I almost have this figured out. In the details I have gather the values for each field and add them to an array for each field.

Example:
arrID:= ["C01", "C02", "C03", "C04"];
arrPrice:= ["400", "500", "400", "500"];
 
Then in the footer, I created a formula for each field. In the formula, I iterate through each element in the array and create a string with a line break in between each element. Then I dropped each formula in the footer, and it shows nice columns.
 
I do have another problem though. In some columns the value wraps to the next line, so that the rest of the column values do not liine up anymore.
 
Example:
Customer ID    Order Number          Date Ordered     Price  
C01                    Ord01,206           1/1/2011           $400
C02                    Ord02,992           2/1/2011           $500
C03                    Ord03,038,6        2/1/2011           $400
C04                    0489,9054           3/1/2011           $500
                         Ord04 
 
I tried to work around this by padding each field with spaces so that that the fields in each row have the same number of spaces and should theoretically wrap.
 
So in the example above, Order Number associated with ID C03 has a length of 20. I have padded ID, date, and price with with spaces and trimmed so that they have a length of 20.
 
Example: "C03"
tempID:=left("C03"+space(20),space(20))
tempID should show "C03                 "
 
Since the width is the same between fields, I would have thought that it would wrap the extraneous spaces to the next line, creating what would looke like a break. I envisioned this:
 
Customer ID    Order Number          Date Ordered     Price  
C01                    Ord01,206           1/1/2011           $400
C02                    Ord02,992           2/1/2011           $500
C03                    Ord03,038,6        2/1/2011           $400
                          0489,9054                     
C04                    Ord04                 3/1/2011            $500
 
Instead the it looks like Crystal is completely ignoring the spaces appended to each string. I have also looked at the length of the padded strings and they are correct. When I add an actual charater at the end of the blank spaces, it looks like there is only one space in between the original string and the additional character.
 
Example: "C03"
tempID:=left("C03"+space(20),space(20))+"v"
tempID should show "C03                  v"
but tempID is showing  "C03 v"
and crystal is showing that the length of tempID is 21, even though it appears to be 5.
 
How can I get Crystal to stop ignorning my blank spaces???
IP IP Logged
shanth
Groupie
Groupie


Joined: 06 Aug 2012
Location: United States
Online Status: Offline
Posts: 75
Quote shanth Replybullet Posted: 20 Dec 2012 at 5:57am
Your approach is interesting! But wondering how your formula is not throwing error:
tempID:=left("C03"+space(20),space(20))+"v"
because I guess, LEFT function syntax only allows number at bold(space(20))
So, I tried left("CO3"+space(20), 20)+"v", its showing space as expected.
IP IP Logged
DaBoujibo
Newbie
Newbie


Joined: 21 Feb 2012
Online Status: Offline
Posts: 28
Quote DaBoujibo Replybullet Posted: 20 Dec 2012 at 6:18am
Why would you not use the code below instead of a LEFT()? (I added the variable declaration type since I didn't see it above.)  For the "C03" you can replace that with your {Customer ID} field so it applies to everything if you want it for all customers.
 
StringVar tempID:="C03" & space(20) & "v";
 
Forgot to add...this is a concatenation which appears to be what you are doing rather than selecting the left characters.
 
LEFT() function works like this:
 
LEFT(StringHere,From position 1 to whatever number here);
 
Example:
LEFT(Daboujibo,4); returns "Dabo"
 
Just as a guess since I have never seen someone use the LEFT function the way you did, is that CR (and I could be wrong here) is reading all 20 of the spaces as 1 for the field display based on the way the function was structured.


Edited by DaBoujibo - 20 Dec 2012 at 6:22am
IP IP Logged
runner9037
Newbie
Newbie


Joined: 18 Dec 2012
Online Status: Offline
Posts: 3
Quote runner9037 Replybullet Posted: 20 Dec 2012 at 8:53am
Originally posted by shanth

Your approach is interesting! But wondering how your formula is not throwing error:
tempID:=left("C03"+space(20),space(20))+"v"
because I guess, LEFT function syntax only allows number at bold(space(20))
So, I tried left("CO3"+space(20), 20)+"v", its showing space as expected.
 
 
Sorry that was a mistype, left("CO3"+space(20), 20)+"v" is the correct syntax I was using. I am using left because I want the fields to be of the same length. 
 
What I am expecting is if the formula field on the report allows for 10 characters, and the ID is 20 characters long, those blank spaces should wrap to the next line so it looks like a line break.
 
The formula I am actually using for the ID field is:
 
//ssArrID is an array of all the IDs, generated in details section;
Shared StringVar array ssArrID;
//ssArrMaxSpace is an array of the length of the longest string for that row;
Shared NumberVar array ssArrMaxSpace;
Local NumberVar index:=1;
Local NumberVar lenArray:=Ubound(ssArrID)
Local NumberVar lnPadding;
Local StringVar lsDisplay;


While index<=lenArray do
(

//lnPadding is length this field should be;
    lnPadding:=ssArrMaxSpace[index];
//Build display string
    lsDisplay:=lsDisplay+left(ssArrID[index]+space(lnPadding),lnPadding)+chr(10);
index:=index+1;
);

lsDisplay

 
 


Edited by runner9037 - 20 Dec 2012 at 9:00am
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