VBA将Excel导出为XML
时间:2022-03-10 11:23:50
以下代码的功能,是配合select,将Excel导出为XML文件。
Const stSQL As String = "SELECT * FROM [Report]"
Dim stCon As String
stCon = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & ThisWorkbook.FullName & ";" & _
"Extended Properties=""Excel 8.0;HDR=Yes"";"
Dim rst As New ADODB.Recordset
Dim str As New ADODB.Stream
With rst
.CursorLocation = adUseClient
.Open stSQL, stCon, adOpenStatic, adLockReadOnly, adCmdText
.Save str, adPersistXML
.Close
With str
.SaveToFile "C:dzwebs.xml", adSaveCreateOverWrite
.Close
End With
End With
Set str = Nothing
Set rst = Nothing
注意,要使用如上的代码,需要添加MS ADO Library引用。
标签:VBA将Excel导出为XML
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Onenote表格单元格怎么合并? Onenote合并单元格技巧
2023-06-05 21:53:34
![](https://img.aspxhome.com/file/2023/8/15068_0s.png)
excel2010怎么插入剪贴画
2022-04-17 11:53:04
![](https://img.aspxhome.com/file/2023/1/38581_0s.jpg)
Excel显示"隐私问题警告"该怎么办?
2023-09-27 22:27:48
![](https://img.aspxhome.com/file/2023/5/36495_0s.jpg)
如何快速解决电脑word文档无法打开问题
2023-12-07 18:33:14
![](https://img.aspxhome.com/file/2023/3/19933_0s.jpg)
Excel不显示网格线.更改网格线颜色.打印网格线的方法介绍
2023-12-02 10:31:45
![](https://img.aspxhome.com/file/2023/1/38401_0s.jpg)
如何更改word文档中的文本格式
2022-05-07 07:05:49
![](https://img.aspxhome.com/file/2023/4/32924_0s.jpg)
word怎么把图片插入到图形中?
2023-02-09 19:51:06
![](https://img.aspxhome.com/file/2023/3/28963_0s.jpg)
Word中标准格式分数的三种输入方法
2022-04-25 17:20:40
如何在Word 2007中插入页码
2023-01-12 15:27:46
![](https://img.aspxhome.com/file/2023/1/23761_0s.jpg)
word 中邮件合并功能的用法详解
2023-01-31 16:04:13
![](https://img.aspxhome.com/file/2023/7/32647_0s.jpg)
Excel如何将数字设为文本格式
2022-05-12 01:28:07
![](https://img.aspxhome.com/file/2023/6/37146_0s.png)
iOS 13.6.1 续航测试,相比老版本略有下滑
2023-11-03 06:50:35
![](https://img.aspxhome.com/file/2023/2/a194682_0s.jpg)
建议升级iOS 14Beta 5吗?iOS 14Beta 5升级方法
2023-11-14 09:37:19
![](https://img.aspxhome.com/file/2023/7/a194677_0s.png)
win10字体安装后怎么使用
2023-11-10 18:10:42
![](https://img.aspxhome.com/file/2023/4/48274_0s.jpg)
win10如何修复系统引导文件?win10修复系统引导文件方法
2023-11-05 21:56:56
![](https://img.aspxhome.com/file/2023/7/47687_0s.png)
Win10专业版声音提示音频服务未响应怎么办
2023-11-20 19:58:39
![](https://img.aspxhome.com/file/2023/6/49826_0s.jpg)
怎样对word表格的数据进行求和
2022-03-21 15:52:53
Excel表格怎么改变数据的排列方式操作教学分享
2023-10-16 23:50:51
![](https://img.aspxhome.com/file/2023/9/16059_0s.png)
Win10无法启动Windows Audio服务错误1068怎么办?
2023-12-14 12:55:37
![](https://img.aspxhome.com/file/2023/6/51746_0s.png)
Word文档怎么设置文字发光效果
2022-04-30 03:06:11
![](https://img.aspxhome.com/file/2023/7/32057_0s.png)