Sometime we will need the excel data to be converted to properly formatted text.
This happens mainly if you are working in mainframe, where we might need to convert a excel file into text and upload it for file processing.
We could copy-paste the excel document on to a notepad. However the formatting will be off. We might actually need the data is specific format and each data element might be having predefined format and length.
Here is the formula sample that you could use for formatting the columns
So to format the first row you could us the following formula
=LEFT(A1&REPT(" ",10),10)&RIGHT(REPT("0",5)&B1,5)&" "&LEFT(C1&REPT(" ",20),20)&" "&TEXT(D1,"YYYYMMDD")
Notes
LEFT function allows you to extract a substring from a string, starting from the left-most character
RIGHT function allows you to extract a substring from a string, starting from the right-most character
REPT function returns a repeated text value a specified number of times
TEXT function returns a value converted to text with a specified format.
This happens mainly if you are working in mainframe, where we might need to convert a excel file into text and upload it for file processing.
We could copy-paste the excel document on to a notepad. However the formatting will be off. We might actually need the data is specific format and each data element might be having predefined format and length.
Here is the formula sample that you could use for formatting the columns
| Column | Format | Length |
| A | Text | 10 |
| B | Number with leading zeroes | 5 |
| C | Text | 20 |
| D | Date in YYYYMMDD format | 8 |
So to format the first row you could us the following formula
=LEFT(A1&REPT(" ",10),10)&RIGHT(REPT("0",5)&B1,5)&" "&LEFT(C1&REPT(" ",20),20)&" "&TEXT(D1,"YYYYMMDD")
Notes
LEFT function allows you to extract a substring from a string, starting from the left-most character
RIGHT function allows you to extract a substring from a string, starting from the right-most character
REPT function returns a repeated text value a specified number of times
TEXT function returns a value converted to text with a specified format.
