Here we provide a step by step example of how to convert a fixed width text file, say c:\input\flowers.txt, to an Excel file c:\output\Flowers.XLS. For the example, let's say we are given the format specification below:
Character Position |
Number of Characters |
Field |
Pad With |
Alignment |
1-6 |
6 |
Date |
Space |
Left |
7-18 |
12 |
Amount |
Space |
Left |
19-22 |
4 |
State |
Space |
Right |
23-52 |
30 |
Description |
Space |
Left |
53-82 |
30 |
Flower Type |
Space |
Left |
In summary we have 5 columns that are all padded with the space character and all but the 3rd column is left aligned. Follow these directions to accomplish this task:
Run 'Convert XLS' and set the Action To Do to Convert Files, and the Conversion Method to Use 'Convert XLS'.
Press F3 to display the fixed width profile editor.
Enter 1 for the Total Number of Columns, the click the Apply button.
Enter 30 for the Width, choose the [32] Space for the Pad With, and Left for the Alignment.
Enter 5 for the Total Number of Columns, the click the Apply button
Enter 6 for the width, then <enter>. Typing <enter> takes you to the next item.
Type 12<enter>4<enter> Note the last two columns already have the width of 30.
Click on the 3rd row in the grid and specify Right alignment. Double clicking the 3rd row is a quick way to toggle the alignment. We are done editing the profile.
At this point you may want to give a unique name to this profile, if so enter it in the Profile Name drop down list box.
Click the Save and Close button
Enter c:\input\Flowers.TXT for the Input File and c:\output\Flowers.XLS for the Output File. Be certain the Input File Type is what you want it to be, in our case, [21] Text (ASCII) Fixed Width (*.TXT). The Output File Type should be also be specified as *.XLS or *.XLSX.
Click Add, and then Convert.
In the future if you have a similar fixed width text profile required, you can skip steps 3-8 and simply select the profile from the list provided. Furthermore, you can save the program configuration know as a Conversion Job from the file menu to recall at a later time.
See also:
Conversion of Fixed Width Text Files
Using the Fixed Width Text Profile Editor
Step by Step Example: Converting from Excel to a Fixed Width Text File
Step by Step Example: Converting from a Fixed Width Text File to Excel