将 Excel 转换为 JSON
Contents
[
Hide
]
Aspose.Cells 支持将 Workbook 转换为 Json(JavaScript Object Notation)文件。
将 Excel 工作簿转换为 JSON
无需考虑如何将 Excel 工作簿转换为 JSON,因为 Aspose.Cells Java 库有最佳决策。 Aspose.Cells Java API 提供将电子表格转换为 JSON 格式的支持。要将工作簿导出到 JSON,请通过保存格式.JSON作为第二个参数[工作簿.保存](https://reference.aspose.com/cells/java/com.aspose.cells/workbook#save(java.lang.String,%20int)) 方法。您也可以使用JsonSave选项类以指定将工作表导出到 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
//Load Source Excel file | |
Workbook workbook = new Workbook("sample.xlsx"); | |
//Save the workbook in JSON format | |
workbook.save("sample_out.json", SaveFormat.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
//Create an options of saving the file. | |
JsonSaveOptions options = new JsonSaveOptions(); | |
//Set the exporting range. | |
options.setExportArea(CellArea.createCellArea("B1", "C4")); | |
//Load Source Excel file | |
Workbook workbook = new Workbook("sample.xlsx"); | |
//Save the workbook in JSON format | |
workbook.save("sample_out.json", options); |