JSON files are immensely used to store and transmit structured data. However, in certain cases, you may need to import data from JSON files to Excel spreadsheets. To achieve this programmatically, this article covers how to convert JSON files to Excel XLSX or XLS format on the Linux platform.
API to Import Data from JSON to Excel on Linux
Aspose.Cells for Java is a powerful and feature-rich API that lets you create and process spreadsheet documents. In addition, it lets you convert the spreadsheet files with high fidelity. You can download the API’s JAR or install it using the following Maven configurations.
<repository>
<id>AsposeJavaAPI</id>
<name>Aspose Java API</name>
<url>https://repository.aspose.com/repo/</url>
</repository>
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-cells</artifactId>
<version>21.9</version>
</dependency>
Import JSON Data to Excel on Linux
The following are the steps to import data from a JSON file to an Excel spreadsheet.
- First, read the JSON data into a string object.
- Then, create an instance of Workbook class.
- Get the reference of first worksheet into a Worksheet object.
- Create an instance of JsonLayoutOptions class.
- Set option using JsonLayoutOptions.setArrayAsTable().
- Import data from JSON to Excel using JsonUtility.importData() method.
- Finally, save the workbook using Workbook.save(string, SaveFormat) method.
The following code sample shows how to import data from JSON to Excel worksheet.
Get a Free License
You can use Aspose.Cells for Java without evaluation limitations using a temporary license.
Conclusion
In this article, you have learned how to import data from JSON files to Excel XLSX/XLS on Linux. You can explore more about Aspose.Cells for Java using the documentation. In case you would have any queries, you can ask us via our forum.