How to Export Excel Data as a Fixed-Width Text File
Question details
The user needs a way to export Excel records into a text file where each field has a strictly defined, fixed character length using padding spaces.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Exporting structured data for systems that require non-delimited, fixed-width formatting, such as legacy systems or specific databases.
- Observed behavior
- The goal is to format text, numbers, dates, and mixed values with precise character counts, concatenating them for a proper fixed-width text file export without delimiters.
Ensure you know the exact character length requirements for each column of your data. It is highly recommended to duplicate your original dataset to a new sheet before applying padding formulas to prevent accidental data loss.
Use Excel Formulas to Pad and Concatenate Data for Fixed-Width Export
Use text manipulation formulas to add exact padding to each column, concatenate the results, and save the output as a simple text file.
By combining formulas such as LEFT, REPT, and TEXT, you can dynamically enforce character limits and add trailing or leading spaces based on your required field lengths.
Once the entire row is concatenated into a single cell, exporting it as a standard text document creates a perfect non-delimited fixed-width file.
Identify the required width for each field. For example, if Column A needs 10 characters, create a formula in a new column: =LEFT(A2&REPT(" ", 10), 10).
For numbers or dates, use the TEXT function first to ensure the format is retained, like =LEFT(TEXT(B2, "mm/dd/yyyy")&REPT(" ", 12), 12).
Combine the padded columns into a single master column using the & operator or the CONCAT function, e.g., =C2&D2&E2.
Copy the final concatenated column, paste it as values into a new, blank text document (such as Notepad), and save the file with a .txt extension.

Save As Formatted Text (Space delimited)
Adjust column widths visually and save directly using Excel's built-in PRN file format for a quick fixed-width output.
Easily Export Fixed-Width Text Files with WPS Spreadsheet
WPS Spreadsheet offers powerful text manipulation formulas and flexible export options, allowing you to pad, concatenate, and export exact fixed-width text files without the heavy processing overhead.
- 1. Open your dataset in WPS Spreadsheet: Launch WPS Office and open your workbook containing the data you need to format and export.
- 2. Apply padding formulas: Use the formula =LEFT(A2&REPT(" ", 10), 10) in a new column to guarantee a 10-character width for your text.
- 3. Concatenate the padded data: Combine your newly padded columns using the & symbol into one single output column.
- 4. Export to Text: Copy the concatenated column, open WPS Writer or Notepad, paste as unformatted text, and save your fixed-width .txt file.

Frequently Asked Questions
Why do numbers lose their formatting when concatenating for fixed-width text?
When formulas combine cells, underlying number or date values revert to their raw serial numbers. To preserve the visual format, wrap the cell reference in a TEXT function, such as TEXT(A1, "0.00"), before applying padding and concatenating.
Can I add leading zeros instead of spaces to numbers in a fixed-width export?
Yes. You can use the REPT function to add zeros or simply use the TEXT function. For example, TEXT(A2, "00000000") forces the number to be exactly 8 digits long, filling any empty space with leading zeros.
Is there a maximum character limit when exporting a fixed-width text file from Excel?
If you use the 'Save As Formatted Text (.prn)' method, Excel limits the output to 240 characters per row. Using the formula and concatenation method bypasses this limit, constrained only by the cell's maximum character limit of 32,767 characters.
How can I pad a string so it aligns to the right instead of the left?
To right-align text (padding spaces on the left), reverse the combination inside the RIGHT function: =RIGHT(REPT(" ", 10)&A2, 10). This adds spaces before the text and dynamically extracts the rightmost 10 characters.




