将数据、架构和相关表导出为 XML
ExportXML 方法可用于导出表中包含的数据和格式设置,以及指定的任何其他数据。
若要指定要导出的其他数据,必须使用 CreateAdditionalData 方法创建 AdditionalData 对象。 然后,使用 Add 方法添加要随主表一起导出的其他表。
以下过程说明如何在将表导出为 XML 时包括其他数据。 “订单”表随若干其他表一起导出。 架构和格式也分别导出为单独的 .xsd 和 .xsl 文件。
Private Sub ExportRelTables()
' Purpose: Exports the Orders table as well as
' a number of related databases to an XML file.
' XSD and XSL files are also created.
Dim objAD As AdditionalData
' Create the AdditionalData object.
Set objAD = Application.CreateAdditionalData
' Add the related tables to the object.
With objAD
.Add "Order Details"
objAD(Item:="Order Details").Add "Order Details Details"
.Add "Customers"
.Add "Shippers"
.Add "Employees"
.Add "Products"
objAD(Item:="Products").Add "Product Details"
objAD(Item:="Products")(Item:="Product Details").Add _
"Product Details Details"
.Add "Suppliers"
.Add "Categories"
End With
' Export the Orders table along with the additional data.
Application.ExportXml acExportTable, "Orders", _
"C:\Orders.xml", "C:\OrdersSchema.xsd", _
"C:\OrdersStyle.xsl", AdditionalData:= objAD
End Sub
支持和反馈
有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈