Add XML Map inside the Workbook using XmlMapCollection.Add method with C++

Possible Usage Scenarios

Aspose.Cells provides the XmlMapCollection.Add() method, which you can use to import your XML map into the workbook.

Add XML Map inside the Workbook using XmlMapCollection.Add method

The following sample code adds an XML map to the workbook using the XmlMapCollection.Add() method and saves it as an output Excel file. The screenshot shows the XML map that has been imported from the sample.xml into the output Excel file.

add-xml-map

#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;

int main()
{
    Aspose::Cells::Startup();

    // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C

    // Source directory path
    U16String srcDir(u"..\\Data\\01_SourceDirectory\\");

    // Path of input XML file
    U16String inputXmlMap = srcDir + u"sample.xml";

    // Create workbook object
    Workbook workbook;

    // Add the XML map found in sample.xml to the workbook
    workbook.GetWorksheets().GetXmlMaps().Add(inputXmlMap);

    // Save the workbook in XLSX format
    U16String outputFilePath = srcDir + u"output_out.xlsx";
    workbook.Save(outputFilePath);

    std::cout << "Workbook saved successfully in XLSX format!" << std::endl;

    Aspose::Cells::Cleanup();
}