开发者

string builder appendline tab but equal spacing

I am using mail merge and displays Name, Phone and fax column through stringbuilder append line with tab. It is working well. But the prob is when the length开发者_高级运维 of Name is diff from other rows, it has diff spacing.

it looks like the upper pic but I need it to look like the lower pic :

click this for pic

Is there a way I can make them equal no matter what the length of each row's name is? I know one solution is to separate the phone and fax and declare them as another column but is there a way without doing that? any formatting I need to do? thanks.

foreach (var item in _list)
            {
                List.Append(item.FullNameDF + "\t" + "\t" + "\t" + "\n");
                List.Append(item.Add1 + "\t" + "\t" + "\t" + "\n");
                List.Append((!string.IsNullOrEmpty(item.HomePhone) ? String.Format("{0:(000)000-000}", Convert.ToInt64(item.HomePhone)) : string.Empty) + "\t" + "\t" + "\t" + "\n");

                             }


Please use tables in situations like this.

List.Append("<table>");
foreach (var item in _list)
{
    string phone = !string.IsNullOrEmpty(item.HomePhone) ? String.Format("{0:(000)000-000}", Convert.ToInt64(item.HomePhone)) : string.Empty;
    List.Append(String.Format("<tr><td>{0}</td><td>{1}</td><td>{2}</td></tr>",item.FullNameDF, item.Add1 ,phone);
}
List.Append("</table>");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜