Export XML Data linked to XML Map inside the Workbook

Export XML Data linked to XML Map inside the Workbook

Please use the Workbook.export_xml() method to export XML data linked to your XML Maps inside your workbook. The following sample code exports XML data of all XML Maps from the workbook one by one. Please check the sample excel file used in this code and the exported XML data of the first XML Map.

from aspose.cells import Workbook
from os import os, path
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET
# The path to the documents directory.
dataDir = RunExamples.GetDataDir(".")
# Create directory if it is not already present.
IsExists = path.isdir(dataDir)
if notIsExists:
os.makedirs(dataDir)
# Instantiating a Workbook object.
workbook = Workbook(dataDir + "sample.xlsx")
# Export all XML data from all XML Maps from the Workbook.
for i in range(len(workbook.worksheets.xml_maps)):
# Access the XML Map.
map = workbook.worksheets.xml_maps[i]
# Exports its XML Data to file.
workbook.export_xml(map.name, dataDir + map.name + ".xml")