使用XmlMapCollection.Add方法在工作簿中添加XML映射

可能的使用场景

Aspose.Cells 提供了 XmlMapCollection.Add() 方法,您可以使用该方法将 XML 映射导入工作簿。

使用XmlMapCollection.Add方法在工作簿中添加XML映射

以下示例代码使用 XmlMapCollection.Add() 方法向工作簿中添加 XML 映射,并将其保存为 输出 Excel 文件。屏幕截图显示了已从 sample.xml 中导入的 XML 映射。

add-xml-map

// 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 workbook object
Workbook wb = new Workbook();
// Add xml map found inside the sample.xml inside the workbook
wb.Worksheets.XmlMaps.Add(dataDir + "sample.xml");
// Save the workbook in xlsx format
wb.Save(dataDir + "output_out.xlsx");