将 JSON 转换为 Excel
Contents
[
Hide
]
Aspose.Cells for Python via Java 支持将Json(JavaScript Object Notation)文件转换为Excel Workbook。
将 JSON 转换为 Excel 工作簿
无需考虑如何将 JSON 转换为 Excel 文件,因为 Aspose.Cells for Python via Java 库有最佳决策。 Aspose.Cells for Python via Java API 提供了将JSON格式转换为电子表格的支持。您可以使用JsonLoad选项类以指定将 JSON 导入工作簿的其他设置。
以下代码示例演示将 JSON 导入 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
import jpype | |
import asposecells | |
jpype.startJVM() | |
from asposecells.api import Workbook | |
# Load Source JSON file | |
workbook = Workbook("sample.json") | |
# Save file to xlsx format | |
workbook.save("sample_out.xlsx") | |
jpype.shutdownJVM() |
以下代码示例使用 JsonLoadOptions 类指定其他设置,演示了将 JSON 导入 Excel 工作簿。请看代码转换源文件以代码生成的xlsx文件供参考。
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
import jpype | |
import asposecells | |
jpype.startJVM() | |
from asposecells.api import Workbook, JsonLoadOptions | |
# Create an options of loading the file. | |
options = JsonLoadOptions() | |
# Indicates whether importing each attribute of JsonObject object as one worksheet when all child nodes are array nodes. | |
options.setMultipleWorksheets(True) | |
book = Workbook("sample.json", options) | |
# save file to xlsx format | |
book.save("sample_out2.xlsx") | |
jpype.shutdownJVM() |