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
都可以考虑
}
具体我也不知道怎么办,但给你个思路吧。方法一:
1.找个pdf控件/引擎,打开pdf,将其内容读至字符串(或临时文件)中。
2.找个xml控件/引擎,保存刚才的字符串(或打开临时文件并保存)为xml。
PS:网上有人用福企阅读器的pdf引擎成功打开pdf,而且好像可以另存为,至于什么格式就不知道了。但应该不是xml格式。
方法二:
利用Windows API,或二进制读取文件等方法,不引用任何控件/引擎,即可达到效果。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)