vb.net中怎么创建xml文件并写数据

vb.net中怎么创建xml文件并写数据,第1张

DataSet 和 DataTable都有现成的方法:WriteXml

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

都可以考虑

}

for i=1 to n'n为你需要读取的行数

vv=cells(i,n).value'用vv存取从表格的第i行第n列的内容

conver2xml(vv)'你的转换为xml的子过程

next i


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/tougao/12084289.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-20
下一篇2023-05-20

发表评论

登录后才能评论

评论列表(0条)

    保存