将 XML 导入到 Excel 工作簿
Contents
[
Hide
]
Aspose.Cells 允许您使用 Workbook.ImportXml() 方法将 XML 映射导入工作簿内。您可以使用以下步骤在 Microsoft Excel 中导入 XML 映射
- 选择** 开发人员** 选项卡
- 单击 在 XML 部分导入 并按照所需步骤操作。
您需要提供您的 XML 数据以完成导入。这里是一个样本 XML 数据,您可以用于测试。
使用 Microsoft Excel 导入 XML 地图
下面的截图显示如何使用 Microsoft Excel 导入 XML 地图。
![]() |
---|
使用 Aspose.Cells 导入 XML 地图
以下示例代码展示了如何使用 Workbook.ImportXml()。它可生成 输出的 Excel 文件,如此截图所示。
![]() |
---|
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 a workbook | |
Workbook workbook = new Workbook(); | |
// URL that contains your XML data for mapping | |
string XML = "http://www.aspose.com/docs/download/attachments/434475650/sampleXML.txt"; | |
// Import your XML Map data starting from cell A1 | |
workbook.ImportXml(XML, "Sheet1", 0, 0); | |
// Save workbook | |
workbook.Save(dataDir + "output_out.xlsx"); |