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

可能的使用场景

Aspose.Cells提供XmlMapCollection.Add()可用于在工作簿中导入 XML 映射的方法。

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

以下示例代码使用XmlMapCollection.Add()方法并将其另存为输出excel文件.屏幕截图显示了从示例.xml在输出 excel 文件中。

添加-xml-映射

// 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");