导出工作簿中与 XML 地图关联的 XML 数据
Contents
[
Hide
]
导出链接到工作簿中的 XML 映射的 XML 数据
请使用工作簿内链接到 XML 地图的 XML 数据导出的 Workbook.ExportXml() 方法。以下示例代码逐个导出工作簿中所有 XML 地图的 XML 数据。请查看本代码中使用的 示例 Excel 文件 和第一个 XML 地图的 导出的 XML 数据。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Create directory if it is not already present. | |
bool IsExists = System.IO.Directory.Exists(dataDir); | |
if (!IsExists) | |
System.IO.Directory.CreateDirectory(dataDir); | |
// Instantiating a Workbook object. | |
Workbook workbook = new Workbook(dataDir + "sample.xlsx"); | |
// Export all XML data from all XML Maps from the Workbook. | |
for (int i = 0; i < workbook.Worksheets.XmlMaps.Count; i++) | |
{ | |
// Access the XML Map. | |
XmlMap map = workbook.Worksheets.XmlMaps[i]; | |
// Exports its XML Data to file. | |
workbook.ExportXml(map.Name, dataDir + map.Name + ".xml"); | |
} |