转换Excel为JSON
Contents
[
Hide
]
Aspose.Cells支持将工作簿转换为Json(JavaScript对象表示)文件。
将Excel工作簿转换为JSON
不需要纠结如何将Excel工作簿转换为JSON,因为Apose.Cells for .NET库有最佳决策。 Aspose.Cells API支持将电子表格转换为JSON格式。 要将工作簿导出到JSON,请将SaveFormat.Json作为Workbook.Save方法的第二个参数传递。 您还可以使用JsonSaveOptions类指定导出工作表到JSON的其他设置。
以下代码示例演示导出Excel工作簿为Json。请参阅转换源文件到代码生成的Json文件的代码以供参考。
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 | |
//Load your source workbook | |
Workbook workbook = new Workbook("sample.xlsx"); | |
//Convert the workbook to json file. | |
workbook.Save("sample_out.json"); |
以下代码示例示范了使用JsonSaveOptions类指定附加设置,从而导出Excel工作簿为Json。请参阅转换源文件到代码生成的Json文件的代码以供参考。
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 | |
//Create an options of saving the file. | |
JsonSaveOptions options = new JsonSaveOptions(); | |
//Set the exporting range. | |
options.ExportArea = CellArea.CreateCellArea("B1", "C4"); | |
//Load your source workbook | |
Workbook workbook = new Workbook("sample.xlsx"); | |
//Convert the workbook to json file. | |
workbook.Save("sample_out.json", options); |