在为自己编写一个小型C#应用程序时,我意识到如果我可以轻松地在textmode中绘制表格,它会很简洁.你知道,像这样:
+-----------------+-----------------+
| Header 1 | Header 2 |
+--------+--------+--------+--------+
| Data 1 | Data 2 | Data 3 | Data 4 |
| Data 1 | Data 2 | Data 3 | Data 4 |
| Data 1 | Data 2 | Data 3 | Data 4 |
+--------+--------+--------+--------+
Run Code Online (Sandbox Code Playgroud)
快速的谷歌搜索没有透露任何信息.有没有这样的现成品,或者我应该推出自己的?
补充:理想版本支持:
但我也会满足于少.:)
这是您正在寻找的 http://www.phpguru.org/static/ConsoleTable.html 或 http://www.phpguru.org/downloads/csharp/ConsoleTable/ConsoleTable.cs
ConsoleTable table = new ConsoleTable();
table.AppendRow(new string[] {"foo", "bar", "jello"});
table.AppendRow(new string[] {"foo", "bar", "jello"});
table.AppendRow(new string[] {"foo", "bar", "jello"});
table.AppendRow(new string[] {"foo", "bar", "jello"});
table.SetHeaders(new string[] {"First Column", "Second Column", "Third Column"});
table.SetFooters(new string[] {"Yabba"});
table.InsertRow(new string[] {"", "ferfr", "frf r"}, 7);
table.PrependRow(new string[] {});
System.Console.Write(table.ToString());
Produces...
+--------------+---------------+--------------+
| First Column | Second Column | Third Column |
+--------------+---------------+--------------+
| | | |
| foo | bar | jello |
| foo | bar | jello |
| foo | bar | jello |
| foo | bar | jello |
| | | |
| | | |
| | | |
| | ferfr | frf r |
+--------------+---------------+--------------+
| Yabba | | |
+--------------+---------------+--------------+
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
615 次 |
| 最近记录: |