Search code examples
c#.netcrystal-reportsreportplaintext

crystal report print plain text in columns


I have a report in crystal report that shows a list of addresses taken from a db and formatted as follows:

`<some codes regarding object to send>
<Name> <Surname>
<Address>
<zip> <City>
<other informations>`

I need to print those addresses in 3 or 4 columns (according user choice) in plain text. With PDF Report there is no problem, but if i set as plain text it shows only one column. Can you help me? Thanks and regards


Solution

  • I will not change the first answer because maybe it can be useful for someone else.

    Here is a very boring new solution, if you do not come up with a better idea. I will write for 3 columns. You will need to adapt for 4 columns (or just create another rpt for 4 columns).

    1. Forget the "format with multiple columns" option. Just create a normal detail section.

    2. Create the following boring formula. Let's call it as "fieldsFiller":

        shared stringvar address1;
        shared stringvar address2;
        shared stringvar address3;
        shared stringvar name1;
        shared stringvar name2;
        shared stringvar name3;
        shared stringvar surname1;
        shared stringvar surname2;
        shared stringvar surname3;
        shared stringvar zip1;
        shared stringvar zip2;
        shared stringvar zip3;
        shared stringvar city1;
        shared stringvar city2;
        shared stringvar city3;
        //TODO do the same for the others fields you need
    
        if recordnumber mod 3 = 1 then (
            address1 := {YourDataSource.Address};
            name1 := {YourDataSource.Name};
            surname1 := {YourDataSource.Surname};
            zip1 := {YourDataSource.Zip};
            city1 := {YourDataSource.City};
            //TODO do the same for the others fields you need
        )
        else if recordnumber mod 3 = 2 then (
            address2 := {YourDataSource.Address};
            name2 := {YourDataSource.Name};
            surname2 := {YourDataSource.Surname};
            zip2 := {YourDataSource.Zip};
            city2 := {YourDataSource.City};
            //TODO do the same for the others fields you need
        )
        else if recordnumber mod 3 = 0 then (
            address3 := {YourDataSource.Address};
            name3 := {YourDataSource.Name};
            surname3 := {YourDataSource.Surname};
            zip3 := {YourDataSource.Zip};
            city3 := {YourDataSource.City};
            //TODO do the same for the others fields you need
        )
    
    1. Put the "fieldsFiller" formula in details section and suppress it.
    2. Use section expert on detail section to suppress it according to the following formula:
      recordnumber mod 3 > 0
    
    1. This will be too boring... Create one formula for each shared variable you declared in "fieldsFiller" formula. For example, create a formula named "address1" with this content:
      shared stringvar address1;
      address1;
    
    1. Put the formulas in the details section. Put them as fields, side by side.
    name1 surname1   name2 surname2     name3 surname3
    address1         address2           address3
    zip1 city1       zip2 city2         zip3 city3
    
    1. Give it a try.