Skip to Content
0
Former Member
Nov 02, 2009 at 08:52 AM

Exporting to Text with fixed field length

244 Views

Hi,

I am using Crystal reports version 10.0. I have a requirement where I need to export data to a Text file. There are 19 fields & the fields were given fixed length.

I have used the following formula to fix the length of the fields,

FOR EXAMPLE - For SSN field

NumberVar RequiredLength:= 9;
NumberVar CurrentLength:= Length (TOTEXT ({ACNT.SSN}));
(IF RequiredLength < CurrentLength
THEN TOTEXT (Replace({Payroll.SSN},'-','')) [1 TO RequiredLength]
ELSE ReplicateString (" ",RequiredLength - CurrentLength) + TOTEXT (Replace({Payroll.SSN},'-','')))

I have a blank field next to SSN so I have used,

ReplicateString (" ",10)

similarly the third field has the formula,

NumberVar RequiredLength:= 9;
NumberVar CurrentLength:= Length (TOTEXT({@Tax}));
(IF RequiredLength < CurrentLength
THEN TOTEXT ({@Tax}) [1 TO RequiredLength]
ELSE ReplicateString (" ",RequiredLength - CurrentLength) + TOTEXT ({@Tax}))

When I export it to excel, I am getting exactly what I want. The fields were assigned the length which I have set. However, when I export it to a text file it does not fits. I am really wondering why it is not coming up when exported to text file.

can some one help me out in solving this issue?

Regards,

karthik