Learn how to import data from JSON to Excel on Linux: https://blog.aspose.com/2021/09/25/import-data-from-json-to-excel-on-linux-java/
Last active
October 25, 2021 15:56
-
-
Save aspose-com-gists/472e8ea861c2359f0ea55d4a4ce9d0c7 to your computer and use it in GitHub Desktop.
Import JSON Data to Excel on Linux
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 JSON data | |
String jsonInput = "[{'nodeId':1,'reputation':1134},{'nodeId':2,'reputation':547},{'nodeId':3,'reputation':1703},{'nodeId':4,'reputation':-199},{'nodeId':5,'reputation':-306},{'nodeId':6,'reputation':-49},{'nodeId':7,'reputation':1527},{'nodeId':8,'reputation':1223}]"; | |
// create a blank Workbook object | |
Workbook workbook = new Workbook(); | |
// access default empty worksheet | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
// set JsonLayoutOptions for formatting | |
JsonLayoutOptions layoutOptions = new JsonLayoutOptions(); | |
layoutOptions.setArrayAsTable(true); | |
// import JSON data to Excel | |
JsonUtility.importData(jsonInput, worksheet.getCells(), 0, 0, layoutOptions); | |
// save Excel file | |
workbook.save("output.xlsx", SaveFormat.XLSX); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment