cancel
Showing results for 
Search instead for 
Did you mean: 

Crystal Reports 10 - Export to TEXT with Delimited Space Format

Former Member
0 Kudos

Hello,

I am new to Crystal reports, sorry if this is a really basic question. I am trying to create a report which I can export to a TXT file. The TXT file format will be delimted space (size 500 characters). I would like to know how I can use Crystal reports to fix the size of the fields.

For example field 1 is 22 characters, field 2 starts directly after field 1 and is 9 characters (9 spaces), field 3 is then 7 characters so an example of the output I need is:

1111111111111111111111 2222222

I will need to use a mixture of TEXT fields and database fields to create the report. Thefore is it possible to specify the length of a text file i.e. TEXT1 = 22?

I am new to Crystal so I hope there is a simple solution without the use of coding

Thanks,

Brett

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Anybody have any ideas?

0 Kudos

Hello,

Look in Crystal Reports Help file in the Formula expert. There are all sorts of StringLength, replaceString etc. features you can use.

Thank you

Don

Former Member
0 Kudos

You will have to force the fields to the length that you are looking for, as Crystal treats strings as variable length strings. So to force a character field to 20 characters, you'd do something like:


left({db.charfield} + ReplicateString(" ", 20), 20)

For a number, you could use either


ToText({db.numfield}, "0000000000")

or


right(ReplicateString(" ", 10) + ToText({db.numfield}, "0"), 10)

(for a 10 digit integer; change the format string in ToText for other numeric data types)

I suggest that it may be clearer and more accurate to create one formula field with the entire line formatted as needed, then just display that one field on the report.

HTH,

Carl

Answers (2)

Answers (2)

Former Member
0 Kudos

I think that what you need to do is to use a font which is fixed-width(monospaced) like 'Courier New'.

Then you specify the font size (which is its height in point (an inch has 72 points)...

And when you do your 'Export to Text', you must specify the font's width (characters by inch) which could be something like 12 characters by inch, which equals to 6 points per character.

With these information known, you can create your design and using the right field size to have the number of desired characters.

Example: if you need 24 characters, the the field must be 2 inches width...

Former Member
0 Kudos

Moving this to the Design forum

Regards,

Jonathan