[C#] Can anyone point me in the direction of an ASCII table formatter?

Started by
1 comment, last by Spa8nky 12 years, 3 months ago
I'm after an ASCII table formatter in a similar vein to this one: http://cxc.harvard.e...dule-asciitable

I'm looking to automatically generate tables using ASCII characters to produce something similar to the following:


| Column 1 | Column 2 | Column 3 |
=====================================
|FM-8 | 1981-05 | M68A09 @ 1MHz |
|FM-7 | 1982-11 | M68B09 @ 2MHz |


The '|' should line up and auto size depending on the number of characters in each cell.

Any ideas?

Thank you.
Advertisement
Well it should be pretty simple, first establish the correct width of each column by iterating over all data lines, and place the separators | accordingly. Then replace the spaces in between by the proper data texts. The === line can then be inserted easily.

“If I understand the standard right it is legal and safe to do this but the resulting value could be anything.”

Good call, I've rolled my own.

Would have liked to seen other examples but I've created one in 79 lines that works well so I'm happy.

This topic is closed to new replies.

Advertisement