DataSet 和 DataTable都有现成的方法:WriteXml
创新互联是一家专注于成都做网站、网站设计与策划设计,松桃网站建设哪家好?创新互联做网站,专注于网站建设十余年,网设计领域的专业建站公司;建站业务涵盖:松桃等地区。松桃做网站价格咨询:18982081108
DataTable tb = this.dataGridView1.DataSource as DataTable;
if(tb != null)
{
tb.WriteXml(@"C:\table.xml",true);
return;
}
DataView dv = this.dataGridView1.DataSource as DataView;
if(dv != null)
{
dv.Table.WriteXml(@"C:\table.xml",true);
return;
}
IList list = this.dataGridView1.DataSource as IList;
if(list != null)
{
//to do,如果是IList,就要你自己想办法导出了
//XmlDocument or XmlWriter都可以考虑
}
DataSet
和
DataTable
都有现成的方法:WriteXml
DataTable
tb
=
this.
dataGridView
1.DataSource
as
DataTable;
if(tb
!=
null)
{
tb.WriteXml(@"C:\table.xml",true);
return;
}
DataView
dv
=
this.dataGridView1.DataSource
as
DataView;
if(dv
!=
null)
{
dv.Table.WriteXml(@"C:\table.xml",true);
return;
}
IList
list
=
this.dataGridView1.DataSource
as
IList;
if(list
!=
null)
{
//to
do,如果是IList,就要你自己想办法导出了
//XmlDocument
or
XmlWriter
都可以考虑
}
Imports System.IO
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim f As New FileInfo("d:\doc.xml")
If f.Exists = False Then
f.Create()
f.Refresh()
End If
Dim s As String = ""
Dim sw As StreamWriter = f.CreateText()
s = "?xml version=""1.0"" encoding=""GB2312""?"
sw.WriteLine(s)
sw.WriteLine("doc")
sw.WriteLine(" assembly")
sw.WriteLine("userId34/userId")
sw.WriteLine("userName张三/userName")
sw.WriteLine("qxbz1/qxbz")
sw.WriteLine(" /assembly")
sw.WriteLine("/doc")
sw.Flush()
sw.Close()
Process.Start("d:\doc.xml")
End Sub
End Class
售后响应及时
7×24小时客服热线数据备份
更安全、更高效、更稳定价格公道精准
项目经理精准报价不弄虚作假合作无风险
重合同讲信誉,无效全额退款