Click here to Skip to main content
15,889,281 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
how to write text in notepad in tabular format using c#

Customer Name Order Name Order ID Price
abc ABC ABC 5
def DEF DEF 10
ghi GHI GHI 15
Posted

This is nearly useless initiative, due to the common conventions of the presentation of the text files. If some file marked with tab characters ('\t') is aligned by the tab boundaries, adding some more characters by some of the cells in a columns will screw it up.

Another approach would be adding appropriate number of blank spaces, in assumption that all characters have the same width. This is quite possible and easy enough, but what's the use? You cannot demand that all text editors will use only the monospace font.

The whole idea is wrong. Text files and the customary ways of presenting them are not designed for such tricks, despite of many documents and applications trying to align those columns. If you need appropriate column alignment, use one of the following document formats: RTF, HTML or PDF. Note that those formats can be viewed on nearly all platforms.

—SA
 
Share this answer
 
Hi,

It will help you :http://msdn.microsoft.com/en-us/library/26etazsy.aspx[^]

But where you got stuck?
 
Share this answer
 
Comments
singh.ashish92 18-Jun-14 0:28am    
I want to write the above thing in tabular format in .txt file using c#,but while converting to .pdf the tabular format gets dissapeared and everything is conjusted
Sergey Alexandrovich Kryukov 18-Jun-14 1:34am    
You did not mentioned anything about conversion to PDF. Of course, in PDF aligned columns are quite possible, but you should not start with "aligned" text, it just makes no sense.
—SA
Sergey Alexandrovich Kryukov 18-Jun-14 1:30am    
Sorry, but this information has little to nothing to do with the OP's issue. Well, you can format it all by the position of each character in a row string, but who told you that all viewers will use monospace font? With '\t', the problems is different. This problem simply does not worth solving, as there is no a reliable solution, and cannot be.
—SA
Suvabrata Roy 18-Jun-14 1:56am    
But why down voted..
Sergey Alexandrovich Kryukov 18-Jun-14 2:33am    
Because this is how the voting system works: bad, misleading answers can be down-voted. After all, misleading an inquirer is much worse than not answering at all; we all should be responsible for our posts. I, too, from time to time receive down-votes and, in cases the comment convinces me, fix my bad post or remove it.

If you think that I made a mistake, please explain it and try to prove that you were right; in this case, I would admit my mistake, and fix it, with gratitude.

—SA
Hi,

It will help you-


http://stackoverflow.com/questions/9655376/write-contents-in-a-txt-file-in-a-tabular-order-using-c-sharp



Follow this link.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 18-Jun-14 1:32am    
Sorry, this not a solution at all. Who told you the referenced page will help to solve the problem?

Well, you can format it all by the position of each character in a row string, but who told you that all viewers will use monospace font? With '\t', the problems is different. This problem simply does not worth solving, as there is no a reliable solution, and cannot be.

—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900