?? exportcontactstocvs.cs
字號:
?namespace Imps.Client.Pc
{
using System;
using System.IO;
using System.Text;
using System.Windows.Forms;
using System.Xml;
internal class ExportContactsToCVS : IExportContacts
{
public void ExportContacts(IWin32Window owner, string filePath, string xmlContacts)
{
XmlDocument document = new XmlDocument();
document.LoadXml(xmlContacts);
if (document.DocumentElement.ChildNodes.Count != 0)
{
StringBuilder builder = new StringBuilder();
for (int i = 0; i < document.DocumentElement.ChildNodes[0].ChildNodes.Count; i++)
{
builder.Append(string.Format("\"{0}\"", document.DocumentElement.ChildNodes[0].ChildNodes[i].Name));
if (i != (document.DocumentElement.ChildNodes[0].ChildNodes.Count - 1))
{
builder.Append(",");
}
else
{
builder.Append("\r\n");
}
}
foreach (XmlNode node in document.DocumentElement.ChildNodes)
{
for (int j = 0; j < node.ChildNodes.Count; j++)
{
builder.Append(string.Format("\"{0}\"", node.ChildNodes[j].InnerText));
if ((node.ChildNodes.Count - 1) != j)
{
builder.Append(",");
}
else
{
builder.Append("\r\n");
}
}
}
using (StreamWriter writer = new StreamWriter(filePath, false, ImportExportManager.FileEncoding))
{
writer.Write(builder.ToString());
}
}
}
public string Filter
{
get
{
return "csv files (*.csv)|*.csv";
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -