in reply to Need help to convert excel file to text file

Often what is done is to generate HTML, then use a browser to look at the results.   Another way to do it is to generate a PDF.   Basically, in both cases you are pushing the work of “pretty printing” off to another application.

There is also a very limited ability to use \t tab-characters in certain forms of printed output.   These might be interpreted correctly (by whatever ultimately prints the file), to create a crude but effective form of formatting.

Quite seriously... maybe you should just let Excel do it.